You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[FEATURE]: Laxtex rendering in opencode web ui #24426
A few implementation details from local validation that may help scope this:
Current behavior in opencode web:
The app already bundles KaTeX and uses marked-katex-extension for markdown rendering.
However, the renderer currently handles $...$ and $$...$$, but not \(...\) and \[...\].
In practice, models often emit the escaped LaTeX delimiters, so users see raw math like \(\rho\) and \[ ... \] instead of rendered equations.
Concrete repro in opencode web:
A quantum state \( \rho \) gives an observable expectation by
\[
\langle O \rangle = \mathrm{Tr}(O\rho)
\]
Observed result:
\( \rho \) and \[ ... \] render as plain text.
Relevant code paths:
packages/ui/src/context/marked.tsx
already uses marked-katex-extension
packages/ui/src/styles/index.css
already imports katex/dist/katex.min.css
So this looks less like “add a renderer from scratch” and more like “normalize/accept the standard escaped LaTeX delimiters before markdown parsing”.
Minimal implementation direction:
Normalize \(...\) -> $...$
Normalize \[...\] -> $$...$$
Do that before markdown parsing, while skipping inline code / fenced code blocks so code samples are not mutated.
One extra note: the public share page renderer is a separate code path from the main app UI, so if this gets fixed in opencode web, it is worth checking whether the share page should be kept in sync too.
If you are looking to improve math rendering in opencode web and support standard escaped LaTeX delimiters like \( and \[ without leaking into inline code blocks, you can consider using browser-native MathML Core.
Since all major modern browser engines (Blink, WebKit, Gecko) natively support MathML, compiling LaTeX to standard <math> tags delegates all layout work to the browser's native C++ engine, completely eliminating the need for client-side JS layout calculations and heavy CSS/font assets.
You can also use its plugin @webc.site/math-marked (or configure a custom marked extension) to parse TeX. To support \(...\) and \[...\] delimiters safely before parsing (while skipping inline/fenced code blocks), you can implement a custom tokenizer/lexer or pre-normalize them.
A simple pre-normalization function that skips code blocks (using regex to split code blocks from plain text) might look like:
constnormalizeDelimiters=(markdown)=>{// Regex to split by fenced code blocks (```)constparts=markdown.split(/(```[\\s\\S]*?```)/g);returnparts.map((part,index)=>{// If it's a code block, leave it untouchedif(index%2===1)returnpart;// Otherwise, normalize \( ... \) and \[ ... \] to $ ... $ and $$ ... $$returnpart.replace(/\\\[([\\s\\S]*?)\\\]/g,'$$$$$1$$$$').replace(/\\\(([\\s\\S]*?)\\\)/g,'$$$1$$');}).join('');};
Applying this normalization before passing the markdown text to marked will cleanly resolve the delimiter issue without mutating any actual code samples.
Activity
github-actions commentedon Apr 26, 2026
This issue might be a duplicate of existing issues. Please check:
mbrotos commentedon Apr 26, 2026
A few implementation details from local validation that may help scope this:
Current behavior in
opencode web:marked-katex-extensionfor markdown rendering.$...$and$$...$$, but not\(...\)and\[...\].\(\rho\)and\[ ... \]instead of rendered equations.Concrete repro in
opencode web:Observed result:
\( \rho \)and\[ ... \]render as plain text.Relevant code paths:
packages/ui/src/context/marked.tsxmarked-katex-extensionpackages/ui/src/styles/index.csskatex/dist/katex.min.cssSo this looks less like “add a renderer from scratch” and more like “normalize/accept the standard escaped LaTeX delimiters before markdown parsing”.
Minimal implementation direction:
\(...\)->$...$\[...\]->$$...$$One extra note: the public share page renderer is a separate code path from the main app UI, so if this gets fixed in
opencode web, it is worth checking whether the share page should be kept in sync too.x-at-01 commentedon Jun 7, 2026
If you are looking to improve math rendering in
opencode weband support standard escaped LaTeX delimiters like\(and\[without leaking into inline code blocks, you can consider using browser-native MathML Core.Since all major modern browser engines (Blink, WebKit, Gecko) natively support MathML, compiling LaTeX to standard
<math>tags delegates all layout work to the browser's native C++ engine, completely eliminating the need for client-side JS layout calculations and heavy CSS/font assets.I wrote
@webc.site/math(GitHub: https://github.com/webc-site/math, Live Demo: https://math.webc.site) — the world's smallest and fastest TeX-to-MathML compiler:You can also use its plugin
@webc.site/math-marked(or configure a custom marked extension) to parse TeX. To support\(...\)and\[...\]delimiters safely before parsing (while skipping inline/fenced code blocks), you can implement a custom tokenizer/lexer or pre-normalize them.A simple pre-normalization function that skips code blocks (using regex to split code blocks from plain text) might look like:
Applying this normalization before passing the markdown text to
markedwill cleanly resolve the delimiter issue without mutating any actual code samples.github-actions commentedon Aug 7, 2026
To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.