bugfix: fix Marked highlihgt option

This commit is contained in:
Le Tan 2017-05-11 19:54:36 +08:00
parent a154e568de
commit df40ac2db0
3 changed files with 13 additions and 6 deletions

View File

@ -1,9 +1,13 @@
var placeholder = document.getElementById('placeholder'); var placeholder = document.getElementById('placeholder');
// Use Marked to highlight code blocks. // Use Marked to highlight code blocks in edit mode.
marked.setOptions({ marked.setOptions({
highlight: function(code) { highlight: function(code, lang) {
return hljs.highlightAuto(code).value; if (lang && hljs.getLanguage(lang)) {
return hljs.highlight(lang, code).value;
} else {
return hljs.highlightAuto(code).value;
}
} }
}); });

View File

@ -46,7 +46,6 @@ var mdit = window.markdownit({
} else { } else {
return hljs.highlightAuto(str).value; return hljs.highlightAuto(str).value;
} }
return '';
} }
}); });

View File

@ -16,8 +16,12 @@ renderer.heading = function(text, level) {
// Highlight.js to highlight code block // Highlight.js to highlight code block
marked.setOptions({ marked.setOptions({
highlight: function(code) { highlight: function(code, lang) {
return hljs.highlightAuto(code).value; if (lang && hljs.getLanguage(lang)) {
return hljs.highlight(lang, code).value;
} else {
return hljs.highlightAuto(code).value;
}
} }
}); });