Skip to content

Commit

Permalink
Fix detection of classes in markdown code fences
Browse files Browse the repository at this point in the history
  • Loading branch information
thecrypticace committed Jun 9, 2022
1 parent c44dd7b commit 4a99a9c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/lib/defaultExtractor.js
Expand Up @@ -25,7 +25,7 @@ function* buildRegExps(context) {

let utility = regex.any([
// Arbitrary properties
/\[[^\s:'"]+:[^\s\]]+\]/,
/\[[^\s:'"`]+:[^\s\]]+\]/,

// Utilities
regex.pattern([
Expand All @@ -43,7 +43,7 @@ function* buildRegExps(context) {
/(?![{([]])/,

// optionally followed by an opacity modifier
/(?:\/[^\s'"\\><$]*)?/,
/(?:\/[^\s'"`\\><$]*)?/,
]),

regex.pattern([
Expand All @@ -54,11 +54,11 @@ function* buildRegExps(context) {
/(?![{([]])/,

// optionally followed by an opacity modifier
/(?:\/[^\s'"\\$]*)?/,
/(?:\/[^\s'"`\\$]*)?/,
]),

// Normal values w/o quotes — may include an opacity modifier
/[-\/][^\s'"\\$={><]*/,
/[-\/][^\s'"`\\$={><]*/,
])
),
]),
Expand All @@ -69,8 +69,8 @@ function* buildRegExps(context) {
'((?=((',
regex.any(
[
regex.pattern([/([^\s"'\[\\]+-)?\[[^\s"'\\]+\]/, separator]),
regex.pattern([/[^\s"'\[\\]+/, separator]),
regex.pattern([/([^\s"'`\[\\]+-)?\[[^\s"'`\\]+\]/, separator]),
regex.pattern([/[^\s"'`\[\\]+/, separator]),
],
true
),
Expand Down
9 changes: 9 additions & 0 deletions tests/default-extractor.test.js
Expand Up @@ -449,3 +449,12 @@ test('with angle brackets', async () => {
expect(extractions).not.toContain('>shadow-xl')
expect(extractions).not.toContain('shadow-xl<')
})

test('markdown code fences', async () => {
const extractions = defaultExtractor('<!-- this should work: `.font-bold`, `.font-normal` -->')

expect(extractions).toContain('font-bold')
expect(extractions).toContain('font-normal')
expect(extractions).not.toContain('.font-bold')
expect(extractions).not.toContain('.font-normal')
})

0 comments on commit 4a99a9c

Please sign in to comment.