Spaces:
Sleeping
Sleeping
continue to fix latex
Browse files- web/src/mathjax-config.ts +10 -0
web/src/mathjax-config.ts
CHANGED
|
@@ -60,6 +60,16 @@ export function preprocessMathContent(content: string): string {
|
|
| 60 |
|
| 61 |
let processed = content;
|
| 62 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 63 |
// Step 0.3: Fix markdown table pipes interfering with math
|
| 64 |
// Replace $$|$ patterns (table separator after display math) with proper spacing
|
| 65 |
processed = processed.replace(/\$\$\|\$/g, '$$ | $');
|
|
|
|
| 60 |
|
| 61 |
let processed = content;
|
| 62 |
|
| 63 |
+
// Step 0.1: Normalize LaTeX delimiters (MUST BE FIRST!)
|
| 64 |
+
// Convert \(...\) to $...$ for inline math
|
| 65 |
+
// Convert \[...\] to $$...$$ for display math
|
| 66 |
+
// This handles LLM responses that use LaTeX-style delimiters
|
| 67 |
+
processed = processed
|
| 68 |
+
.replace(/\\\(/g, '$')
|
| 69 |
+
.replace(/\\\)/g, '$')
|
| 70 |
+
.replace(/\\\[/g, '\n$$')
|
| 71 |
+
.replace(/\\\]/g, '$$\n');
|
| 72 |
+
|
| 73 |
// Step 0.3: Fix markdown table pipes interfering with math
|
| 74 |
// Replace $$|$ patterns (table separator after display math) with proper spacing
|
| 75 |
processed = processed.replace(/\$\$\|\$/g, '$$ | $');
|