Bug
Markdown messages containing currency amounts (or any prose with two $ signs in the same text run) are silently re-rendered as KaTeX inline math. The text between the two $ signs is collapsed into a single math expression — whitespace stripped, letters reflowed as italic math symbols, apostrophes turned into prime marks — and is no longer readable as prose.
remark-math is configured with defaults, which enables singleDollarTextMath: true. Any pair of $ characters in a paragraph becomes a math span. Currency mentions are extremely common in chat (pricing discussions, plan comparisons, billing), so the false-positive rate is high enough that users have hit it on day-to-day prose.
Reproduction
Render this paragraph through the chat surface (works in <MarkdownText />, <Reasoning />, and <MarkdownRenderer /> — all share MARKDOWN_PLUGINS):
The plan is $200/mo and the bill is $80 — total $400 saved.
Expected: three literal currency amounts in plain text.
Actual: everything between the first $ and the next-to-last $ is rendered inside a <span class="katex"> block. Output looks like:
The plan is <span class="katex">200/mo and the bill is</span>80 — total $400 saved.
Real-world example pulled from a user-reported message:
At least $400 of API usage on a $200 plan. That's 2:1 minimum.
→ Renders as At least <math>...</math>400 of API usage on a 200 plan. That's 2:1 minimum. with all the running text collapsed into KaTeX italic glyphs.
Trade-off vs #237
Issue #237 (closed) added KaTeX support and explicitly cited single-dollar form $ E= mc^2 $ as desired. Disabling single-dollar inline math reverses that part of the decision — users who want inline math will need to switch to:
$$E = mc^2$$ on its own line (block math, still works)
```math fenced block (if/when remark-math gains GFM math fence support)
That's a regression for math-heavy users, but the false-positive rate from $N/$NN currency prose is high enough that the current default makes most non-math messages unsafe to render.
Proposed fix
Pass singleDollarTextMath: false to remarkMath in web/src/components/assistant-ui/markdown-text.tsx (single source of truth — used by MarkdownText, Reasoning, and MarkdownRenderer). Block math $$...$$ keeps working. This matches GitHub-flavored markdown, which only treats math as math inside $$...$$ or fenced ```math blocks, never inside a single $.
PR with regression tests follows.
Environment
web/ package
remark-math@^6.0.0
rehype-katex@^7.0.1
- Affects every
MarkdownText / Reasoning / MarkdownRenderer consumer
Bug
Markdown messages containing currency amounts (or any prose with two
$signs in the same text run) are silently re-rendered as KaTeX inline math. The text between the two$signs is collapsed into a single math expression — whitespace stripped, letters reflowed as italic math symbols, apostrophes turned into prime marks — and is no longer readable as prose.remark-mathis configured with defaults, which enablessingleDollarTextMath: true. Any pair of$characters in a paragraph becomes a math span. Currency mentions are extremely common in chat (pricing discussions, plan comparisons, billing), so the false-positive rate is high enough that users have hit it on day-to-day prose.Reproduction
Render this paragraph through the chat surface (works in
<MarkdownText />,<Reasoning />, and<MarkdownRenderer />— all shareMARKDOWN_PLUGINS):Expected: three literal currency amounts in plain text.
Actual: everything between the first
$and the next-to-last$is rendered inside a<span class="katex">block. Output looks like:Real-world example pulled from a user-reported message:
→ Renders as
At least <math>...</math>400 of API usage on a 200 plan. That's 2:1 minimum.with all the running text collapsed into KaTeX italic glyphs.Trade-off vs #237
Issue #237 (closed) added KaTeX support and explicitly cited single-dollar form
$ E= mc^2 $as desired. Disabling single-dollar inline math reverses that part of the decision — users who want inline math will need to switch to:$$E = mc^2$$on its own line (block math, still works)```mathfenced block (if/when remark-math gains GFM math fence support)That's a regression for math-heavy users, but the false-positive rate from
$N/$NNcurrency prose is high enough that the current default makes most non-math messages unsafe to render.Proposed fix
Pass
singleDollarTextMath: falsetoremarkMathinweb/src/components/assistant-ui/markdown-text.tsx(single source of truth — used byMarkdownText,Reasoning, andMarkdownRenderer). Block math$$...$$keeps working. This matches GitHub-flavored markdown, which only treats math as math inside$$...$$or fenced```mathblocks, never inside a single$.PR with regression tests follows.
Environment
web/packageremark-math@^6.0.0rehype-katex@^7.0.1MarkdownText/Reasoning/MarkdownRendererconsumer