Ver código fonte

fix: 修改latex显示

余尚辉 2 meses atrás
pai
commit
78270e5ad3
1 arquivos alterados com 6 adições e 2 exclusões
  1. 6 2
      src/components/Chat/ChatText.vue

+ 6 - 2
src/components/Chat/ChatText.vue

@@ -50,12 +50,16 @@ mdi.renderer.rules.table_close = function () { return '</table></div>'; };
 mdi.use(markdownItSub);
 mdi.use(markdownItSup);
 
-
+const transformText = (text) => {
+  return text.replace(/\b\w*_\w*\/\w*\W*\w*\b/g, function (match) {
+    return `$${match}$`;
+  });
+}
 
 const text = computed(() => {
   let value = props.content ?? ""
   value = value.replace(/\((\w+_\w+)\)/g, '($$$1$)');
-
+  value = transformText(value)
   if (!props.asRawText)
     return mdi.render(value)
   return value