mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-08 20:42:30 +08:00
### What problem does this PR solve? [remarkjs/react-markdown/issues/785](https://github.com/remarkjs/react-markdown/issues/785) Fix: Fixed an issue where math formulas could not be displayed correctly #4405 ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue)
This commit is contained in:
@ -34,3 +34,18 @@ export const buildMessageUuidWithRole = (
|
||||
) => {
|
||||
return `${message.role}_${message.id}`;
|
||||
};
|
||||
|
||||
// Preprocess LaTeX equations to be rendered by KaTeX
|
||||
// ref: https://github.com/remarkjs/react-markdown/issues/785
|
||||
|
||||
export const preprocessLaTeX = (content: string) => {
|
||||
const blockProcessedContent = content.replace(
|
||||
/\\\[([\s\S]*?)\\\]/g,
|
||||
(_, equation) => `$$${equation}$$`,
|
||||
);
|
||||
const inlineProcessedContent = blockProcessedContent.replace(
|
||||
/\\\(([\s\S]*?)\\\)/g,
|
||||
(_, equation) => `$${equation}$`,
|
||||
);
|
||||
return inlineProcessedContent;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user