Explorar el Código

Replace @username with link to username

sbkwgh hace 8 años
padre
commit
d06fe0ce22
Se han modificado 1 ficheros con 5 adiciones y 1 borrados
  1. 5 1
      src/components/InputEditorPreview.vue

+ 5 - 1
src/components/InputEditorPreview.vue

@@ -22,7 +22,11 @@
 		props: ['value'],
 		computed: {
 			HTML () {
-				return Marked(this.value);
+				let replacedMd = this.value.replace(/@[^\s]+/g, match => {
+					return `[${match}](/user/${match.slice(1)})`
+				})
+
+				return Marked(replacedMd);
 			}
 		}
 	}