-
Notifications
You must be signed in to change notification settings - Fork 181
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Bug Description
According to the docs, Streamdown only renders mathematical expressions when they are wrapped in double dollar signs ($$).
However, AI-generated content (and many LaTeX sources) commonly use \(...\) for inline math and \[...\] for block math.
As a result, valid mathematical expressions produced by AI models are not rendered unless manually converted to $$.
This creates a mismatch between Streamdown’s expected syntax and common AI/LaTeX output.
Steps to Reproduce
- Use Streamdown with the default math configuration.
- Generate mathematical content using an AI model, for example
openai/gpt-oss-120b, without explicitly specifying the required math delimiter format. - The AI may output math using common LaTeX conventions, such as:
## Inline math with \(...\)
This is inline math: \(x = \frac{1}{2}\) and another one \(E = mc^2\).
## Block math with \[...\]
\[
\int_{0}^{\infty} e^{-x^2} dx = \frac{\sqrt{\pi}}{2}
\]- Render the generated Markdown using Streamdown.
- Observe how the mathematical expressions are displayed.
Expected Behavior
Streamdown should render mathematical expressions correctly, including those using LaTeX-style delimiters (\(...\) for inline math and \[...\] for block math), without requiring manual conversion to $$ ... $$.
Actual Behavior
- Mathematical expressions wrapped with
\(...\)and\[...\]are rendered as plain text. - KaTeX is not invoked for these expressions.
- Only expressions wrapped with $$ ... $$ are detected and rendered as math.
Code Sample
function normalizeMathDelimiters(input: string): string[] {
return [
input
.replace(/\\\[/g, `$$$`)
.replace(/\\\]/g, `$$$`)
.replace(/\\\(/g, `$$$`)
.replace(/\\\)/g, `$$$`)
];
}Streamdown Version
1.6.10
React Version
19.2.3
Node.js Version
24.12.0
Browser(s)
No response
Operating System
None
Additional Context
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working