Skip to content

Commit e4f70ec

Browse files
committedAug 30, 2024··
fix: support more languages
1 parent 55526bb commit e4f70ec

File tree

5 files changed

+766
-4
lines changed

5 files changed

+766
-4
lines changed
 

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

+2
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ export class JavaScriptScanner implements PatternScanner {
2525
try {
2626
const regex = onigurumaToRegexp(
2727
p
28+
.replace(/\|\\G(\||\))/g, '$1')
29+
.replace(/(\(|\|)\\G\|/g, '$1')
2830
// YAML specific handling; TODO: move to tm-grammars
2931
.replaceAll('[^\\s[-?:,\\[\\]{}#&*!|>\'"%@`]]', '[^\\s\\-?:,\\[\\]{}#&*!|>\'"%@`]'),
3032
{

‎packages/shiki/test/engine-js/__records__/markdown.json

+733
Large diffs are not rendered by default.

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

+25
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,31 @@
115115
].join('\n'),
116116
],
117117
},
118+
{
119+
name: 'markdown',
120+
theme: () => import('../../src/assets/themes/nord'),
121+
lang: () => import('../../src/assets/langs/markdown'),
122+
cases: [
123+
[
124+
'# Header',
125+
'',
126+
'This is a paragraph',
127+
'',
128+
'```ts',
129+
'const foo = "bar"',
130+
'```',
131+
].join('\n'),
132+
[
133+
'look like:',
134+
'',
135+
' * this one',
136+
' * that one',
137+
' * the other one',
138+
'',
139+
'and this',
140+
].join('\n'),
141+
],
142+
},
118143
]
119144

120145
describe('cases', async () => {
@@ -160,7 +185,7 @@
160185
.toMatchFileSnapshot(`./__records__/${c.c.name}.json`)
161186

162187
compare.forEach(([a, b]) => {
163188
expect.soft(a).toEqual(b)
164189
// await expect.soft(a)
165190
// .toMatchFileSnapshot(`./__records__/tokens/${c.c.name}-${i}.json`)
166191
})

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

+3-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ const cache = new Map<string, RegExp | Error>()
1717
for (const file of files) {
1818
// Some token positions are off in this record
1919
const name = basename(file, '.json')
20-
if (name === 'ts-basic')
20+
21+
// TODO: markdown support is still problematic
22+
if (name === 'markdown')
2123
continue
2224

2325
describe(`record: ${name}`, async () => {

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
| Status | Number |
1010
| :-------------- | -----: |
1111
| Total Languages | 213 |
12-
| OK | 178 |
13-
| Mismatch | 33 |
12+
| OK | 179 |
13+
| Mismatch | 32 |
1414
| Error | 2 |
1515

1616
| Language | Highlight Match | Patterns Parsable | Patterns Failed |
@@ -38,6 +38,7 @@
3838
| cmake | ✅ OK | 23 | - |
3939
| cobol | ✅ OK | 138 | - |
4040
| codeowners | ✅ OK | 4 | - |
41+
| codeql | ✅ OK | 150 | - |
4142
| coffee | ✅ OK | 120 | - |
4243
| common-lisp | ✅ OK | 57 | - |
4344
| cpp | ✅ OK | 220 | - |
@@ -199,7 +200,6 @@
199200
| beancount | ⚠️ Mismatch | 39 | - |
200201
| blade | ⚠️ Mismatch | 330 | - |
201202
| cadence | ⚠️ Mismatch | 71 | - |
202-
| codeql | ⚠️ Mismatch | 150 | - |
203203
| coq | ⚠️ Mismatch | 25 | - |
204204
| cue | ⚠️ Mismatch | 85 | - |
205205
| cypher | ⚠️ Mismatch | 39 | - |

0 commit comments

Comments
 (0)
Please sign in to comment.