ami*_*min 12 ecmascript-6 atom-editor angular
如何在模板文字中获得HTML语法高亮?
像我之前为崇高所写的这样的东西:
这是sublime版本https://github.com/Microsoft/TypeScript-Sublime-Plugin/pull/189/files
如何为Atom编写相同的东西?
ami*_*min 10
我能够实现这一点,这是ts.cson文件的要点.
在我的系统上使用form atomcript插件:
/Users/amin/.atom/packages/atom-typescript/grammars/ts.cson
https://gist.github.com/aminroosta/509476f48f05f4b56db2c0748fedc8fd
这对于angular2开发非常有用,
这里是atom with html和csshighlight 的截图:
我找不到一个更好的正则表达式来匹配template:和styles:[,如果有人能想出一个更好的正则表达式,我会接受他们的答案.
ts.cson文件中的重要变化是:
"template-html":
name: "meta.template.html.ts"
begin: "`<!---->"
beginCaptures:
"0":
name: "string.quoted.template.ts"
end:"`"
endCaptures:
"0":
name: "string.quoted.template.ts"
patterns: [
{
include: "text.html.basic"
}
]
"template-css":
name: "meta.template.css.ts"
begin: "`/\\*\\*/"
beginCaptures:
"0":
name: "string.quoted.template.ts"
end:"`"
endCaptures:
"0":
name: "string.quoted.template.ts"
patterns: [
{
include: "source.css"
}
]
Run Code Online (Sandbox Code Playgroud)
找到了解决方案:
"template-html":
name: "meta.template.html.ts"
begin: "(?<=template\\:)\\s*`"
beginCaptures:
"0":
name: "string.quoted.template.ts"
end:"`"
endCaptures:
"0":
name: "string.quoted.template.ts"
patterns: [
{
include: "text.html.basic"
}
]
"template-css":
name: "meta.template.css.ts"
begin: "(?<=styles\\:)\\s*(\\[)\\s*(`)"
beginCaptures:
"2":
name: "string.quoted.template.ts"
end:"`"
endCaptures:
"0":
name: "string.quoted.template.ts"
patterns: [
{
include: "source.css"
}
]
Run Code Online (Sandbox Code Playgroud)
这是更新的截图:
| 归档时间: |
|
| 查看次数: |
2648 次 |
| 最近记录: |