GitbookIO/kramed

Outdated highlight example in README

Opened this issue · 0 comments

The README says that this should be possible:

// Synchronous highlighting with highlight.js
kramed.setOptions({
  highlight: function (code) {
    return require('highlight.js').highlightAuto(code).value;
  }
});

console.log(kramed(markdownString));

but it's not (anymore).

As far as I can tell, the default Renderer instance doesn't get the updated options passed in any way. I'm currently using

var options = {
  renderer: new kramed.Renderer({
    highlight: code => hljs.highlightAuto(code).value,
  }),
};

console.log(kramed(markdownString, options));

Not sure whether the README version is still supposed to work or not, but it seems that I have to explicitly create a Renderer instance if I want to pass options to it (seems inconvenient), and pass it to kramed instead of calling setOptions.