summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGaurav Jain <gaurav@gauravjain.org>2014-05-12 11:48:34 -0400
committerGaurav Jain <gaurav@gauravjain.org>2014-05-12 11:48:34 -0400
commitc6f9868a4aef43beec4f80c582dad9c69c34c231 (patch)
tree450d146bca3764544e9123087b527d09b7f8266f
parentcb9e18ea291f4d27501dc7d5a64d6046ac773fb7 (diff)
downloadpygments-c6f9868a4aef43beec4f80c582dad9c69c34c231.tar.gz
Copy regex from LiveScript to CoffeeScript to handle mid string interpolations
-rw-r--r--pygments/lexers/web.py8
-rw-r--r--tests/examplefiles/example.coffee2
2 files changed, 7 insertions, 3 deletions
diff --git a/pygments/lexers/web.py b/pygments/lexers/web.py
index 35793200..65d07a1c 100644
--- a/pygments/lexers/web.py
+++ b/pygments/lexers/web.py
@@ -2488,7 +2488,7 @@ class CoffeeScriptLexer(RegexLexer):
("'", String, 'sqs'),
],
'strings': [
- (r'[^\\\'"]+', String),
+ (r'[^#\\\'"]+', String),
# note that all coffee script strings are multi-line.
# hashmarks, quotes and backslashes must be parsed one at a time
],
@@ -2500,22 +2500,24 @@ class CoffeeScriptLexer(RegexLexer):
(r'"', String, '#pop'),
(r'\\.|\'', String), # double-quoted string don't need ' escapes
(r'#{', String.Interpol, "interpoling_string"),
+ (r'#', String),
include('strings')
],
'sqs': [
(r"'", String, '#pop'),
- (r'\\.|"', String), # single quoted strings don't need " escapses
+ (r'#|\\.|"', String), # single quoted strings don't need " escapses
include('strings')
],
'tdqs': [
(r'"""', String, '#pop'),
(r'\\.|\'|"', String), # no need to escape quotes in triple-string
(r'#{', String.Interpol, "interpoling_string"),
+ (r'#', String),
include('strings'),
],
'tsqs': [
(r"'''", String, '#pop'),
- (r'\\.|\'|"', String), # no need to escape quotes in triple-strings
+ (r'#|\\.|\'|"', String), # no need to escape quotes in triple-strings
include('strings')
],
}
diff --git a/tests/examplefiles/example.coffee b/tests/examplefiles/example.coffee
index 3d062332..2cbd1df3 100644
--- a/tests/examplefiles/example.coffee
+++ b/tests/examplefiles/example.coffee
@@ -15,11 +15,13 @@ methodF:(c,d)-> 'F'
# strings
"#{wow}"
+"w#{wow}w"
"#wow"
"wow#"
"w#ow"
'#{wow}'
+'w#{wow}w'
'#wow'
'wow#'
'w#ow'