HTML 语法高亮 sublime 3 Typescript
HTML syntax highlight sublime 3 Typescript
我在 Sublime 3 中使用 TypeScript。如何在模板属性中添加 HTML 突出显示:[注意:我已经在使用 Microsoft TypeScript 包]
看看它现在没有突出显示:
您可以在此处阅读如何实现此目的:
https://forum.sublimetext.com/t/javascript-es6-template-literals-syntax-for-html/18242
转载于此:
打开工具 > 开发人员 > 新语法
添加:
%YAML1.2
---
# See http://www.sublimetext.com/docs/3/syntax.html
name: JavaScript NG
file_extensions:
- js
- ng.js
scope: source.js.ng
contexts:
main:
- match: ""
push: scope:source.js
with_prototype:
- match: '`'
push:
- meta_content_scope: text.html.basic.embedded.js
- include: 'scope:text.html.basic'
- match: '`'
pop: true
并保存它有 JavaScript-NG.sublime-语法
关于此还有一个未解决的 github 问题:
这里有一个快速修复,它仍然使用您安装的 TypeScript
包及其现有的语法高亮定义:
打开一个 TypeScript 文件(使用您安装的 TypeScript 语法突出显示)
Select Tools > Developer > New Syntax from Typescript.tmLanguage 创建新的语法定义文件 based在现有的
找到 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 列表中轻松找到并 select后来
以 .sublime-syntax
文件结尾保存文件
重启 Sublime Text 并将新的语法高亮应用到 typescript 文件:
我在 Sublime 3 中使用 TypeScript。如何在模板属性中添加 HTML 突出显示:[注意:我已经在使用 Microsoft TypeScript 包]
看看它现在没有突出显示:
您可以在此处阅读如何实现此目的:
https://forum.sublimetext.com/t/javascript-es6-template-literals-syntax-for-html/18242
转载于此:
打开工具 > 开发人员 > 新语法
添加:
%YAML1.2
---
# See http://www.sublimetext.com/docs/3/syntax.html
name: JavaScript NG
file_extensions:
- js
- ng.js
scope: source.js.ng
contexts:
main:
- match: ""
push: scope:source.js
with_prototype:
- match: '`'
push:
- meta_content_scope: text.html.basic.embedded.js
- include: 'scope:text.html.basic'
- match: '`'
pop: true
并保存它有 JavaScript-NG.sublime-语法
关于此还有一个未解决的 github 问题:
这里有一个快速修复,它仍然使用您安装的 TypeScript
包及其现有的语法高亮定义:
打开一个 TypeScript 文件(使用您安装的 TypeScript 语法突出显示)
Select Tools > Developer > New Syntax from Typescript.tmLanguage 创建新的语法定义文件 based在现有的
找到
template
上下文 (ctrl+f forstring.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 列表中轻松找到并 select后来以
.sublime-syntax
文件结尾保存文件重启 Sublime Text 并将新的语法高亮应用到 typescript 文件: