2014-02-12 58 views
3

如何獲得ST3 HTML包(內置於ST3中,我相信)可以識別內聯CoffeeScript <script>標籤?帶內聯咖啡文本的崇高文本html文件

I.e.使用

<script src="../tools/coffee-script.js"></script> 
    <script type="text/coffeescript"> 
     ... CS code .. 
    </script> 

當HTML包裝應使用CoffeeScript的包腳本塊中編輯(這是由咖啡的script.js庫編譯的頁面加載)

如何有任何解決方案HTML包以與JavaScript相同的方式識別CoffeeScript?

回答

0

您可以創建自定義的.tmLanguage文件(或編輯現有的HTML文件),該文件將定義'text/coffeescript'爲具有coffescript範圍的範圍。

你可以找到一個例子here.

基本上,他們認爲那是什麼,你會在下面的代碼添加到您的HTML.tmLangugage文件:

<dict> 
    <key>begin</key> 
    <string>(?:^\s+)?(&lt;)((?i:script))\b(?=^&gt;]*type *=^&gt;]*text/coffeescript)\b(?!^&gt;]*/&gt;)</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>(?&lt;=&lt;/(script|SCRIPT))(&gt;)(?:\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>(?&lt;!&lt;/(?:script|SCRIPT))(&gt;)</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>(&lt;/)((?i:script))</string> 
      <key>patterns</key> 
      <array> 
       <dict> 
        <key>include</key> 
        <string>source.coffee</string> 
       </dict> 
      </array> 
     </dict> 
    </array> 
</dict> 

這應該工作正常的。