diff --git a/lib/ruler.js b/lib/ruler.js index 147bda5..c9b7d06 100644 --- a/lib/ruler.js +++ b/lib/ruler.js @@ -208,7 +208,8 @@ Ruler.prototype.getRules = function (chainName) { this.__compile__(); } - return this.__cache__[chainName]; + // Chain can be empty, if rules disabled. But we still have to return Array. + return this.__cache__[chainName] || []; }; module.exports = Ruler; diff --git a/test/misc.js b/test/misc.js index 743276e..6f1a4d9 100644 --- a/test/misc.js +++ b/test/misc.js @@ -200,7 +200,7 @@ describe('Misc', function () { assert.strictEqual(md.render('*b*'), 'b'); }); - it('zero preset should disable everything', function () { + it('Zero preset should disable everything', function () { var md = markdownit('zero'); assert.strictEqual(md.render('___foo___'), '

___foo___

\n'); @@ -212,6 +212,12 @@ describe('Misc', function () { assert.strictEqual(md.renderInline('___foo___'), 'foo'); }); + it('Should correctly check block termination rules ahen those are disabled (#13)', function () { + var md = markdownit('zero'); + + assert.strictEqual(md.render('foo\nbar'), '

foo\nbar

\n'); + }); + });