I'm not exactly sure what's going on here, but it has been bugging me for a while. The marked
node markdown parser works like this:
var marked = require('marked');
marked.setOptions({ mathjax : false });
That all works. But I'm building a plugin system where I want to pass the marked module function into a function from another file and set the options in that function:
// main.js
var marked = require('marked');
var plugin = require('./plugin');
plugin(marked);
marked("# my markdown\n $$5 + 5$$", function(err, result) {
// this result still parses mathjax. Setting the option in the main
// file will disable mathjax.
console.log(result);
});
// plugin.js
module.exports = function(marked) {
marked.setOptions({ mathjax: false });
}
The marked
function is passed correctly to my plugin function, and the setOptions
function is called, but when I use marked
afterwards in my main script, the options are not set. If I set the options in the main script, it's working.
I'm a bit unsure of whether marked
being a Function
and its implementation of setOptions()
might be the culprit of this?
Any thoughts?