diff --git a/benchmark/profile.js b/benchmark/profile.js index d7a191d..a3f6b73 100755 --- a/benchmark/profile.js +++ b/benchmark/profile.js @@ -8,12 +8,13 @@ var Remarkable = require('../'); var md = new Remarkable({ html: true, - linkify: true, - typographer: true + linkify: false, + typographer: false }); -var data = fs.readFileSync(path.join(__dirname, '/samples/lorem1.txt'), 'utf8'); +//var data = fs.readFileSync(path.join(__dirname, '/samples/lorem1.txt'), 'utf8'); +var data = fs.readFileSync(path.join(__dirname, '../test/fixtures/stmd/spec.txt'), 'utf8'); -for (var i = 0; i < 200; i++) { +for (var i = 0; i < 20; i++) { md.render(data); } diff --git a/lib/rules_block/lheading.js b/lib/rules_block/lheading.js index 733c828..fa329c3 100644 --- a/lib/rules_block/lheading.js +++ b/lib/rules_block/lheading.js @@ -12,6 +12,7 @@ module.exports = function lheading(state, startLine, endLine, silent) { if (state.bqMarks[next] < state.bqLevel) { return false; } // Scan next line + if (state.tShift[next] - state.blkIndent > 3) { return false; } pos = state.bMarks[next] + state.tShift[next]; diff --git a/lib/rules_block/table.js b/lib/rules_block/table.js index fc295fe..4a9c675 100644 --- a/lib/rules_block/table.js +++ b/lib/rules_block/table.js @@ -12,18 +12,23 @@ function lineMatch(state, line, reg) { module.exports = function table(state, startLine, endLine, silent) { - var ch, firstLineMatch, secondLineMatch, i, nextLine, m, rows, + var ch, firstLineMatch, secondLineMatch, pos, i, nextLine, m, rows, aligns, t; // should have at least three lines if (startLine + 2 > endLine) { return false; } - if (state.tShift[startLine + 1] < state.blkIndent) { return false; } - if (state.bqMarks[startLine + 1] < state.bqLevel) { return false; } + nextLine = startLine + 1; + + if (state.tShift[nextLine] < state.blkIndent) { return false; } + if (state.bqMarks[nextLine] < state.bqLevel) { return false; } // first character of the second line should be '|' or '-' - ch = state.src.charCodeAt(state.bMarks[startLine + 1] - + state.tShift[startLine + 1]); + + pos = state.bMarks[nextLine] + state.tShift[nextLine]; + if (pos >= state.eMarks[nextLine]) { return false; } + + ch = state.src.charCodeAt(pos); if (ch !== 0x7C/* | */ && ch !== 0x2D/* - */ && ch !== 0x3A/* : */) { return false; } secondLineMatch = lineMatch(state, startLine + 1,