fraudTech commited on
Commit
07a596c
·
1 Parent(s): 16b7a0a

Continue to fix latex

Browse files
Files changed (1) hide show
  1. web/src/mathjax-config.ts +3 -2
web/src/mathjax-config.ts CHANGED
@@ -169,8 +169,9 @@ export function preprocessMathContent(content: string): string {
169
  );
170
 
171
  // Step 3: Fix spacing issues around single dollar signs
172
- // $ x $ should become $x$
173
- processed = processed.replace(/\$\s+(.+?)\s+\$/g, '$$$1$$');
 
174
 
175
  // Step 4: Ensure display math with newlines is properly formatted
176
  // MathJax needs $$ on separate lines for multi-line display math
 
169
  );
170
 
171
  // Step 3: Fix spacing issues around single dollar signs
172
+ // Only collapse excessive whitespace, don't break trailing spaces before $
173
+ // $ x $ should become $x$ but $\mathbb{R}^2 $ should stay as is
174
+ processed = processed.replace(/\$\s{2,}(.+?)\s{2,}\$/g, '$$$$1$$');
175
 
176
  // Step 4: Ensure display math with newlines is properly formatted
177
  // MathJax needs $$ on separate lines for multi-line display math