Commits

Russell McClellan committed 260e947

coffee-script fix: fix for host of issues with string interpolation and triple-quotes. See https://gist.github.com/1215861 for file with pathological behavior before.

  • Participants
  • Parent commits 7799e33

Comments (0)

Files changed (1)

File pygments/lexers/web.py

             ("'", String, 'sqs'),
         ],
         'strings': [
-            (r'[^\\\'"]+', String), # note that all coffee script strings are multi-line.
-            (r'[\'"\\]', String),   # quotes and backslashes must be parsed one at a time
+            (r'[^#\\\'"]+', String)  # note that all coffee script strings are multi-line.
+                                     # hashmarks, quotes and backslashes must be parsed one at a time
+        ],
+        'interpoling_string' : [
+            (r'}', String.Interpol, "#pop"),
+            include('root')
         ],
         'dqs': [
             (r'"', String, '#pop'),
-            (r'\\\\|\\"', String), # double-quoted string has " escapes
+            (r'\\.|\'', String), # double-quoted string don't need ' escapes
+            (r'#{', String.Interpol, "interpoling_string"),
             include('strings')
         ],
         'sqs': [
             (r"'", String, '#pop'),
-            (r"\\\\|\\'", String), # single quoted string has ' escapses
+            (r'#|\\.|"', String), # single quoted strings don't need " escapses
             include('strings')
         ],
         'tdqs': [
             (r'"""', String, '#pop'),
-            include('strings')
+            (r'\\.|\'|"', String), # no need to escape quotes in triple-string
+            (r'#{', String.Interpol, "interpoling_string"),
+            include('strings'),
         ],
         'tsqs': [
             (r"'''", String, '#pop'),
+            (r'#|\\.|\'|"', String), # no need to escape quotes in triple-strings
             include('strings')
         ],
     }