fraudTech commited on
Commit
c6832b1
·
1 Parent(s): c71ba63

fix latex

Browse files
Files changed (1) hide show
  1. web/src/math-preprocessing.ts +7 -4
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
- // Pattern: "1. $$math$$" or "1. $math$" becomes "1. " followed by clean delimiters
64
- // Also handles: "1$$math$$" → "1. $$math$$"
65
- processed = processed.replace(/(\d+)\$+/g, '$1. ');
66
- processed = processed.replace(/(\d+\.\s*)\$+/g, '$1');
 
 
 
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