我的语法突出显示语法注入有什么问题? [英] What's wrong with my syntax highlighting grammar injection?
问题描述
I am following this example for a simple grammar injection in 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
,其余的将始终呈现为superjs,这将破坏受防护的代码块语法在其他嵌入式代码中的突出显示语言.
There is a small problem with the above code - As long as there is a string superjs
appear in the fenced code block, the remaining would always be rendered as superjs, which would break fenced code block syntax highlighting for other embedded languages.
{
"foo": "superjs"
}
我想通过遵循
但是它不起作用,我也不知道如何调试它. However it doesn't work, and I don't know how to debug it either. 这是规则优先级问题. 我必须在 I have to use the 注入选择器中的 The 这篇关于我的语法突出显示语法注入有什么问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!推荐答案
"injectionSelector": "L:text.html.markdown"
中使用L:
前缀,而不是在此处记录:L:
prefix in "injectionSelector": "L:text.html.markdown"
instead as documented here:
L:
意味着将注入添加到现有语法规则的左侧.这基本上意味着我们的注入语法规则将在任何现有语法规则之前应用.
L:
in the injection selector means that the injection is added to the left of existing grammar rules. This basically means that our injected grammar's rules will be applied before any existing grammar rules.