diff --git a/lib/index.js b/lib/index.js index 0803058..b531720 100644 --- a/lib/index.js +++ b/lib/index.js @@ -514,6 +514,10 @@ MarkdownIt.prototype.use = function (plugin /*, params, ... */) { * and then pass updated object to renderer. **/ MarkdownIt.prototype.parse = function (src, env) { + if (typeof src !== 'string') { + throw new Error('Input data should be a String'); + } + var state = new this.core.State(src, this, env); this.core.process(state); diff --git a/test/misc.js b/test/misc.js index 0497642..5b20392 100644 --- a/test/misc.js +++ b/test/misc.js @@ -145,6 +145,15 @@ describe('API', function () { assert(md.renderInline('_foo_'), 'foo'); }); + it('input type check', function () { + var md = markdownit(); + + assert.throws( + function () { md.render(null); }, + /Input data should be a String/ + ); + }); + });