• 请不要在回答技术问题时复制粘贴 AI 生成的内容
sunjourney
V2EX  ›  程序员

sublime 中如何给 <script type="text/template"> <script type="text/babel"> 加语法高亮?

  •  
  •   sunjourney · Sep 19, 2016 · 4751 views
    This topic created in 3555 days ago, the information mentioned may be changed or developed.

    如题, sublime 中如何给 <script type="text/template"> <script type="text/babel"> 加语法高亮?

    11 replies    2016-09-19 19:24:45 +08:00
    Dirlllee
        1
    Dirlllee  
       Sep 19, 2016 via iPhone
    可能是设置里面的事吧,或者主题
    sunjourney
        2
    sunjourney  
    OP
       Sep 19, 2016
    @Dirlllee 具体的设置方法找不到,搜索找到的修改 HTML.tmLanguage 貌似是 ST2 时代的方法
    jfcherng
        3
    jfcherng  
       Sep 19, 2016
    @sunjourney 那就去 HTML.sublime-syntax 改囉
    shoaly
        4
    shoaly  
       Sep 19, 2016
    这个还好, 关键是我的 sublime 如何认识 laravel 的 blade 语法
    @if 和 @endif 这种....
    sunjourney
        5
    sunjourney  
    OP
       Sep 19, 2016
    @jfcherng 在正则里把 text/javascript 扩展下增加 template 和 babel 只能对其应用 javascript 的语法,不能应用出 underscore, babel 的语法, HTML.sublime-syntax match 后的 push 不知道要做什么样的修改
    P233
        6
    P233  
       Sep 19, 2016
    @shoaly 在 PHP 的 .tmLanguage 或者 .tmLanguage 里修改,基本的正则判断,然后定义一个 scope name 。另外如果所用的 color scheme 没有配置这个 scope name ,还得继续改 color scheme 文件。
    P233
        7
    P233  
       Sep 19, 2016   ❤️ 1
    如果是给 <script type="text/template"> <script type="text/babel"> 内部的代码块高亮,参考 https://www.sublimetext.com/docs/3/syntax.html#include-syntax
    sunjourney
        8
    sunjourney  
    OP
       Sep 19, 2016
    @P233 感谢!
    jfcherng
        9
    jfcherng  
       Sep 19, 2016
    @sunjourney 關鍵你得有 "underscore, babel 的语法包", 官方沒有

    假設我想再 text/babel 裡用 python 高亮: https://gist.github.com/jfcherng/f2b1e3c866e83929c48e6d4f502332a9
    效果圖:
    sunjourney
        10
    sunjourney  
    OP
       Sep 19, 2016
    @jfcherng 安装了 babel 插件,它用的 syntax 是 source.js ,这样似乎只需要第 9 行的就行了
    jfcherng
        11
    jfcherng  
       Sep 19, 2016
    可以的,解決問題又不需要自己維護那是最好。這其實可以發個 PR 到官方的 repo...
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1375 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 35ms · UTC 16:50 · PVG 00:50 · LAX 09:50 · JFK 12:50
    ♥ Do have faith in what you're doing.