gpt4 book ai didi

HTML 语法高亮 sublime 3 Typescript

转载 作者:搜寻专家 更新时间:2023-10-30 21:02:54 26 4
gpt4 key购买 nike

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

看看它现在没有突出显示:

enter image description here

最佳答案

这是一个快速修复,它仍然使用您安装的 TypeScript 包及其现有的语法高亮定义:

  1. 打开一个 TypeScript 文件(使用您安装的 TypeScript 语法突出显示)

  2. 选择 Tools > Developer > New Syntax from Typescript.tmLanguage 基于现有语法定义文件

  3. 找到 template 上下文(ctrl+f for string.template.ts)和将 'scope:text.html.basic' 添加到 push 中,如下面的 commented 行所示:

    %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:

    # ...

    可选步骤:
    将文件开头的 name 属性更改为类似 TypeScript + HTML 的内容,以便稍后在Syntax 列表中轻松找到并选择它

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

  5. 重启 Sublime Text 并将新的语法高亮应用到 typescript 文件:

    Screenshot of HTML syntax highlighting inside Angular template string within a TypeScript file

关于HTML 语法高亮 sublime 3 Typescript,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38160260/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com