Skip to content

Commit

Permalink
Improve example for invoking highlight.js
Browse files Browse the repository at this point in the history
  • Loading branch information
octogonz committed Feb 13, 2020
1 parent 3ab4bf5 commit 2b9aa11
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions docs/USING_ADVANCED.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ const marked = require('marked');
// `highlight` example uses `highlight.js`
marked.setOptions({
renderer: new marked.Renderer(),
highlight: function(code) {
return require('highlight.js').highlightAuto(code).value;
highlight: function(code, language) {
const validLanguage = hljs.getLanguage(language) ? language : 'plaintext';
return require('highlight.js').highlight(validLanguage, code).value;
},
pedantic: false,
gfm: true,
Expand Down

0 comments on commit 2b9aa11

Please sign in to comment.