Skip to content

fix(ui): dollar amounts incorrectly rendered as LaTeX inline math#30715

Open
veerbal1 wants to merge 2 commits into
anomalyco:devfrom
veerbal1:dev
Open

fix(ui): dollar amounts incorrectly rendered as LaTeX inline math#30715
veerbal1 wants to merge 2 commits into
anomalyco:devfrom
veerbal1:dev

Conversation

@veerbal1
Copy link
Copy Markdown

@veerbal1 veerbal1 commented Jun 4, 2026

Dollar amounts like $50 were incorrectly rendered as LaTeX inline math. Added escaping of $ followed by a digit to $ before markdown parsing, so the markdown parser treats them as literal text instead of math delimiters. Real LaTeX like $x^2$ is unaffected.

Issue for this PR

Closes #30712

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

When text contains dollar amounts (e.g. "$80 + $50 = $130"), the markdown parser's marked-katex-extension interprets $...$ pairs as inline LaTeX math, causing random text fragments to render in a math font.

This PR escapes $ followed by a digit as the HTML entity $ before markdown parsing, preventing the math parser from recognizing it as a delimiter. Real LaTeX like $x^2 + y^2$ or display math $$...$$ is unaffected because the $ is followed by a letter or backslash, not a digit.

Changes in packages/ui/src/context/marked.tsx:

  • renderMathInText: escape $ before inline math regex runs
  • jsParser path: wrap the return to escape $ before passing to parser

How did you verify your code works?

  • Ran all 27 existing UI tests — all pass
  • Tested locally with bun dev serve + bun run --cwd packages/app dev
  • Verified dollar amounts like "$800 + $400 + $200 = $1400" render as plain text
  • Verified real LaTeX like "$E = mc^2$" and "$$\int_0^\infty e^{-x} dx = 1$$" still render as math

Screenshots / recordings

Before (dollar amounts incorrectly rendered as LaTeX math):
Screenshot 2026-06-04 at 3 01 08 PM

After (dollar amounts render as plain text):
Screenshot 2026-06-04 at 3 02 31 PM

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

Dollar amounts like $50 were incorrectly rendered as LaTeX inline
math. Added escaping of $ followed by a digit to \&anomalyco#36; before
markdown parsing, so the markdown parser treats them as literal
text instead of math delimiters. Real LaTeX like $x^2$ is
unaffected.
@github-actions github-actions Bot added needs:compliance This means the issue will auto-close after 2 hours. needs:issue labels Jun 4, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 4, 2026

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@github-actions github-actions Bot removed needs:issue needs:compliance This means the issue will auto-close after 2 hours. labels Jun 4, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 4, 2026

Thanks for updating your PR! It now meets our contributing guidelines. 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Dollar signs in plain text are incorrectly rendered as LaTeX inline math

1 participant