Browse Source

StateBlock() cleanup

pull/14/head
Vitaly Puzrin 10 years ago
parent
commit
0cf8b0f362
  1. 1
      lib/common/html_re.js
  2. 24
      lib/rules_block/state_block.js

1
lib/common/html_re.js

@ -12,7 +12,6 @@ function replace(regex, options) {
return new RegExp(regex, options);
}
val = val.source || val;
//val = val.replace(/(^|[^\[])\^/g, '$1');
regex = regex.replace(name, val);
return self;
};

24
lib/rules_block/state_block.js

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

Loading…
Cancel
Save