Procházet zdrojové kódy

bugfix: fix Marked highlihgt option

Le Tan před 8 roky
rodič
revize
df40ac2db0

+ 7 - 3
src/resources/hoedown.js

@@ -1,9 +1,13 @@
 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) {
-        return hljs.highlightAuto(code).value;
+    highlight: function(code, lang) {
+        if (lang && hljs.getLanguage(lang)) {
+            return hljs.highlight(lang, code).value;
+        } else {
+            return hljs.highlightAuto(code).value;
+        }
     }
 });
 

+ 0 - 1
src/resources/markdown-it.js

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

+ 6 - 2
src/resources/marked.js

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