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,10 +1,14 @@
var placeholder = document.getElementById('placeholder');
// Use Marked to highlight code blocks.
// Use Marked to highlight code blocks in edit mode.
marked.setOptions({
highlight: function(code) {
highlight: function(code, lang) {
if (lang && hljs.getLanguage(lang)) {
return hljs.highlight(lang, code).value;
} else {
return hljs.highlightAuto(code).value;
}
}
});
var updateHtml = function(html) {

View File

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

View File

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