Skip to content

Commit 159efd7

Browse files
authored
fix(highlight): highlight json/yaml render blocks inside comark syntax (#300)
1 parent 060dfa9 commit 159efd7

1 file changed

Lines changed: 15 additions & 4 deletions

File tree

packages/comark/src/utils/comark.tmLanguage.ts

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -220,12 +220,12 @@ const comark = {
220220
],
221221
},
222222
{
223-
match: '^(\\s*)(#[\\w\\-\\_]*)\\s*(<!--(.*)-->)?$',
223+
match: '(^|\\G)(\\s*)(#[\\w\\-\\_]*)\\s*(<!--(.*)-->)?$',
224224
captures: {
225-
'2': {
225+
'3': {
226226
name: 'entity.other.attribute-name.html',
227227
},
228-
'3': {
228+
'4': {
229229
name: 'comment.block.html',
230230
},
231231
},
@@ -582,7 +582,7 @@ const comark = {
582582
include: '#heading-setext',
583583
},
584584
],
585-
while: '(^|\\G)((?=\\s*[-=]{3,}\\s*$)|[ ]{4,}(?=\\S))',
585+
while: '(^|\\G)(?=\\s*[-=]{3,}\\s*$)',
586586
},
587587
blockquote: {
588588
begin: '(^|\\G)[ ]*(>) ?',
@@ -602,4 +602,15 @@ const comark = {
602602
},
603603
}
604604

605+
const jsonb = markdown[0].repository.fenced_code_block_json
606+
const yamlb = markdown[0].repository.fenced_code_block_yaml
607+
markdown[0].repository.fenced_code_block_json = {
608+
...markdown[0].repository.fenced_code_block_json,
609+
begin: String(jsonb.begin).replace('json5??|', 'json5??|json-render|'),
610+
}
611+
markdown[0].repository.fenced_code_block_yaml = {
612+
...markdown[0].repository.fenced_code_block_yaml,
613+
begin: String(yamlb.begin).replace('(ya?ml)', '(ya?ml|ya?ml-render)'),
614+
}
615+
605616
export default [...markdown, ...yaml, ...html_derivative, comark]

0 commit comments

Comments
 (0)