我正在按照这个示例在 markdown 中进行简单的语法注入。
{
"fileTypes": [],
"injectionSelector": "L:markup.fenced_code.block.markdown",
"patterns": [
{
"include": "#superjs-code-block"
}
],
"repository": {
"superjs-code-block": {
"begin": "superjs",
"end": "(^|\\G)(?=\\s*[`~]{3,}\\s*$)",
"contentName": "meta.embedded.block.superjs",
"patterns": [
{
"include": "source.js"
}
]
}
},
"scopeName": "markdown.superjs.codeblock"
}
上面的代码有个小问题——只要有一个字符串superjs
出现在fenced代码块中,剩下的总是会渲染为superjs,这会破坏其他嵌入式语言的fenced代码块语法高亮。
{
"foo": "superjs"
}
我想通过关注markdown.tmLanguage.json来修复它。
{
"fileTypes": [],
"injectionSelector": "text.html.markdown",
"patterns": [
{
"include": "#fenced_code_block_superjs"
}
],
"repository": {
"fenced_code_block_superjs": {
"begin": "(^|\\G)(\\s*)(`{3,}|~{3,})\\s*(?i:(superjs)(\\s+[^`~]*)?$)",
"beginCaptures": {
"3": {
"name": "punctuation.definition.markdown"
},
"5": {
"name": "fenced_code.block.language"
},
"6": {
"name": "fenced_code.block.language.attributes"
}
},
"end": "(^|\\G)(\\2|\\s{0,3})(\\3)\\s*$",
"endCaptures": {
"3": {
"name": "punctuation.definition.markdown"
}
},
"name": "markup.fenced_code.block.markdown",
"patterns": [
{
"begin": "(^|\\G)(\\s*)(.*)",
"contentName": "meta.embedded.block.superjs",
"patterns": [
{
"include": "source.js"
}
],
"while": "(^|\\G)(?!\\s*([`~]{3,})\\s*$)"
}
]
}
},
"scopeName": "markdown.superjs.codeblock"
}
但是它不起作用,我也不知道如何调试它。