问题描述
我不熟悉 Sublime Text 3 如何使用语法高亮,例如,如果它纯粹依赖于主题,或者它内置了主题运行的标准,但在我的情况下,使用 PHP 的 HERE 存在一些语法高亮差异文档和正斜杠.一旦出现正斜杠,ST3 就会认为以下所有代码都是该标签的一部分.
I am unfamiliar with how Sublime Text 3 uses syntax highlighting, as in, if it purely relies on the theme or has it's built in standard that themes run off of but in my case, there's some syntax highlighting discrepancy with using PHP's HERE docs and forward slashes. Once a forward slash is present, it appears ST3 thinks all the following code is apart of that tag.
这是我可以解决的问题吗?
Is this something I can fix?
正斜杠语法突出显示差异
Forward slash syntax highlighting discrepancy
没有正斜杠和正确的语法高亮
No forward slash and correct syntax highlighting
推荐答案
因为你的 HEREDOC 被称为 JAVASCRIPT
,Sublime Text 试图将内容语法高亮显示为 JavaScript.
Because your HEREDOC is called JAVASCRIPT
, Sublime Text is trying to syntax highlight the contents as JavaScript.
但是因为您包含了 HTML(...</script>
标记),它会错误地突出显示它(它似乎认为它是一个正则表达式,因此不会在正则表达式执行之前(它认为是),不会找到/期望 HEREDOC 结束.
But because you are including HTML (the <script>...</script>
tag), it highlights it incorrectly (it seems to think it is a regular expression and thus doesn't find/expect the HEREDOC to end until (what it thinks is) the regex does.).
解决方法只是更改您的代码,将 HEREDOC 命名为 HTML
:
The fix is simply to change your code to name the HEREDOC as HTML
instead:
<?php
$inlineJS =
<<<HTML
<script>
$('ele').click(function(){
// some code
});
</script>
HTML;
?>
这篇关于PHP 的 HERE Doc (EOT) 语法突出显示了 Sublime Text 3 上正斜杠的差异的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!