anomalyco / anomalyco/opencode
Markdown math formula rendering broken on web
@Hona is already working on this.
Since Jul 28, 2026.
- Dominant language
- TypeScript
- Stars
- 209k
- Forks
- 27.5k
- PR merge metrics
- PR metrics pending
Description
Description
Math formulas (LaTeX) fail to render correctly on the web page, displaying raw LaTeX source instead of rendered equations.
Root cause: In packages/ui/src/context/marked.tsx, math rendering was implemented as a post-processing step after Markdown → HTML conversion (renderMathExpressions + renderMathInText), doing regex replacement on the generated HTML string. HTML tree structure and LaTeX syntax conflict in this approach, causing matching failures or malformed output.
Fix:
- Removed the post-processing approach (renderMathInText, renderMathExpressions) in favor of marked's built-in tokenizer extensions, intercepting math tokens during Markdown parsing.
- Relaxed blockMathRegex: previously required $$...$$ to be wrapped with newlines (^$$\n(...)\n$$), changed to ^$$([\s\S]*?)$$.
- Added inlineDollarKatex extension: supports $...$ syntax for inline math (previously only (...) was supported).
Affected: packages/ui/src/context/marked.tsx:379-567
Before:
After these fix:
Plugins
No response
OpenCode version
1.18
Steps to reproduce
Ask LLM for some latex
Screenshot and/or share link
No response
Operating System
OpenSUSE
Terminal
Wezterm
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.