Explorar el Código

chore: support both $$ and $ latex format (#5723)

Nam Vu hace 9 meses
padre
commit
9513155fa4
Se han modificado 1 ficheros con 2 adiciones y 1 borrados
  1. 2 1
      web/app/components/base/markdown.tsx

+ 2 - 1
web/app/components/base/markdown.tsx

@@ -44,7 +44,8 @@ const preprocessLaTeX = (content: string) => {
   if (typeof content !== 'string')
     return content
   return content.replace(/\\\[(.*?)\\\]/gs, (_, equation) => `$$${equation}$$`)
-    .replace(/\\\((.*?)\\\)/gs, (_, equation) => `$${equation}$`)
+    .replace(/\\\((.*?)\\\)/gs, (_, equation) => `$$${equation}$$`)
+    .replace(/(^|[^\\])\$(.+?)\$/gs, (_, prefix, equation) => `${prefix}$${equation}$`)
 }
 
 export function PreCode(props: { children: any }) {