Skip to content

Commit 61a6bf2

Browse files
committedAug 30, 2024
fix(engine): correct default regex flag
1 parent 5e66bf8 commit 61a6bf2

File tree

5 files changed

+79
-49
lines changed

5 files changed

+79
-49
lines changed
 

‎.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,4 @@ packages/shiki/src/assets/*.json
1616
cache
1717
.eslintcache
1818
report-engine-js-compat.json
19+
scripts/compares

‎packages/core/src/engines/javascript.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export class JavaScriptScanner implements PatternScanner {
2727
p
2828
// YAML specific handling; TODO: move to tm-grammars
2929
.replaceAll('[^\\s[-?:,\\[\\]{}#&*!|>\'"%@`]]', '[^\\s\\-?:,\\[\\]{}#&*!|>\'"%@`]'),
30-
{ flags: 'dg' },
30+
{ flags: 'dgm' },
3131
)
3232
cache?.set(p, regex)
3333
return regex

‎packages/shiki/test/engine-js/compare.test.ts

+8
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,14 @@ const cases: Cases[] = [
6969
'const foo: string = "bar"',
7070
],
7171
},
72+
{
73+
name: 'jsonc',
74+
theme: () => import('../../src/assets/themes/nord'),
75+
lang: () => import('../../src/assets/langs/jsonc'),
76+
cases: [
77+
'// comment\n{"foo":"bar"}',
78+
],
79+
},
7280
]
7381

7482
describe('cases', async () => {

‎scripts/report-engine-js-compat.md

+48-48
Original file line numberDiff line numberDiff line change
@@ -2,95 +2,133 @@
22

33
> At Fri Aug 30 2024
44
>
5-
> Version `1.14.1`
5+
> Version `1.15.0`
66
>
77
> Runtime: Node.js v20.12.2
88
99
| Status | Number |
1010
| :-------------- | -----: |
1111
| Total Languages | 213 |
12-
| OK | 84 |
13-
| Mismatch | 127 |
12+
| OK | 123 |
13+
| Mismatch | 88 |
1414
| Error | 2 |
1515

1616
| Language | Highlight Match | Patterns Parsable | Patterns Failed |
1717
| ------------------ | :-------------- | ----------------- | --------------- |
1818
| actionscript-3 | ✅ OK | 57 | - |
19+
| apache | ✅ OK | 60 | - |
1920
| apl | ✅ OK | 179 | - |
21+
| asm | ✅ OK | 297 | - |
2022
| awk | ✅ OK | 36 | - |
2123
| ballerina | ✅ OK | 231 | - |
22-
| beancount | ✅ OK | 39 | - |
24+
| bat | ✅ OK | 58 | - |
2325
| berry | ✅ OK | 18 | - |
2426
| bibtex | ✅ OK | 19 | - |
27+
| bicep | ✅ OK | 28 | - |
28+
| clarity | ✅ OK | 43 | - |
2529
| clj | ✅ OK | 38 | - |
2630
| clojure | ✅ OK | 38 | - |
31+
| cmake | ✅ OK | 23 | - |
2732
| codeowners | ✅ OK | 4 | - |
2833
| coffee | ✅ OK | 120 | - |
34+
| crystal | ✅ OK | 140 | - |
2935
| css | ✅ OK | 141 | - |
3036
| csv | ✅ OK | 1 | - |
37+
| d | ✅ OK | 270 | - |
38+
| dart | ✅ OK | 71 | - |
3139
| dax | ✅ OK | 23 | - |
3240
| desktop | ✅ OK | 16 | - |
41+
| diff | ✅ OK | 16 | - |
42+
| docker | ✅ OK | 7 | - |
43+
| dotenv | ✅ OK | 9 | - |
3344
| dream-maker | ✅ OK | 55 | - |
3445
| elixir | ✅ OK | 102 | - |
3546
| elm | ✅ OK | 68 | - |
3647
| erb | ✅ OK | 6 | - |
3748
| fennel | ✅ OK | 31 | - |
49+
| fish | ✅ OK | 22 | - |
50+
| fluent | ✅ OK | 23 | - |
51+
| fsharp | ✅ OK | 120 | - |
3852
| fsl | ✅ OK | 30 | - |
53+
| gdresource | ✅ OK | 32 | - |
54+
| gdscript | ✅ OK | 93 | - |
3955
| gdshader | ✅ OK | 38 | - |
56+
| genie | ✅ OK | 20 | - |
4057
| gherkin | ✅ OK | 16 | - |
4158
| gleam | ✅ OK | 26 | - |
4259
| glimmer-js | ✅ OK | 74 | - |
4360
| glimmer-ts | ✅ OK | 74 | - |
4461
| graphql | ✅ OK | 63 | - |
62+
| groovy | ✅ OK | 134 | - |
4563
| handlebars | ✅ OK | 64 | - |
64+
| haxe | ✅ OK | 175 | - |
4665
| hcl | ✅ OK | 61 | - |
66+
| hjson | ✅ OK | 55 | - |
67+
| hxml | ✅ OK | 6 | - |
68+
| hy | ✅ OK | 9 | - |
4769
| imba | ✅ OK | 242 | - |
4870
| javascript | ✅ OK | 378 | - |
4971
| jinja | ✅ OK | 35 | - |
5072
| json | ✅ OK | 19 | - |
5173
| json5 | ✅ OK | 23 | - |
74+
| jsonc | ✅ OK | 19 | - |
75+
| jsonl | ✅ OK | 19 | - |
76+
| jsonnet | ✅ OK | 33 | - |
5277
| jssm | ✅ OK | 30 | - |
5378
| jsx | ✅ OK | 378 | - |
5479
| kotlin | ✅ OK | 58 | - |
5580
| lean | ✅ OK | 32 | - |
81+
| less | ✅ OK | 261 | - |
5682
| liquid | ✅ OK | 69 | - |
5783
| log | ✅ OK | 30 | - |
5884
| luau | ✅ OK | 88 | - |
5985
| marko | ✅ OK | 81 | - |
6086
| mojo | ✅ OK | 213 | - |
6187
| move | ✅ OK | 117 | - |
88+
| narrat | ✅ OK | 34 | - |
6289
| nextflow | ✅ OK | 17 | - |
6390
| nginx | ✅ OK | 102 | - |
6491
| nix | ✅ OK | 80 | - |
92+
| nushell | ✅ OK | 75 | - |
6593
| ocaml | ✅ OK | 178 | - |
6694
| postcss | ✅ OK | 47 | - |
6795
| prisma | ✅ OK | 26 | - |
6896
| prolog | ✅ OK | 26 | - |
6997
| proto | ✅ OK | 33 | - |
98+
| puppet | ✅ OK | 59 | - |
7099
| python | ✅ OK | 218 | - |
71100
| qml | ✅ OK | 38 | - |
72101
| qmldir | ✅ OK | 7 | - |
73102
| qss | ✅ OK | 31 | - |
103+
| racket | ✅ OK | 68 | - |
104+
| reg | ✅ OK | 9 | - |
74105
| regexp | ✅ OK | 34 | - |
75106
| rel | ✅ OK | 17 | - |
76-
| rst | ✅ OK | 61 | - |
107+
| rust | ✅ OK | 89 | - |
77108
| sas | ✅ OK | 32 | - |
78109
| sass | ✅ OK | 67 | - |
79110
| scss | ✅ OK | 104 | - |
80111
| smalltalk | ✅ OK | 31 | - |
112+
| soy | ✅ OK | 45 | - |
81113
| system-verilog | ✅ OK | 102 | - |
82114
| systemd | ✅ OK | 32 | - |
115+
| tasl | ✅ OK | 22 | - |
83116
| tcl | ✅ OK | 33 | - |
84117
| terraform | ✅ OK | 62 | - |
85118
| ts-tags | ✅ OK | - | - |
86119
| tsv | ✅ OK | 1 | - |
87120
| tsx | ✅ OK | 378 | - |
121+
| turtle | ✅ OK | 15 | - |
88122
| twig | ✅ OK | 94 | - |
89123
| typescript | ✅ OK | 366 | - |
124+
| typespec | ✅ OK | 80 | - |
90125
| typst | ✅ OK | 78 | - |
91126
| v | ✅ OK | 76 | - |
127+
| vala | ✅ OK | 20 | - |
128+
| vhdl | ✅ OK | 82 | - |
92129
| viml | ✅ OK | 72 | - |
93130
| vyper | ✅ OK | 238 | - |
131+
| wasm | ✅ OK | 78 | - |
94132
| wenyan | ✅ OK | 18 | - |
95133
| wgsl | ✅ OK | 44 | - |
96134
| wikitext | ✅ OK | 104 | - |
@@ -99,71 +137,46 @@
99137
| xsl | ✅ OK | 5 | - |
100138
| zenscript | ✅ OK | 21 | - |
101139
| zig | ✅ OK | 51 | - |
140+
| ada | ✅ OK | 199 | 1 |
102141
| abap | ⚠️ Mismatch | 49 | - |
103142
| angular-html | ⚠️ Mismatch | 2 | - |
104143
| angular-ts | ⚠️ Mismatch | 366 | - |
105-
| apache | ⚠️ Mismatch | 60 | - |
106144
| apex | ⚠️ Mismatch | 189 | - |
107145
| applescript | ⚠️ Mismatch | 151 | - |
108146
| ara | ⚠️ Mismatch | 54 | - |
109147
| asciidoc | ⚠️ Mismatch | 262 | - |
110-
| asm | ⚠️ Mismatch | 297 | - |
111148
| astro | ⚠️ Mismatch | 59 | - |
112149
| bash | ⚠️ Mismatch | 146 | - |
113-
| bat | ⚠️ Mismatch | 58 | - |
114-
| bicep | ⚠️ Mismatch | 28 | - |
150+
| beancount | ⚠️ Mismatch | 39 | - |
115151
| blade | ⚠️ Mismatch | 330 | - |
116152
| c | ⚠️ Mismatch | 158 | - |
117153
| cadence | ⚠️ Mismatch | 71 | - |
118-
| clarity | ⚠️ Mismatch | 43 | - |
119-
| cmake | ⚠️ Mismatch | 23 | - |
120154
| cobol | ⚠️ Mismatch | 138 | - |
121155
| codeql | ⚠️ Mismatch | 150 | - |
122156
| common-lisp | ⚠️ Mismatch | 57 | - |
123157
| coq | ⚠️ Mismatch | 25 | - |
124158
| cpp | ⚠️ Mismatch | 220 | - |
125-
| crystal | ⚠️ Mismatch | 140 | - |
126159
| cue | ⚠️ Mismatch | 85 | - |
127160
| cypher | ⚠️ Mismatch | 39 | - |
128-
| d | ⚠️ Mismatch | 270 | - |
129-
| dart | ⚠️ Mismatch | 71 | - |
130-
| diff | ⚠️ Mismatch | 16 | - |
131-
| docker | ⚠️ Mismatch | 7 | - |
132-
| dotenv | ⚠️ Mismatch | 9 | - |
133161
| edge | ⚠️ Mismatch | 10 | - |
134162
| emacs-lisp | ⚠️ Mismatch | 151 | - |
135163
| erlang | ⚠️ Mismatch | 147 | - |
136-
| fish | ⚠️ Mismatch | 22 | - |
137-
| fluent | ⚠️ Mismatch | 23 | - |
138164
| fortran-fixed-form | ⚠️ Mismatch | 6 | - |
139165
| fortran-free-form | ⚠️ Mismatch | 317 | - |
140-
| fsharp | ⚠️ Mismatch | 120 | - |
141-
| gdresource | ⚠️ Mismatch | 32 | - |
142-
| gdscript | ⚠️ Mismatch | 93 | - |
143-
| genie | ⚠️ Mismatch | 20 | - |
144166
| glsl | ⚠️ Mismatch | 7 | - |
145167
| gnuplot | ⚠️ Mismatch | 82 | - |
146168
| go | ⚠️ Mismatch | 117 | - |
147-
| groovy | ⚠️ Mismatch | 134 | - |
148169
| hack | ⚠️ Mismatch | 301 | - |
149170
| haml | ⚠️ Mismatch | 64 | - |
150171
| haskell | ⚠️ Mismatch | 157 | - |
151-
| haxe | ⚠️ Mismatch | 175 | - |
152-
| hjson | ⚠️ Mismatch | 55 | - |
153172
| hlsl | ⚠️ Mismatch | 52 | - |
154173
| html | ⚠️ Mismatch | 116 | - |
155174
| http | ⚠️ Mismatch | 20 | - |
156-
| hxml | ⚠️ Mismatch | 6 | - |
157-
| hy | ⚠️ Mismatch | 9 | - |
158175
| ini | ⚠️ Mismatch | 11 | - |
159176
| java | ⚠️ Mismatch | 141 | - |
160177
| jison | ⚠️ Mismatch | 57 | - |
161-
| jsonc | ⚠️ Mismatch | 19 | - |
162-
| jsonl | ⚠️ Mismatch | 19 | - |
163-
| jsonnet | ⚠️ Mismatch | 33 | - |
164178
| kusto | ⚠️ Mismatch | 60 | - |
165179
| latex | ⚠️ Mismatch | 183 | - |
166-
| less | ⚠️ Mismatch | 261 | - |
167180
| logo | ⚠️ Mismatch | 9 | - |
168181
| lua | ⚠️ Mismatch | 113 | - |
169182
| make | ⚠️ Mismatch | 48 | - |
@@ -172,11 +185,9 @@
172185
| mdc | ⚠️ Mismatch | 27 | - |
173186
| mdx | ⚠️ Mismatch | 180 | - |
174187
| mermaid | ⚠️ Mismatch | 129 | - |
175-
| narrat | ⚠️ Mismatch | 34 | - |
176188
| nim | ⚠️ Mismatch | 114 | - |
177-
| nushell | ⚠️ Mismatch | 75 | - |
178-
| objective-c | ⚠️ Mismatch | 219 | - |
179-
| objective-cpp | ⚠️ Mismatch | 300 | - |
189+
| objective-c | ⚠️ Mismatch | 217 | - |
190+
| objective-cpp | ⚠️ Mismatch | 297 | - |
180191
| pascal | ⚠️ Mismatch | 23 | - |
181192
| perl | ⚠️ Mismatch | 156 | - |
182193
| php | ⚠️ Mismatch | 328 | - |
@@ -185,45 +196,34 @@
185196
| powerquery | ⚠️ Mismatch | 30 | - |
186197
| powershell | ⚠️ Mismatch | 88 | - |
187198
| pug | ⚠️ Mismatch | 92 | - |
188-
| puppet | ⚠️ Mismatch | 59 | - |
189199
| purescript | ⚠️ Mismatch | 72 | - |
190200
| r | ⚠️ Mismatch | 73 | - |
191-
| racket | ⚠️ Mismatch | 68 | - |
192201
| raku | ⚠️ Mismatch | 52 | - |
193-
| reg | ⚠️ Mismatch | 9 | - |
194202
| riscv | ⚠️ Mismatch | 36 | - |
203+
| rst | ⚠️ Mismatch | 61 | - |
195204
| ruby | ⚠️ Mismatch | 154 | - |
196-
| rust | ⚠️ Mismatch | 89 | - |
197205
| scala | ⚠️ Mismatch | 108 | - |
198206
| scheme | ⚠️ Mismatch | 34 | - |
199207
| shaderlab | ⚠️ Mismatch | 38 | - |
200208
| shellscript | ⚠️ Mismatch | 146 | - |
201209
| shellsession | ⚠️ Mismatch | 2 | - |
202210
| solidity | ⚠️ Mismatch | 102 | - |
203-
| soy | ⚠️ Mismatch | 45 | - |
204211
| sparql | ⚠️ Mismatch | 4 | - |
205212
| splunk | ⚠️ Mismatch | 17 | - |
206213
| sql | ⚠️ Mismatch | 67 | - |
207214
| ssh-config | ⚠️ Mismatch | 12 | - |
208215
| stata | ⚠️ Mismatch | 189 | - |
209216
| stylus | ⚠️ Mismatch | 107 | - |
210217
| svelte | ⚠️ Mismatch | 83 | - |
211-
| tasl | ⚠️ Mismatch | 22 | - |
212218
| templ | ⚠️ Mismatch | 74 | - |
213219
| tex | ⚠️ Mismatch | 38 | - |
214220
| toml | ⚠️ Mismatch | 40 | - |
215-
| turtle | ⚠️ Mismatch | 15 | - |
216-
| typespec | ⚠️ Mismatch | 80 | - |
217-
| vala | ⚠️ Mismatch | 20 | - |
218221
| vb | ⚠️ Mismatch | 34 | - |
219222
| verilog | ⚠️ Mismatch | 33 | - |
220-
| vhdl | ⚠️ Mismatch | 82 | - |
221223
| vue | ⚠️ Mismatch | 69 | - |
222224
| vue-html | ⚠️ Mismatch | 36 | - |
223-
| wasm | ⚠️ Mismatch | 78 | - |
224225
| yaml | ⚠️ Mismatch | 46 | - |
225226
| zsh | ⚠️ Mismatch | 146 | - |
226-
| ada | ⚠️ Mismatch | 199 | 1 |
227227
| csharp | ⚠️ Mismatch | 298 | 1 |
228228
| razor | ⚠️ Mismatch | 83 | 2 |
229229
| swift | ❌ Error | 302 | 4 |

‎scripts/report-engine-js-compat.ts

+21
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ export interface ReportItem {
2222
async function run() {
2323
const report: ReportItem[] = []
2424

25+
await fs.rm(new URL('./compares', import.meta.url), { recursive: true, force: true })
26+
2527
for (const lang of Object.keys(bundledLanguages)) {
2628
const sample = await fs.readFile(`../tm-grammars-themes/samples/${lang}.sample`, 'utf-8')
2729
.catch(() => '')
@@ -70,6 +72,25 @@ async function run() {
7072

7173
if (!highlightMatch) {
7274
console.log(c.yellow(`[${lang}] Mismatch`))
75+
76+
await fs.mkdir(new URL('./compares', import.meta.url), { recursive: true })
77+
78+
await fs.writeFile(
79+
new URL(`./compares/${lang}.html`, import.meta.url),
80+
[
81+
'<style>',
82+
'body { display: flex; }',
83+
'pre { flex: 1; margin: 0; padding: 0; }',
84+
'</style>',
85+
'<pre>',
86+
highlightA,
87+
'</pre>',
88+
'<pre>',
89+
highlightB,
90+
'</pre>',
91+
].join('\n'),
92+
'utf-8',
93+
)
7394
}
7495
else {
7596
console.log(c.green(`[${lang}] OK`))

0 commit comments

Comments
 (0)
Please sign in to comment.