From 9513155fa46bc9bd1ed06381c163a831aea57d42 Mon Sep 17 00:00:00 2001 From: Nam Vu Date: Sat, 29 Jun 2024 10:24:25 +0700 Subject: [PATCH] chore: support both $$ and $ latex format (#5723) --- web/app/components/base/markdown.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/web/app/components/base/markdown.tsx b/web/app/components/base/markdown.tsx index 37d9ad691d..14a630b2ed 100644 --- a/web/app/components/base/markdown.tsx +++ b/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 }) {