FIX: v8 issue with regexp

This commit is contained in:
Robin Ward 2015-01-20 17:29:59 -05:00
parent 649dfd8d23
commit 7cc96bdac5

View file

@ -825,7 +825,6 @@
// TODO: Cache this regexp for certain depths. // TODO: Cache this regexp for certain depths.
// Create a regexp suitable for matching an li for a given stack depth // Create a regexp suitable for matching an li for a given stack depth
function regex_for_depth( depth ) { function regex_for_depth( depth ) {
return new RegExp( return new RegExp(
// m[1] = indent, m[2] = list_type // m[1] = indent, m[2] = list_type
"(?:^(" + indent_re + "{0," + depth + "} {0,3})(" + any_list + ")\\s+)|" + "(?:^(" + indent_re + "{0," + depth + "} {0,3})(" + any_list + ")\\s+)|" +
@ -871,8 +870,11 @@
replace = new RegExp("^" + indent_re + "{" + depth + "}", "gm"), replace = new RegExp("^" + indent_re + "{" + depth + "}", "gm"),
ret = []; ret = [];
while ( blocks.length > 0 ) { while ( blocks.length > 0 ) {
if ( re.exec( blocks[0] ) ) { // HACK: Fixes a v8 issue
test = blocks[0].replace(/^ {8,}/, ' ');
if ( re.exec( test ) ) {
var b = blocks.shift(), var b = blocks.shift(),
// Now remove that indent // Now remove that indent
x = b.replace( replace, ""); x = b.replace( replace, "");