diff --git a/src/transform.ts b/src/transform.ts index ccdbb62..df0fb5d 100644 --- a/src/transform.ts +++ b/src/transform.ts @@ -128,7 +128,13 @@ export const rules: any = [ [/([\s'])contain([\s'!]|$)/, (_: string, v1: string, v2: string) => `${v1}bg-contain${v2}`], [/([\s'])cover([\s'!]|$)/, (_: string, v1: string, v2: string) => `${v1}bg-cover${v2}`], [/([\s'])line(\d+)([\s'!]|$)/, (_: string, v1: string, v2: string, v3: string) => `${v1}line-clamp-${v2}${v3}`], - [/([\s!])\(([^)]+)\)([\s'!]|$)/, (_: string, v1: string, v2: string, v3: string) => v2.replace(/\s+/g, ' ').split(' ').map(item => `!${item}`).join(' ') + v3], + [/([\s!])\(([^)]+)\)([\s'!]|$)/, (_: string, v1: string, v2: string, v3: string) => { + if (v1 === '!') + return v2.replace(/\s+/g, ' ').split(' ').map(item => `!${item}`).join(' ') + v3 + if (v3 === '!') + return v2.replace(/\s+/g, ' ').split(' ').map(item => `!${item}`).join(' ') + return _ + }], ].filter(Boolean) export function transform(content: string) { diff --git a/test/index.test.ts b/test/index.test.ts index 294140c..1e059db 100644 --- a/test/index.test.ts +++ b/test/index.test.ts @@ -128,5 +128,6 @@ describe('should', () => { it('magic transformClass w!', () => { expect(transformClass('