Jelajahi Sumber

Debug toHTML

Loquicom 5 tahun lalu
induk
melakukan
2bdf7e794e
1 mengubah file dengan 6 tambahan dan 1 penghapusan
  1. 6 1
      src/js/script.js

+ 6 - 1
src/js/script.js

@@ -2,7 +2,12 @@
  * Transform markdown string to html 
  */
 String.prototype.toHTML = function() {
-    return DOMPurify.sanitize(marked(this.toString()).replace(/<code>/g, '<pre class="prettyprint">').replace(/<\/code>/g, '</pre>'));
+    return DOMPurify.sanitize(
+        marked(this.toString())
+        .replace(/<code>/g, '<pre class="prettyprint">')
+        .replace(/<code class="/g, '<pre class="prettyprint ')
+        .replace(/<\/code>/g, '</pre>')
+    );
 }
 
 Array.prototype.removeItem = function(item) {