如何通过编程/带有注释将代码突出显示的语法突出显示为特定语言的特定语言? [英] How to set syntax highlighting to a code section to a specific language programmatically/with comments?

查看:113
本文介绍了如何通过编程/带有注释将代码突出显示的语法突出显示为特定语言的特定语言?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Laravel刀片模板(.blade.php),其中包含纯JavaScript作为一部分,稍后将其插入通用包装中.因此,示例为:

I have a Laravel blade template (.blade.php) which contains plain JavaScript as a section that will be later inserted into a generic wrapper. So the example would be:

<div>Some HTML content</div>
@section('js')
var a = "b";
someCall();
@endsection

现在,如果PhpStorm位于<script>标记中(不能),则PhpStorm将能够识别JavaScript.所以我已经尝试过了,我希望它可以像部分荧光笔提示一样工作:

Now PhpStorm would recognize the JavaScript if it was in <script> tag, which it can't be. So I've tried this which I would expect to work like a section highlighter hint:

@section('js')
   // @lang JavaScript
   var a = "b";
   someCall();
   // @endlang
@endsection

还有这个

@section('js')
   // language=JavaScript
   var a = "b";
   someCall();
@endsection

但是没有任何效果(可点击语言注入中断了其他突出显示).

But nothing worked (clickable language injection breaks other highlighting).

我做错了什么?如何以编程方式/注释性地设置要突出显示的部分作为我指定的语言?

What am I doing wrong? How can I programmatically/commentarily set a section to be highlighted as a language I specify?

推荐答案

Blade尚未实现(尽管Smarty和Twig模板已存在).

It's not yet implemented for Blade (although exists for Smarty and Twig templates).

https://youtrack.jetbrains.com/issue/WI-29254 -观看此票(星号/投票/评论)以获取有关任何进度的通知.

https://youtrack.jetbrains.com/issue/WI-29254 -- watch this ticket (star/vote/comment) to get notified on any progress.

这篇关于如何通过编程/带有注释将代码突出显示的语法突出显示为特定语言的特定语言?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆