file.a
<start of file>
// some code with syntax highlighting of language A
// following statement is language A syntax which start with <Block> keyword
Block parameters;
// following is the snippet which start with <Block> keyword and end with <@endBlock>
Block parameters;
// some code with syntax highlighting of secondary language B
@endblock;
// some code with syntax highlighting of language A
<end of file>
"patterns": [
{
"name" : "meta.block,
"begin": “(?i)(block)\\W.*$",
"end": "(?i)^\\s*(@endblock)\\W”,
}
现在的问题是 - 文本媒体与“ block”语句的启动模式匹配,但是请继续检查“ @endblock”,如果它(@endblock)不可用,则Textmate继续检查相同直到文件结束,因此,由于这种语言 - 语言的语言,就像语言B.
Scenario-1<Block>
.
. This should not be secondary language B syntax highlighting
.
<Block>
.
. This is correct secondary language B syntax highlighting
.
<@endblock>
Scenario -2
<Block>
.
. following code should not be secondary language B syntax highlighting, it must be primary language A.
.
.
.
.
<end of file>
我们不能阻止文本成员既匹配开始又结束,然后才能突出特定的语法,否则忽略?
还是还有其他方法可以解决这个问题?
aaddly这是不可能的
textmate是自上而下的解析器按线解析行
例如。您无法查看多行以查看是否存在某物是否存在
找到最好的方法是在找到"end": "(?i)^\\s*(@endblock)\\b|(?=block\\b.*$)”
(我认为您想要\\b
word-boundary而不是
\\W
非字符)
or 如果您能够在Block
之后添加评论,则指出下一节应该是语言b
Block // Language B