mirror of
https://github.com/markedjs/marked
synced 2024-11-22 17:37:24 +00:00
Improve example for invoking highlight.js
This commit is contained in:
parent
3ab4bf5cfd
commit
6472717eaa
@ -20,8 +20,10 @@ const marked = require('marked');
|
|||||||
// `highlight` example uses `highlight.js`
|
// `highlight` example uses `highlight.js`
|
||||||
marked.setOptions({
|
marked.setOptions({
|
||||||
renderer: new marked.Renderer(),
|
renderer: new marked.Renderer(),
|
||||||
highlight: function(code) {
|
highlight: function(code, language) {
|
||||||
return require('highlight.js').highlightAuto(code).value;
|
const hljs = require('highlight.js');
|
||||||
|
const validLanguage = hljs.getLanguage(language) ? language : 'plaintext';
|
||||||
|
return hljs.highlight(validLanguage, code).value;
|
||||||
},
|
},
|
||||||
pedantic: false,
|
pedantic: false,
|
||||||
gfm: true,
|
gfm: true,
|
||||||
|
Loading…
Reference in New Issue
Block a user