Jelajahi Sumber

Sanitize input and add highlighting

sbkwgh 8 tahun lalu
induk
melakukan
59e55092ac
2 mengubah file dengan 8 tambahan dan 0 penghapusan
  1. 1 0
      package.json
  2. 7 0
      src/components/InputEditor.vue

+ 1 - 0
package.json

@@ -10,6 +10,7 @@
   },
   "dependencies": {
     "axios": "^0.15.3",
+    "highlight.js": "^9.10.0",
     "lodash.throttle": "^4.1.1",
     "marked": "^0.3.6",
     "vue": "^2.1.0",

+ 7 - 0
src/components/InputEditor.vue

@@ -72,6 +72,13 @@
 
 	import Marked from 'marked'
 
+	Marked.setOptions({
+		highlight: function (code) {
+			return require('highlight.js').highlightAuto(code).value;
+		},
+		sanitize: true
+	});
+
 	export default {
 		name: 'InputEditor',
 		props: ['value', 'float', 'replyUsername', 'hideClose', 'show', 'error'],