mirror of
https://gitee.com/wanwujie/deer-flow
synced 2026-04-16 11:24:45 +08:00
fix:the formual display error after report editing (#627)
This commit is contained in:
@@ -21,6 +21,23 @@ export function normalizeMathForEditor(markdown: string): string {
|
||||
.replace(/\\\\\(([^)]*)\\\\\)/g, (_match, content) => `$${content}$`) // \\(...\\) → $...$
|
||||
.replace(/\\\(([^)]*)\\\)/g, (_match, content) => `$${content}$`); // \(...\) → $...$
|
||||
|
||||
// Replace double backslashes with single in math contexts
|
||||
// For inline math: $...$
|
||||
normalized = normalized.replace(
|
||||
/\$([^\$]+?)\$/g,
|
||||
(match, mathContent) => {
|
||||
return `$${mathContent.replace(/\\\\/g, '\\')}$`;
|
||||
}
|
||||
);
|
||||
|
||||
// For display math: $$...$$
|
||||
normalized = normalized.replace(
|
||||
/\$\$([\s\S]+?)\$\$/g,
|
||||
(match, mathContent) => {
|
||||
return `$$${mathContent.replace(/\\\\/g, '\\')}$$`;
|
||||
}
|
||||
);
|
||||
|
||||
return normalized;
|
||||
}
|
||||
|
||||
@@ -41,6 +58,23 @@ export function normalizeMathForDisplay(markdown: string): string {
|
||||
.replace(/\\\\\(([^)]*)\\\\\)/g, (_match, content) => `$$${content}$$`) // \\(...\\) → $$...$$
|
||||
.replace(/\\\(([^)]*)\\\)/g, (_match, content) => `$$${content}$$`); // \(...\) → $$...$$
|
||||
|
||||
// Replace double backslashes with single in math contexts
|
||||
// For inline math: $...$
|
||||
normalized = normalized.replace(
|
||||
/\$([^\$]+?)\$/g,
|
||||
(match, mathContent) => {
|
||||
return `$${mathContent.replace(/\\\\/g, '\\')}$`;
|
||||
}
|
||||
);
|
||||
|
||||
// For display math: $$...$$
|
||||
normalized = normalized.replace(
|
||||
/\$\$([\s\S]+?)\$\$/g,
|
||||
(match, mathContent) => {
|
||||
return `$$${mathContent.replace(/\\\\/g, '\\')}$$`;
|
||||
}
|
||||
);
|
||||
|
||||
return normalized;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user