Your LLM Writes \(x\), Your Markdown Parser Wants $x$

TL;DR AI
2 min readKey summary
A developer built Markdown math support for TeX-style inline and display delimiters emitted by LLMs, such as \(\) and \[\].
The problem was that most Markdown math plugins assume dollar-sign delimiters, so LLM output often broke parsing.
Regex-based delimiter swapping proved brittle around code spans, escaped punctuation, TeX commands, and truncated streaming text.
The fix was added in the micromark tokenizer, then released as micromark-extension-math-extended and remark-math-extended.
This makes Markdown pipelines and tools like KaTeX handle LLM-generated math more reliably, especially in streaming workflows.
