Skip to content

RAGFlow is an agent-native database: a Retrieval-Augmented Generation (RAG) engine that grew into context infrastructure.

Fix: LaTeX formulas cannot be displayed on the chat page. (#14531)

balibabu00e03a194553
diff --git a/web/src/utils/chat.ts b/web/src/utils/chat.ts
index e620ba3eab..cc00249502 100644
--- a/web/src/utils/chat.ts
+++ b/web/src/utils/chat.ts
@@ -52,8 +52,8 @@ export const buildMessageUuidWithRole = (
// the last valid delimiter and avoid cutting at the first \] or \) inside the
// equation (e.g. \frac{1}{|y|} or \right]).
-const BLOCK_MATH_RE = /\\\[([\s\S]*)(?<![a-zA-Z])\\\]/g;
-const INLINE_MATH_RE = /\\\(([\s\S]*)(?<![a-zA-Z])\\\)/g;
+const BLOCK_MATH_RE = /\\\[([\s\S]*?)(?<![a-zA-Z])\\\]/g;
+const INLINE_MATH_RE = /\\\(([\s\S]*?)(?<![a-zA-Z])\\\)/g;
export const preprocessLaTeX = (content: string) => {
const blockProcessedContent = content.replace(