Fixed incorrect inputLength. Avoid creating multiple empty chucks for consecutive blank lines.

This commit is contained in:
James Foster
2010-06-02 12:03:27 +08:00
committed by Alexis Sellier
parent 0b30fe48c9
commit 05165ce90d

View File

@@ -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,