diff --git a/lib/less/parser.js b/lib/less/parser.js index 869ff8f5..2a742741 100644 --- a/lib/less/parser.js +++ b/lib/less/parser.js @@ -188,21 +188,21 @@ less.Parser = function Parser(env) { i = j = current = furthest = 0; chunks = []; input = str.replace(/\r\n/g, '\n'); - inputLength = input.length; // Split the input into chunks, - // Either delimited by /\n\n/ or - // delmited by '\n}' (see rationale above), + // delimited by /\n\n/ and + // removing comments (see rationale above), // depending on the level of optimization. if (that.optimization > 0) { input = input.replace(/\/\*(?:[^*]|\*+[^\/*])*\*+\//g, function (comment) { - return that.optimization > 1 ? '' : comment.replace(/\n\n+/g, '\n'); + return that.optimization > 1 ? '' : comment.replace(/\n(\s*\n)+/g, '\n'); }); - chunks = input.split(/^(?=\n)/mg); + chunks = input.split(/^(?=(\s*\n)+)/mg); } else { chunks = [input]; } + inputLength = input.length; // Start with the primary rule. // The whole syntax tree is held under a Ruleset node,