Spaces:
Sleeping
Sleeping
fix latex
Browse files
web/src/math-preprocessing.ts
CHANGED
|
@@ -60,10 +60,13 @@ export function preprocessMathContent(content: string): string {
|
|
| 60 |
processed = processed.replace(/\s+\\$/gm, '');
|
| 61 |
|
| 62 |
// Step 0.6: Fix list markers contaminating math delimiters
|
| 63 |
-
//
|
| 64 |
-
//
|
| 65 |
-
processed = processed.replace(/(\d+)\$
|
| 66 |
-
|
|
|
|
|
|
|
|
|
|
| 67 |
|
| 68 |
// Step 1: Protect currency amounts from being parsed as math
|
| 69 |
// Strategy: Replace $number with a placeholder, restore after
|
|
|
|
| 60 |
processed = processed.replace(/\s+\\$/gm, '');
|
| 61 |
|
| 62 |
// Step 0.6: Fix list markers contaminating math delimiters
|
| 63 |
+
// Must run AFTER Step 0.25 (delimiter stacking cleanup)
|
| 64 |
+
// Pattern 1: Opening delimiter touching list marker: "1$$math" → "1. $$math"
|
| 65 |
+
processed = processed.replace(/(\d+)\$\$/g, '$1. $$');
|
| 66 |
+
// Pattern 2: Closing delimiter followed by list marker with stray $: "$$1$" → "$$ 1."
|
| 67 |
+
processed = processed.replace(/\$\$(\d+)\$/g, '$$ $1.');
|
| 68 |
+
// Pattern 3: List marker between math blocks: "$text$1$more$" → "$text$ 1. $more$"
|
| 69 |
+
processed = processed.replace(/\$(\d+)\$/g, '$ $1. $');
|
| 70 |
|
| 71 |
// Step 1: Protect currency amounts from being parsed as math
|
| 72 |
// Strategy: Replace $number with a placeholder, restore after
|