Skip to content

Commit

Permalink
fix(engine): correct default regex flag
Browse files Browse the repository at this point in the history
  • Loading branch information
antfu committed Aug 30, 2024
1 parent 5e66bf8 commit 61a6bf2
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 49 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ packages/shiki/src/assets/*.json
cache
.eslintcache
report-engine-js-compat.json
scripts/compares
2 changes: 1 addition & 1 deletion packages/core/src/engines/javascript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export class JavaScriptScanner implements PatternScanner {
p
// YAML specific handling; TODO: move to tm-grammars
.replaceAll('[^\\s[-?:,\\[\\]{}#&*!|>\'"%@`]]', '[^\\s\\-?:,\\[\\]{}#&*!|>\'"%@`]'),
{ flags: 'dg' },
{ flags: 'dgm' },
)
cache?.set(p, regex)
return regex
Expand Down
8 changes: 8 additions & 0 deletions packages/shiki/test/engine-js/compare.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,14 @@ const cases: Cases[] = [
'const foo: string = "bar"',
],
},
{
name: 'jsonc',
theme: () => import('../../src/assets/themes/nord'),
lang: () => import('../../src/assets/langs/jsonc'),
cases: [
'// comment\n{"foo":"bar"}',
],
},
]

describe('cases', async () => {
Expand Down
Loading

0 comments on commit 61a6bf2

Please sign in to comment.