HTML语法高亮显示Sublime 3打字稿

El *_*lab 3 html syntax-highlighting typescript sublimetext3

我在Sublime 3中使用TypeScript。如何在模板属性中添加HTML高亮显示:[注意:我已经在使用Microsoft TypeScript Package]

看一下现在没有突出显示的内容:

在此处输入图片说明

fsp*_*irn 6

这是一个快速修复程序,仍然使用已安装的TypeScript软件包及其现有的语法突出显示定义:

  1. 打开TypeScript文件(突出显示已安装的TypeScript语法)

  2. 从Typescript.tmLanguage中选择“ 工具”>“开发人员”>“新语法”,基于现有的语法定义文件创建一个新的语法定义文件

  3. 找到template上下文(ctrl+ f表示string.template.ts)并在以下内容的注释行中指出,将include添加'scope:text.html.basic' 到:push

    %YAML 1.2
    ---
    # http://www.sublimetext.com/docs/3/syntax.html
    name: TypeScript + HTML  # <-- renaming is optional
    
      # ...
    
      template:
        - match: "([_$[:alpha:]][_$[:alnum:]]*)?(`)"
          captures:
            1: entity.name.function.tagged-template.ts
            2: punctuation.definition.string.template.begin.ts
          push:
            - meta_scope: string.template.ts
            - match: "`"
              captures:
                0: punctuation.definition.string.template.end.ts
              pop: true
            - include: template-substitution-element
            - include: string-character-escape
            - include: 'scope:text.html.basic'  # <-- !! only add this line !!
      template-substitution-element:
    
      # ...
    
    Run Code Online (Sandbox Code Playgroud)

    可选步骤:将文件开头
    name属性更改TypeScript + HTML为易于在以后的“ 语法”列表中找到并选择的属性

  4. .sublime-syntax文件结尾保存文件

  5. 重新启动Sublime Text并将新的语法突出显示应用于打字稿文件:

    TypeScript文件中Angular模板字符串内的HTML语法突出显示的屏幕截图