我可以将自定义亮点附加到现有语法的情况下,而无需分叉吗?

发布于 2025-01-24 17:59:33 字数 365 浏览 5 评论 0 原文

我希望将一些自定义语法亮点添加到现有的语法亮点上,但我不想保留我全部使用的基本副本。有没有办法扩展现有语法(如果可能的话,并通过更新继续这样做),只是附加了一些新规则?

我已经尝试使用扩展: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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

穿透光 2025-01-31 17:59:34

语法定义上的文档具有继承上的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:

A syntax may extend a syntax that itself extends another syntax. There are no enforced limits on extending, other than that all syntaxes must share the same version.

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 of version 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 the HTML syntax is one of them.

Hence, you need to include version: 2 in your syntax to be able to extend the HTML syntax.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文