fix: Escape dollar signs followed by numbers in Markdown (#6797)

This commit introduces a change to prevent **Markdown** rendering issues where a dollar sign followed by a number (like **`$1`**) is incorrectly interpreted as **LaTeX** by the rendering engine.

---

The `normalizeLatex` function in `RenderMarkdown.tsx` now explicitly escapes these sequences (e.g., **`$1`** becomes **`\$1`**), ensuring they are displayed literally instead of being processed as mathematical expressions. This improves the fidelity of text that might contain currency or similar numerical notations.
This commit is contained in:
Akarshan Biswas 2025-10-16 12:15:24 +05:30 committed by GitHub
parent 2fb956ccaf
commit 147cab94a8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -62,6 +62,10 @@ const normalizeLatex = (input: string): string => {
(_, pre, inner) => `${pre}$${inner.trim()}$` (_, pre, inner) => `${pre}$${inner.trim()}$`
) )
// --- Escape $<number> to prevent Markdown from treating it as LaTeX
// Example: "$1" → "\$1"
s = s.replace(/\$(\d+)/g, '\\$$1')
return s return s
}) })
.join('') .join('')