Просмотр исходного кода

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

Nam Vu 9 месяцев назад
Родитель
Сommit
9513155fa4
1 измененных файлов с 2 добавлено и 1 удалено
  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 }) {