简体   繁体   English

如何在Notepad ++中为输出JS的PHP文件设置语法突出显示?

[英]How do I set syntax highlighting in Notepad++ for a PHP file outputting JS?

PHP is most commonly used to echo out HTML, but for this project I'm using PHP to echo out JavaScript. PHP最常用于回显HTML,但是对于此项目,我正在使用PHP回显JavaScript。

How can I set syntax highlighting in Notepad++ to assume that anything outside of PHP tags is JS? 如何在Notepad ++中设置语法突出显示,以假定PHP标记之外的任何内容都是JS?

For example, in: 例如,在:

function(){
    var message='<?php echo 'value'; ?>';
}

I want the surrounding function and various marks to be highlighted like JS, not like HTML. 我希望周围的function和各种标记像JS而不是HTML一样突出显示。

(I know anything inside of echo statements won't be highlighted as JS, so I'm not worried about that. Just JavaScript outside of the PHP tags) (我知道echo语句内的任何内容都不会突出显示为JS,因此我对此并不担心。只是PHP标记之外的JavaScript)

I should probably feel ashamed for this answer, but it's such a quick shortcut I'm kinda proud of it. 我可能会对这个答案感到as愧,但这是我为此感到自豪的快捷捷径。

<?php echo '//'; ?><script>
function(){
    var message='<?php echo 'value'; ?>';
}
<?php echo '//'; ?></script>

I'd still love an actual answer to this question as I've had a hard time figuring it out, but this fools Notepad++ into highlighting the JavaScript correctly and the <script> tags get commented out, so it works on both fronts for me. 我一直很想知道这个问题的实际答案,因为我很难弄清楚它,但是这使Notepad ++正确地突出显示了JavaScript,并且使<script>标记被注释掉了,所以它对我都有效。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM