From e37056192b10c65e8d077335e220b97b268fab0a Mon Sep 17 00:00:00 2001 From: Jeremy Ashkenas Date: Wed, 2 Jun 2010 19:53:03 -0400 Subject: [PATCH] Fix for issue #414 -- apostrophes in heredocs. --- lib/lexer.js | 2 +- src/lexer.coffee | 2 +- test/test_heredocs.coffee | 4 ++++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/lexer.js b/lib/lexer.js index 14ce7da4..bc6d226d 100644 --- a/lib/lexer.js +++ b/lib/lexer.js @@ -450,7 +450,7 @@ if (options.herecomment) { return doc; } - return doc.replace(MULTILINER, "\\n").replace(new RegExp(options.quote, 'g'), '\\"'); + return doc.replace(MULTILINER, "\\n").replace(new RegExp(options.quote, 'g'), ("\\" + options.quote)); }; // Tag a half assignment. Lexer.prototype.tag_half_assignment = function(tag) { diff --git a/src/lexer.coffee b/src/lexer.coffee index 696425aa..f660bde9 100644 --- a/src/lexer.coffee +++ b/src/lexer.coffee @@ -309,7 +309,7 @@ exports.Lexer: class Lexer doc: doc.replace(new RegExp("^" +indent, 'gm'), '') return doc if options.herecomment doc.replace(MULTILINER, "\\n") - .replace(new RegExp(options.quote, 'g'), '\\"') + .replace(new RegExp(options.quote, 'g'), "\\$options.quote") # Tag a half assignment. tag_half_assignment: (tag) -> diff --git a/test/test_heredocs.coffee b/test/test_heredocs.coffee index 01421d6a..3d412221 100644 --- a/test/test_heredocs.coffee +++ b/test/test_heredocs.coffee @@ -66,3 +66,7 @@ b: ''' ok a is "basic heredoc 10\non two lines" ok b is "basic heredoc \$val\non two lines" + + +a: '''here's an apostrophe''' +ok a is "here's an apostrophe"