chunkify with a zero-width regexp
This commit is contained in:
parent
e339649158
commit
01ae902eff
@ -120,15 +120,15 @@ less.parser = {
|
||||
//
|
||||
parse: function (str) {
|
||||
var tree;
|
||||
input = str;
|
||||
|
||||
inputLength = input.length;
|
||||
chunks = input.split(/\n\n/g);
|
||||
|
||||
for (var k = 0; k < chunks.length; k++) {
|
||||
if (k < chunks.length - 1) { chunks[k] += '\n' }
|
||||
if (k) { chunks[k] = '\n' + chunks[k] }
|
||||
}
|
||||
input = str;
|
||||
inputLength = input.length;
|
||||
|
||||
// Split the input into chunks,
|
||||
// delmited by /\n\n/ (see rationale above)
|
||||
// We use a lookahead, because we want to
|
||||
// preserve the '\n's in the input.
|
||||
chunks = input.split(/^(?=\n)/mg);
|
||||
|
||||
// Start with the primary rule
|
||||
tree = new(node.Ruleset)([], $(this.parsers.primary, []));
|
||||
|
Loading…
Reference in New Issue
Block a user