diff --git a/benchmark/profile.js b/benchmark/profile.js index e553aa1..d7a191d 100755 --- a/benchmark/profile.js +++ b/benchmark/profile.js @@ -6,10 +6,14 @@ var fs = require('fs'); var path = require('path'); var Remarkable = require('../'); -var md = new Remarkable('commonmark'); +var md = new Remarkable({ + html: true, + linkify: true, + typographer: true +}); var data = fs.readFileSync(path.join(__dirname, '/samples/lorem1.txt'), 'utf8'); -for (var i = 0; i < 20000; i++) { +for (var i = 0; i < 200; i++) { md.render(data); } diff --git a/lib/rules_block/lheading.js b/lib/rules_block/lheading.js index 42a1ffb..733c828 100644 --- a/lib/rules_block/lheading.js +++ b/lib/rules_block/lheading.js @@ -17,6 +17,8 @@ module.exports = function lheading(state, startLine, endLine, silent) { pos = state.bMarks[next] + state.tShift[next]; max = state.eMarks[next]; + if (pos >= max) { return false; } + marker = state.src.charCodeAt(pos); if (marker !== 0x2D/* - */ && marker !== 0x3D/* = */) { return false; } diff --git a/lib/typographer.js b/lib/typographer.js index db53161..c5525b2 100644 --- a/lib/typographer.js +++ b/lib/typographer.js @@ -20,6 +20,8 @@ rules.push(require('./rules_typographer/smartquotes')); function Typographer() { + this._rules = []; + this.options = assign({}, defaults); this.ruler = new Ruler(this.rulesUpdate.bind(this));