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 6472717
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions docs/USING_ADVANCED.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ 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 hljs = require('highlight.js');
const validLanguage = hljs.getLanguage(language) ? language : 'plaintext';
return hljs.highlight(validLanguage, code).value;
},
pedantic: false,
gfm: true,
Expand Down

0 comments on commit 6472717

Please sign in to comment.