【发布时间】:2016-10-05 16:55:05
【问题描述】:
我正在处理自定义语法突出显示,并从 HTML 语法中复制了一些 sn-ps,因为这部分非常相似。我一直在试图弄清楚如何突出显示标签内的文本。这是我的定义:
- match: "(</?)([a-zA-Z0-9:]+)"
captures:
1: punctuation.definition.tag.begin.html
2: entity.name.tag.other.html
push:
- meta_scope: meta.tag.other.html
- match: '>'
scope: punctuation.definition.tag.end.html
pop: true
- match: '.'
scope: string.quoted.single.html
示例文本:
<file bash>
Some bash code block
Some bash code block
</file>
我的代码突出显示了括号 <>、file 和 bash 关键字,但我不知道如何为里面的块添加颜色。最终我想把它作为一个块评论或类似的东西,这样它就会脱颖而出。有什么建议吗?
我需要一个避免为没有结束标签的标签添加注释突出显示的解决方案。例如,我正在使用的标记中的某些标签不使用关闭,例如<tag without close> 没有</tag>。有什么方法可以在正则表达式中添加排除项以仅在有打开和关闭标签时才有效,但在只有打开标签时无效?
<tag without close>
This should not be a comment.
<file bash>
This should be a comment.
</file>
This also should not be a comment.
只会使用一小部分标签,如上面的<tag>,主要用于元数据。
【问题讨论】:
标签: sublimetext3 sublimetext sublime-text-plugin