diff --git a/lib/lexer.js b/lib/lexer.js index ad375971..59536db8 100644 --- a/lib/lexer.js +++ b/lib/lexer.js @@ -172,7 +172,7 @@ } doc = match[2] || match[4]; 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.line += this.count(match[1], "\n"); this.i += match[1].length; diff --git a/src/lexer.coffee b/src/lexer.coffee index 7d790605..e824d6ea 100644 --- a/src/lexer.coffee +++ b/src/lexer.coffee @@ -159,7 +159,7 @@ exports.Lexer: class Lexer indent: (doc.match(HEREDOC_INDENT) or ['']).sort()[0] doc: doc.replace(new RegExp("^" + indent, 'gm'), '') .replace(MULTILINER, "\\n") - .replace('"', '\\"') + .replace(/"/g, '\\"') @token 'STRING', '"' + doc + '"' @line += @count match[1], "\n" @i += match[1].length diff --git a/test/test_heredocs.coffee b/test/test_heredocs.coffee index d9f8e8f0..b9cd2e2c 100644 --- a/test/test_heredocs.coffee +++ b/test/test_heredocs.coffee @@ -36,6 +36,7 @@ a: ''' ok a is " a\n b\nc" + a: ''' a @@ -44,3 +45,8 @@ b c ''' ok a is "a\n\n\nb c" + + +a: '''more"than"one"quote''' + +ok a is 'more"than"one"quote' \ No newline at end of file