无法在 TextMate 中进行自定义语法突出显示
我试图在 TextMate 中突出显示自定义语言。但是,以下定义不会突出显示 PHP 插入(我确实为我的 *.serpent 文件选择了它):
{ scopeName = 'source.serpent';
fileTypes = ( 'serpent' );
patterns = (
{ begin = '<\?';
end = '\?>';
patterns = ( { include = 'source.php'; } );
},
);
}
如果我选择 PHP 语言,则 PHP 部分会突出显示。
可能是什么原因?应该有效吗?
我也在考虑用 <% %> 插入红宝石分隔符,但它不适用于最简单的设置。
更新
显然,这只是 PHP 的问题。以下语言定义在我的文本中突出显示了 Ruby 和 Serpent 语言,但没有突出显示 PHP 插入!这里有什么问题吗?
{ scopeName = 'source.phpruby.serpent';
fileTypes = ( 'serpent', 'serpent.php', 'serpent.erb' );
patterns = (
{ begin = '<\?(php|=)?';
end = '\?>';
patterns = ( { include = 'source.php'; } );
},
{ begin = '<%';
end = '%>';
patterns = ( { include = 'source.ruby'; } );
},
{ include = 'source.serpent'; },
);
}
我通过在我的模式中用 #language 替换 source.php 并从 PHP 语言复制存储库来使其工作。
I am trying to highlight a custom language in TextMate. However, the following definition does not highlight PHP insertions (I do select it for my *.serpent files):
{ scopeName = 'source.serpent';
fileTypes = ( 'serpent' );
patterns = (
{ begin = '<\?';
end = '\?>';
patterns = ( { include = 'source.php'; } );
},
);
}
If I select PHP language, then the PHP parts are highlighted.
What can be the reason? Should it work?
I was also considering ruby insertions with <% %> delimiters, but it doesn't work with the simplest setup.
Update
Apparently, it is an issue of PHP only. The following language definition highlights Ruby and Serpent languages in my text, but not PHP insertions! What is wrong here?
{ scopeName = 'source.phpruby.serpent';
fileTypes = ( 'serpent', 'serpent.php', 'serpent.erb' );
patterns = (
{ begin = '<\?(php|=)?';
end = '\?>';
patterns = ( { include = 'source.php'; } );
},
{ begin = '<%';
end = '%>';
patterns = ( { include = 'source.ruby'; } );
},
{ include = 'source.serpent'; },
);
}
I have made it working by replacing source.php with #language in my patterns and by copying the repository from PHP language.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在大神的帮助下,我理解了我的错误,并能够做出一个有效的(至少突出显示!)定义:
With the help of the God, I understood my mistake and was able to make a working (at least highlighting!) definition: