fixing heredoc indentation from herecomment tweaks
This commit is contained in:
parent
8136c5f3de
commit
f84eb9ed47
|
@ -422,10 +422,11 @@
|
|||
// Sanitize a heredoc or herecomment by escaping internal double quotes and
|
||||
// erasing all external indentation on the left-hand side.
|
||||
Lexer.prototype.sanitize_heredoc = function sanitize_heredoc(doc, options) {
|
||||
var indent, match;
|
||||
var attempt, indent, match;
|
||||
while (match = HEREDOC_INDENT.exec(doc)) {
|
||||
if (!indent || match[1].length < indent.length) {
|
||||
indent = match[1];
|
||||
attempt = match[2] || match[3];
|
||||
if (!indent || attempt.length < indent.length) {
|
||||
indent = attempt;
|
||||
}
|
||||
}
|
||||
doc = doc.replace(new RegExp("^" + indent, 'gm'), '');
|
||||
|
@ -675,7 +676,7 @@
|
|||
STRING_NEWLINES = /\n[ \t]*/g;
|
||||
COMMENT_CLEANER = /(^[ \t]*#|\n[ \t]*$)/mg;
|
||||
NO_NEWLINE = /^([+\*&|\/\-%=<>:!.\\][<>=&|]*|and|or|is|isnt|not|delete|typeof|instanceof)$/;
|
||||
HEREDOC_INDENT = /\n+([ \t]*)/g;
|
||||
HEREDOC_INDENT = /(\n+([ \t]*)|^([ \t]+))/g;
|
||||
// Tokens which a regular expression will never immediately follow, but which
|
||||
// a division operator might.
|
||||
// See: http://www.mozilla.org/js/language/js20-2002-04/rationale/syntax.html#regular-expressions
|
||||
|
|
|
@ -1855,10 +1855,10 @@
|
|||
// Correctly set up a prototype chain for inheritance, including a reference
|
||||
// to the superclass for `super()` calls. See:
|
||||
// [goog.inherits](http://closure-library.googlecode.com/svn/docs/closure_goog_base.js.source.html#line1206).
|
||||
__extends: " function(child, parent) {\n var ctor = function(){ };\n ctor.prototype = parent.prototype;\n child.__superClass__ = parent.prototype;\n child.prototype = new ctor();\n child.prototype.constructor = child;\n}",
|
||||
__extends: "function(child, parent) {\n var ctor = function(){ };\n ctor.prototype = parent.prototype;\n child.__superClass__ = parent.prototype;\n child.prototype = new ctor();\n child.prototype.constructor = child;\n }",
|
||||
// Bind a function to a calling context, optionally including curried arguments.
|
||||
// See [Underscore's implementation](http://jashkenas.github.com/coffee-script/documentation/docs/underscore.html#section-47).
|
||||
__bind: " function(func, obj, args) {\n return function() {\n return func.apply(obj || {}, args ? args.concat(__slice.call(arguments, 0)) : arguments);\n };\n}",
|
||||
__bind: "function(func, obj, args) {\n return function() {\n return func.apply(obj || {}, args ? args.concat(__slice.call(arguments, 0)) : arguments);\n };\n }",
|
||||
// Shortcuts to speed up the lookup time for native functions.
|
||||
__hasProp: 'Object.prototype.hasOwnProperty',
|
||||
__slice: 'Array.prototype.slice'
|
||||
|
|
|
@ -295,7 +295,8 @@ exports.Lexer: class Lexer
|
|||
# erasing all external indentation on the left-hand side.
|
||||
sanitize_heredoc: (doc, options) ->
|
||||
while match: HEREDOC_INDENT.exec doc
|
||||
indent: match[1] if not indent or match[1].length < indent.length
|
||||
attempt: match[2] or match[3]
|
||||
indent: attempt if not indent or attempt.length < indent.length
|
||||
doc: doc.replace(new RegExp("^" +indent, 'gm'), '')
|
||||
return doc if options.herecomment
|
||||
doc.replace(MULTILINER, "\\n")
|
||||
|
@ -503,7 +504,7 @@ MULTILINER : /\n/g
|
|||
STRING_NEWLINES : /\n[ \t]*/g
|
||||
COMMENT_CLEANER : /(^[ \t]*#|\n[ \t]*$)/mg
|
||||
NO_NEWLINE : /^([+\*&|\/\-%=<>:!.\\][<>=&|]*|and|or|is|isnt|not|delete|typeof|instanceof)$/
|
||||
HEREDOC_INDENT : /\n+([ \t]*)/g
|
||||
HEREDOC_INDENT : /(\n+([ \t]*)|^([ \t]+))/g
|
||||
|
||||
# Tokens which a regular expression will never immediately follow, but which
|
||||
# a division operator might.
|
||||
|
|
Loading…
Reference in New Issue