mirror of
https://github.com/jashkenas/coffeescript.git
synced 2026-04-11 03:00:13 -04:00
Heredoc indentation detector ignores blank lines without trailing whitespace.
This commit is contained in:
@@ -395,7 +395,7 @@
|
|||||||
if (!(options.herecomment)) {
|
if (!(options.herecomment)) {
|
||||||
while ((match = HEREDOC_INDENT.exec(doc)) !== null) {
|
while ((match = HEREDOC_INDENT.exec(doc)) !== null) {
|
||||||
attempt = (typeof (_ref2 = match[2]) !== "undefined" && _ref2 !== null) ? match[2] : match[3];
|
attempt = (typeof (_ref2 = match[2]) !== "undefined" && _ref2 !== null) ? match[2] : match[3];
|
||||||
if (!(typeof indent !== "undefined" && indent !== null) || attempt.length < indent.length) {
|
if (!(typeof indent !== "undefined" && indent !== null) || (0 < attempt.length) && (attempt.length < indent.length)) {
|
||||||
indent = attempt;
|
indent = attempt;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -323,7 +323,7 @@ exports.Lexer = class Lexer
|
|||||||
unless options.herecomment
|
unless options.herecomment
|
||||||
while (match = HEREDOC_INDENT.exec(doc)) isnt null
|
while (match = HEREDOC_INDENT.exec(doc)) isnt null
|
||||||
attempt = if match[2]? then match[2] else match[3]
|
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= ''
|
indent or= ''
|
||||||
doc = doc.replace(new RegExp("^" + indent, 'gm'), '')
|
doc = doc.replace(new RegExp("^" + indent, 'gm'), '')
|
||||||
return doc if options.herecomment
|
return doc if options.herecomment
|
||||||
|
|||||||
@@ -79,3 +79,12 @@ ok b is "basic heredoc \#{val}\non two lines"
|
|||||||
|
|
||||||
a = '''here's an apostrophe'''
|
a = '''here's an apostrophe'''
|
||||||
ok a is "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"
|
||||||
|
|||||||
Reference in New Issue
Block a user