Permalink
Browse files

Heredoc indentation detector ignores blank lines without trailing whi…

…tespace.
  • Loading branch information...
sstephenson committed Sep 22, 2010
1 parent c435647 commit 01c14bc6402198b09f1a7f23f67e4ff05e8c562c
Showing with 11 additions and 2 deletions.
  1. +1 −1 lib/lexer.js
  2. +1 −1 src/lexer.coffee
  3. +9 −0 test/test_heredocs.coffee
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
View
@@ -323,7 +323,7 @@ exports.Lexer = class Lexer
unless options.herecomment
while (match = HEREDOC_INDENT.exec(doc)) isnt null
attempt = if match[2]? then match[2] else match[3]
- indent = attempt if not indent? or attempt.length < indent.length
+ indent = attempt if not indent? or 0 < attempt.length < indent.length
indent or= ''
doc = doc.replace(new RegExp("^" + indent, 'gm'), '')
return doc if options.herecomment
@@ -79,3 +79,12 @@ ok b is "basic heredoc \#{val}\non two lines"
a = '''here's an apostrophe'''
ok a is "here's an apostrophe"
+
+
+# The indentation detector ignores blank lines without trailing whitespace
+a = """
+ one
+ two
+
+ """
+ok a is "one\ntwo\n"

0 comments on commit 01c14bc

Please sign in to comment.