'use strict';

module.exports = function (data, options) {
  var MdIt = require('markdown-it');
  var cfg = this.config.markdown;
  var opt = (cfg) ? cfg : 'default';
  var parser = (opt === 'default' || opt === 'commonmark' || opt === 'zero') ?
    new MdIt(opt) :
    new MdIt(opt.render);

  if (opt.plugins) {
    parser = opt.plugins.reduce(function (parser, pugs) {
      return parser.use(require(pugs));
    }, parser);
  }

  if (opt.anchors) {
    parser = parser.use(require('./anchors'), opt.anchors);
  }

  return parser.render(data.text);
};

@@ -361,24 +361,151 @@
 er, pugs) %7B%0A
+      if (pugs instanceof Object && pugs.name) %7B%0A        return parser.use(require(pugs.name), pugs.options);%0A      %7D else %7B%0A  
       return
@@ -532,16 +532,24 @@
 pugs));%0A
+      %7D%0A
     %7D, p

support passing options to markdown-it plugins