Skip to content

Commit

Permalink
Use the javascript regular expressions grammar
Browse files Browse the repository at this point in the history
This matches the individual components of the regular expression and prevents escaping issues.

Fixes jashkenas#26 & jashkenas#105.
  • Loading branch information
infininight committed Mar 20, 2013
1 parent e8d02ce commit 2caf1de
Show file tree
Hide file tree
Showing 2 changed files with 126 additions and 18 deletions.
72 changes: 63 additions & 9 deletions Syntaxes/CoffeeScript (Literate).tmLanguage
Expand Up @@ -22,6 +22,23 @@
|^\s*-->
|(^|\s)\}
)</string>
<key>injections</key>
<dict>
<key>string.regexp.block.coffee</key>
<dict>
<key>patterns</key>
<array>
<dict>
<key>include</key>
<string>#interpolated_coffee</string>
</dict>
<dict>
<key>include</key>
<string>#embedded_comment</string>
</dict>
</array>
</dict>
</dict>
<key>name</key>
<string>CoffeeScript (Literate)</string>
<key>patterns</key>
Expand Down Expand Up @@ -798,27 +815,64 @@
<dict>
<key>begin</key>
<string>/{3}</string>
<key>beginCaptures</key>
<dict>
<key>0</key>
<dict>
<key>name</key>
<string>punctuation.definition.string.begin.coffee</string>
</dict>
</dict>
<key>end</key>
<string>/{3}[imgy]{0,4}</string>
<string>(/{3})[imgy]{0,4}</string>
<key>endCaptures</key>
<dict>
<key>1</key>
<dict>
<key>name</key>
<string>punctuation.definition.string.end.coffee</string>
</dict>
</dict>
<key>name</key>
<string>string.regexp.coffee</string>
<string>string.regexp.block.coffee</string>
<key>patterns</key>
<array>
<dict>
<key>include</key>
<string>#interpolated_coffee</string>
</dict>
<dict>
<key>include</key>
<string>#embedded_comment</string>
<string>source.js.regexp</string>
</dict>
</array>
</dict>
<dict>
<key>match</key>
<string>/(?![\s=/*+{}?]).*?[^\\]/[igmy]{0,4}(?![a-zA-Z0-9])</string>
<key>begin</key>
<string>/(?![\s=/*+{}?])</string>
<key>beginCaptures</key>
<dict>
<key>0</key>
<dict>
<key>name</key>
<string>punctuation.definition.string.begin.coffee</string>
</dict>
</dict>
<key>end</key>
<string>(/)[igmy]*(?![a-zA-Z0-9])</string>
<key>endCaptures</key>
<dict>
<key>1</key>
<dict>
<key>name</key>
<string>punctuation.definition.string.end.coffee</string>
</dict>
</dict>
<key>name</key>
<string>string.regexp.coffee</string>
<key>patterns</key>
<array>
<dict>
<key>include</key>
<string>source.js.regexp</string>
</dict>
</array>
</dict>
<dict>
<key>match</key>
Expand Down
72 changes: 63 additions & 9 deletions Syntaxes/CoffeeScript.tmLanguage
Expand Up @@ -16,6 +16,23 @@
<string>^\s*class\s+\S.*$|.*(-&gt;|=&gt;)\s*$|.*[\[{]\s*$</string>
<key>foldingStopMarker</key>
<string>^\s*$|^\s*[}\]]\s*$</string>
<key>injections</key>
<dict>
<key>string.regexp.block.coffee</key>
<dict>
<key>patterns</key>
<array>
<dict>
<key>include</key>
<string>#interpolated_coffee</string>
</dict>
<dict>
<key>include</key>
<string>#embedded_comment</string>
</dict>
</array>
</dict>
</dict>
<key>keyEquivalent</key>
<string>^~C</string>
<key>name</key>
Expand Down Expand Up @@ -268,27 +285,64 @@
<dict>
<key>begin</key>
<string>/{3}</string>
<key>beginCaptures</key>
<dict>
<key>0</key>
<dict>
<key>name</key>
<string>punctuation.definition.string.begin.coffee</string>
</dict>
</dict>
<key>end</key>
<string>/{3}[imgy]{0,4}</string>
<string>(/{3})[imgy]{0,4}</string>
<key>endCaptures</key>
<dict>
<key>1</key>
<dict>
<key>name</key>
<string>punctuation.definition.string.end.coffee</string>
</dict>
</dict>
<key>name</key>
<string>string.regexp.coffee</string>
<string>string.regexp.block.coffee</string>
<key>patterns</key>
<array>
<dict>
<key>include</key>
<string>#interpolated_coffee</string>
</dict>
<dict>
<key>include</key>
<string>#embedded_comment</string>
<string>source.js.regexp</string>
</dict>
</array>
</dict>
<dict>
<key>match</key>
<string>/(?![\s=/*+{}?]).*?[^\\]/[igmy]{0,4}(?![a-zA-Z0-9])</string>
<key>begin</key>
<string>/(?![\s=/*+{}?])</string>
<key>beginCaptures</key>
<dict>
<key>0</key>
<dict>
<key>name</key>
<string>punctuation.definition.string.begin.coffee</string>
</dict>
</dict>
<key>end</key>
<string>(/)[igmy]{0,4}(?![a-zA-Z0-9])</string>
<key>endCaptures</key>
<dict>
<key>1</key>
<dict>
<key>name</key>
<string>punctuation.definition.string.end.coffee</string>
</dict>
</dict>
<key>name</key>
<string>string.regexp.coffee</string>
<key>patterns</key>
<array>
<dict>
<key>include</key>
<string>source.js.regexp</string>
</dict>
</array>
</dict>
<dict>
<key>match</key>
Expand Down

1 comment on commit 2caf1de

@steveluscher
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This or something near it might have broken syntax highlighting when using the division operator /.

See jashkenas#127.

Please sign in to comment.