Skip to content

Commit

Permalink
Merge pull request #1603 from octogonz/octogonz/fix-highlight.js
Browse files Browse the repository at this point in the history
Improve example for invoking highlight.js
  • Loading branch information
styfle committed Feb 14, 2020
2 parents 3ab4bf5 + 6472717 commit 6ae3651
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

1 comment on commit 6ae3651

@vercel
Copy link

@vercel vercel bot commented on 6ae3651 Feb 14, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.