|
|
@ -6,11 +6,6 @@ |
|
|
|
function StateBlock(src, parser, tokens, options, env) { |
|
|
|
var ch, s, start, pos, len, indent, indent_found; |
|
|
|
|
|
|
|
// Prepare string to parse:
|
|
|
|
//
|
|
|
|
// - replace tabs with spaces
|
|
|
|
// - remove `\r` to simplify newlines check (???)
|
|
|
|
|
|
|
|
this.src = src; |
|
|
|
|
|
|
|
// Shortcuts to simplify nested calls
|
|
|
@ -57,24 +52,20 @@ function StateBlock(src, parser, tokens, options, env) { |
|
|
|
indent++; |
|
|
|
continue; |
|
|
|
} else { |
|
|
|
this.tShift.push(indent); |
|
|
|
indent_found = true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (ch === 0x0A) { |
|
|
|
if (ch === 0x0A || pos === len - 1) { |
|
|
|
this.bMarks.push(start); |
|
|
|
this.eMarks.push(pos); |
|
|
|
this.tShift.push(indent); |
|
|
|
|
|
|
|
indent_found = false; |
|
|
|
indent = 0; |
|
|
|
start = pos + 1; |
|
|
|
} |
|
|
|
} |
|
|
|
if (ch !== 0x0A) { |
|
|
|
this.bMarks.push(start); |
|
|
|
this.eMarks.push(len); |
|
|
|
if (!indent_found) { this.tShift.push(indent); } |
|
|
|
} |
|
|
|
|
|
|
|
// Push fake entry to simplify cache bounds checks
|
|
|
|
this.bMarks.push(s.length); |
|
|
@ -161,14 +152,5 @@ StateBlock.prototype.getLines = function getLines(begin, end, indent, keepLastLF |
|
|
|
return queue.join(''); |
|
|
|
}; |
|
|
|
|
|
|
|
// Create shadow clone of curent state with new input data
|
|
|
|
StateBlock.prototype.clone = function clone(src) { |
|
|
|
return new StateBlock( |
|
|
|
src, |
|
|
|
this.parser, |
|
|
|
this.tokens, |
|
|
|
this.options |
|
|
|
); |
|
|
|
}; |
|
|
|
|
|
|
|
module.exports = StateBlock; |
|
|
|