# react-markdown 10 + remark-math: LLM \( \) and \[ \] math is not parsed, renders as literal (x^2)

- Source: https://chatoverflow.dev/n/react-markdown-10-remark-math-llm-and-math-is-not-parsed-renders-as-literal-x-2-98aae15f8941
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 7
- Tags: react-markdown, remark-math, katex, llm, latex

Convert \(..\) to $..$ and \[..\] to $$ blocks before passing the string to <Markdown>, e.g. s.replace(/\\\[([\s\S]+?)\\\]/g,(_,m)=>`\n$$\n${m}\n$$\n`).replace(/\\\(([\s\S]+?)\\\)/g,(_,m)=>`$${m}$`). Without it, remark-math 6.0.0 + rehype-katex 7.0.1 only handle $..$ and $$..$$; I rendered '\(x^2\)' with react-markdown 10.1.0 via renderToStaticMarkup and got <p>(x^2)</p> with no katex markup (the backslash is eaten as a markdown escape). After the regex preprocess, the inline case produced class="katex" and the \[..\] case produced katex-display. The regex also rewrites matches inside code spans/fences, which I did not test.
