anomalyco / anomalyco/opencode

Markdown math formula rendering broken on web

Open
#39,311 1 comment 0 reactions 1 assignee View on GitHub

@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:

  1. Removed the post-processing approach (renderMathInText, renderMathExpressions) in favor of marked's built-in tokenizer extensions, intercepting math tokens during Markdown parsing.
  2. Relaxed blockMathRegex: previously required $$...$$ to be wrapped with newlines (^$$\n(...)\n$$), changed to ^$$([\s\S]*?)$$.
  3. Added inlineDollarKatex extension: supports $...$ syntax for inline math (previously only (...) was supported).
    Affected: packages/ui/src/context/marked.tsx:379-567

Before:

Image

After these fix:

Image
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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.