diff --git a/src/index.ts b/src/index.ts index 0fccbf9..3c3d15f 100644 --- a/src/index.ts +++ b/src/index.ts @@ -53,7 +53,7 @@ export async function transformAlias( if (typeof keep === 'string') keep = { prefix: keep, block: true } - const extraRE = new RegExp(`(${escapeRegExp(prefix)}|${escapeRegExp(keep.prefix)})([\\w-]+)`, 'g') + const extraRE = new RegExp(`(${escapeRegExp(prefix)}|${escapeRegExp(keep.prefix)})([\\w-:]+)`, 'g') const map = new Map() for (const item of Array.from(code.original.matchAll(extraRE))) { diff --git a/test/index.test.ts b/test/index.test.ts index df8a15c..21ede3c 100644 --- a/test/index.test.ts +++ b/test/index.test.ts @@ -8,6 +8,7 @@ const uno = createGenerator({ shortcuts: [ ['btn', 'text-(white xl) font-bold py-2 px-4 rounded cursor-pointer'], [/^btn-(.+)$/, ([,d]) => `bg-${d}-500 hover:bg-${d}-700 btn`], + [/^tapped:(.*)$/, ([, c]) => `hover:${c} active:${c}`], ], }) @@ -31,6 +32,7 @@ describe('transformer alias', () => {
+
`.trim() @@ -40,6 +42,7 @@ describe('transformer alias', () => {
+
" `) @@ -53,6 +56,8 @@ describe('transformer alias', () => {
+
+
`.trim() @@ -62,6 +67,8 @@ describe('transformer alias', () => {
+
+
" `) @@ -72,6 +79,8 @@ describe('transformer alias', () => { `.trim() const transform = createTransformer() @@ -80,6 +89,8 @@ describe('transformer alias', () => { "" `)