如何识别内联CoffeeScript <script>
代码的ST3 HTML包(我相信,内置于ST3)?
即。使用时
<script src="../tools/coffee-script.js"></script>
<script type="text/coffeescript">
... CS code ..
</script>
HTML包应该使用CoffeeScript包在脚本块中编辑(由page-load上的coffee-script.js库编译)
任何有关如何让HTML包识别CoffeeScript的解决方案都与JavaScript相同吗?
答案 0 :(得分:0)
您可以创建一个自定义.tmLanguage(或编辑现有的HTML)文件,该文件将“text / coffeescript”定义为具有coffescript范围的范围。
你可以找到一个例子here.
基本上,他们建议您将以下代码添加到HTML.tmLangugage文件中:
<dict>
<key>begin</key>
<string>(?:^\s+)?(<)((?i:script))\b(?=^>]*type *=^>]*text/coffeescript)\b(?!^>]*/>)</string>
<key>beginCaptures</key>
<dict>
<key>1</key>
<dict>
<key>name</key>
<string>punctuation.definition.tag.html</string>
</dict>
<key>2</key>
<dict>
<key>name</key>
<string>entity.name.tag.script.html</string>
</dict>
</dict>
<key>end</key>
<string>(?<=</(script|SCRIPT))(>)(?:\s*\n)?</string>
<key>endCaptures</key>
<dict>
<key>2</key>
<dict>
<key>name</key>
<string>punctuation.definition.tag.html</string>
</dict>
</dict>
<key>name</key>
<string>source.coffee.embedded.html</string>
<key>patterns</key>
<array>
<dict>
<key>include</key>
<string>#tag-stuff</string>
</dict>
<dict>
<key>begin</key>
<string>(?<!</(?:script|SCRIPT))(>)</string>
<key>captures</key>
<dict>
<key>1</key>
<dict>
<key>name</key>
<string>punctuation.definition.tag.html</string>
</dict>
<key>2</key>
<dict>
<key>name</key>
<string>entity.name.tag.script.html</string>
</dict>
</dict>
<key>end</key>
<string>(</)((?i:script))</string>
<key>patterns</key>
<array>
<dict>
<key>include</key>
<string>source.coffee</string>
</dict>
</array>
</dict>
</array>
</dict>
那应该没问题。