我希望将一些自定义语法亮点添加到现有的语法亮点上,但我不想保留我全部使用的基本副本。有没有办法扩展现有语法(如果可能的话,并通过更新继续这样做),只是附加了一些新规则?
我已经尝试使用扩展:packages/html/html.sublime-syntax
在我自己的.sublime-syntax文件中,但是我遇到了“ 语法继承不允许混合的控制台错误版本”,我不知道那意味着什么。我看不到文档。帮助?
I'm looking to add a few custom syntax highlights to an existing one, but I don't want to maintain a copy of the base one I'm using in its entirety. Is there a way to extend an existing syntax (and continue to do so through updating, if possible) and just append a few new rules to it?
I've tried using extends: Packages/HTML/HTML.sublime-syntax
in my own .sublime-syntax file, but I get a console error for "syntax inheritance does not allow for mixed versions" and I have no idea what that means. I don't see it mentioned in the documentation either. Help?
发布评论
评论(1)
语法定义上的文档具有继承上的p节以及如何做到;有关于限制的部分:
版本
是最新版本语法中的一个新概念;它在版本的概念添加>以使较新的语法可以利用自己的修复程序。结果,如上所述,所有语法都必须是相同的
版本
,以使其行为保持一致。在Sublime Text 4中新重写/改版的语法使用新版本,而html
语法是其中之一。因此,您需要在语法中包含
版本:2
才能扩展HTML语法。The Documentation on Syntax Definitions has a section on inheritance and how you do it; there a section on Limitations:
version
is a new concept in recent versions of Syntaxes; it's listed under compatibility. The general gist is that there are various things about syntaxes which are either bugs or unexpected/undesirable behaviour, but since there are so many syntaxes already available that would be broken if that behaviour was changed, the concept ofversion
was added so that newer syntaxes can avail themselves of fixes.As a result, as mentioned above all syntaxes must be the same
version
, ostensibly so that their behaviour is consistent. Syntaxes that are newly rewritten/revamped in Sublime Text 4 use the new version, and theHTML
syntax is one of them.Hence, you need to include
version: 2
in your syntax to be able to extend the HTML syntax.