mirror of
https://github.com/jashkenas/coffeescript.git
synced 2026-04-11 03:00:13 -04:00
fixing heredocs with multiple double quotes (broken regex from the Ruby translation), with tests.
This commit is contained in:
@@ -172,7 +172,7 @@
|
|||||||
}
|
}
|
||||||
doc = match[2] || match[4];
|
doc = match[2] || match[4];
|
||||||
indent = (doc.match(HEREDOC_INDENT) || ['']).sort()[0];
|
indent = (doc.match(HEREDOC_INDENT) || ['']).sort()[0];
|
||||||
doc = doc.replace(new RegExp("^" + indent, 'gm'), '').replace(MULTILINER, "\\n").replace('"', '\\"');
|
doc = doc.replace(new RegExp("^" + indent, 'gm'), '').replace(MULTILINER, "\\n").replace(/"/g, '\\"');
|
||||||
this.token('STRING', '"' + doc + '"');
|
this.token('STRING', '"' + doc + '"');
|
||||||
this.line += this.count(match[1], "\n");
|
this.line += this.count(match[1], "\n");
|
||||||
this.i += match[1].length;
|
this.i += match[1].length;
|
||||||
|
|||||||
@@ -159,7 +159,7 @@ exports.Lexer: class Lexer
|
|||||||
indent: (doc.match(HEREDOC_INDENT) or ['']).sort()[0]
|
indent: (doc.match(HEREDOC_INDENT) or ['']).sort()[0]
|
||||||
doc: doc.replace(new RegExp("^" + indent, 'gm'), '')
|
doc: doc.replace(new RegExp("^" + indent, 'gm'), '')
|
||||||
.replace(MULTILINER, "\\n")
|
.replace(MULTILINER, "\\n")
|
||||||
.replace('"', '\\"')
|
.replace(/"/g, '\\"')
|
||||||
@token 'STRING', '"' + doc + '"'
|
@token 'STRING', '"' + doc + '"'
|
||||||
@line += @count match[1], "\n"
|
@line += @count match[1], "\n"
|
||||||
@i += match[1].length
|
@i += match[1].length
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ a: '''
|
|||||||
|
|
||||||
ok a is " a\n b\nc"
|
ok a is " a\n b\nc"
|
||||||
|
|
||||||
|
|
||||||
a: '''
|
a: '''
|
||||||
a
|
a
|
||||||
|
|
||||||
@@ -44,3 +45,8 @@ b c
|
|||||||
'''
|
'''
|
||||||
|
|
||||||
ok a is "a\n\n\nb c"
|
ok a is "a\n\n\nb c"
|
||||||
|
|
||||||
|
|
||||||
|
a: '''more"than"one"quote'''
|
||||||
|
|
||||||
|
ok a is 'more"than"one"quote'
|
||||||
Reference in New Issue
Block a user