sublime-better-coffeescript
sublime-better-coffeescript copied to clipboard
Recognize embedded CoffeeScript in HTML <script type='text/coffeescript'> tags
alright. i did the following modifications to the HTML.tmLanguage file which is located in a compressed archive C:\ProgramFiles\SublimeText3\Packages\HTML.sublime-package (or similar path):
i replaced:
<string>(?:^\s+)?(<)((?i:script))\b(?![^>]*/>)</string>
...with:
<string>(?:^\s+)?(<)((?i:script))\b(?=[^>]*type *=[^>]*text/javascript)\b(?![^>]*/>)</string>
(so embedding regular javascript works with <script type='text/javascript'> tag)
and added:
<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.begin.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.begin.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>
(so embedding coffeescript works with <script type='text/coffeescript'> tag)
P.S. based on http://www.sublimetext.com/forum/viewtopic.php?f=2&t=5800&p=37751#p37751
Duplicate of #122