GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(ui): render $..$ and same-line $$..$$ math by wulart · Pull Request #51989 · anomalyco/opencode

Conversation

@wulart

@wulart wulart commented Sep 29, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Issue for this PR

Closes #51725 (same gap reported in #39170, #38030, #34407, #49486)

Type of change

  • Bug fix

What does this PR do?

#34850 dropped $...$ inline math in favor of \(...\), fixing the currency false positives of the old unguarded matcher — but chat output overwhelmingly uses $...$ for inline and single-line $$...$$ for display math, which now renders as raw source (#51725 et al).

This reopens the delimiter question with the piece that was missing when #34850 was decided: guards on the dollar matcher. The old matcher ((?<!\$)\$(?!\$)...) had none, so costs $5 and $10 matched as math. This one requires:

  • opening $ not followed by whitespace
  • closing $ not preceded by whitespace
  • closing $ not followed by a digit
  • no $ or newline inside the content

so costs $5 and $10, from $1,000 to $2,000, and an unclosed $ (mid-stream output) all stay plain text.

Implementation stays inside the existing katex extension (marked-parser.tsx, +32/−8): the inline tokenizer falls back to $...$ when \(...\) doesn't match ($$...$$ inside a paragraph renders in display mode); the block regex accepts single-line and same-line $$...$$ alongside the existing newline-delimited form; start hints now report the earliest $ (inline) and \n$$ (block) so marked can split paragraphs around display math glued to preceding text. \(...\) and $$\n...\n$$ handling is untouched; no new dependencies.

#48329 covers this ground plus \[...\] with a larger rewrite — this is deliberately the minimal version scoped to the reported issues. Happy to extend the guard set if reviewers see cases it misses.

How did you verify your code works?

11 new cases in packages/ui/src/context/marked-parser.test.ts: single-dollar inline, symbol-heavy inline, CJK in \text{}, single-line block, block glued to text, in-paragraph $$, money amounts, unclosed delimiters, invalid latex, dollars literal inside code, plain markdown unaffected. All recognition cases fail on unmodified dev first; the money/unclosed/code-literal cases pass there since they assert non-rendering.

  • bun test in packages/ui — 38 pass (incl. marked-regression.test.ts)
  • bun test in packages/session-ui — 83 pass (the parser's consumer)
  • tsgo --noEmit clean

Screenshots / recordings

Rendering fix — the new tests show the before/after directly (<p>$x^2$</p> becomes <span class="katex">…); happy to attach a rendered screenshot on request.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
vimtor and others added 30 commits September 22, 2026 10:10
@vimtor
docs(console): add API reference for inference, BYOK, usage, and budg…
956de96
…ets (anomalyco#50582)
@Hona
fix(desktop): omit undefined fields from renderer IPC payloads (anoma…
8e62ad7
…lyco#50599)
@nexxeln
fix(tui): keep worktrees out of projects (anomalyco#50612)
2f06f9d
@opencode-agent
chore(core): refresh bundled models.dev snapshot
e0ddc47
opencode
sync release versions for v2.0.14
8864eb5
@opencode-agent @jlongster
refactor(tui): break composer import cycle (anomalyco#50637)
18eeb32
Co-authored-by: jlongster <[email protected]>
@nexxeln @Brendonovich
feat(cli): pair with direct server links (anomalyco#49971)
788f0af
Co-authored-by: Brendonovich <[email protected]>
@rekram1-node
refactor(ai): rename evaluation action to run (anomalyco#50529)
067a528
@OpeOginni @nexxeln
fix(client): preserve base URL path prefix in promise client (anomaly…
10aa949
…co#50428)

Co-authored-by: Shoubhit Dash <[email protected]>
@thdxr
fix(core): simplify shell output notices (anomalyco#50676)
ad1a4a6
@thdxr
fix(tui): show canonical projects in open dialog (anomalyco#50674)
3584eca
@rekram1-node
feat(ai): add gateway evaluation providers (anomalyco#50665)
f2bdee6
@nexxeln
feat(ai): add media foundation with Media assets and Image rewrite (a…
60c78ed
…nomalyco#49181)
@opencode-agent @jayair
fix(app): hide cached panel divider (anomalyco#50437)
51d2b66
Co-authored-by: jayair <[email protected]>
@jlongster
refactor(tui): derive bright terminal palette (anomalyco#50433)
cdccde7
@Tarquinen
fix(tui): remove redundant update command description (anomalyco#50687)
54fbf6d
@jlongster
test(codemode): extend promise limit timeout (anomalyco#50693)
bf6788b
@jlongster
test(app): remove flaky workspace focus test (anomalyco#50691)
7af65ef
@jlongster
test(app): remove flaky touch movement test (anomalyco#50692)
94df7a8
@opencode-agent @simonklee
test(tui): wait for workspace filter focus (anomalyco#50709)
ad756ef
Co-authored-by: simonklee <[email protected]>
@opencode-agent @jlongster
fix(ci): avoid stale Bun dependency caches (anomalyco#49845)
d2bbefb
Co-authored-by: jlongster <[email protected]>
@fwang
docs(www): sync Console model and Go guides
eea2475
@fwang
docs(www): merge Console documentation updates
126294a
@jlongster
feat(theme): support dynamic hue names (anomalyco#50728)
8683406
@opencode-agent @rekram1-node
feat(session): allow metadata updates (anomalyco#50025)
5c53cfc
Co-authored-by: rekram1-node <[email protected]>
@nexxeln
fix(acp): forward provider retry status to clients (anomalyco#50752)
38c320e
@nexxeln
fix(core): install git plugins from branch subdirectories (anomalyco#…
3a2203e
…50754)
@opencode-agent
chore: update nix node_modules hashes
1746672
@opencode-agent @rekram1-node
fix(tui): show latest step in turn token summary (anomalyco#50765)
fe0d168
Co-authored-by: rekram1-node <[email protected]>
@rekram1-node
fix(ai): replay Kimi reasoning details without the streaming index (a…
ddeb197
…nomalyco#50383)
rekram1-node and others added 5 commits September 28, 2026 19:29
@rekram1-node
fix(core): drop session ID and order instructions for prompt-cache re…
bda798b
…use (anomalyco#51960)
@rekram1-node
fix(core): share affinity in provider session headers (anomalyco#51931)
1fc05ca
@opencode-agent @rekram1-node
test(core): update xAI variant expectations for Responses (anomalyco#…
35bd8ac
…51977)

Co-authored-by: rekram1-node <[email protected]>
@rekram1-node
feat(core): align shell tool environment with agent conventions (anom…
3740ec3
…alyco#51975)
@rekram1-node
fix(ai): give provider routes distinct IDs (anomalyco#51976)
ca084b2
@github-actions

github-actions Bot commented Sep 29, 2026

Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

opencode and others added 9 commits September 29, 2026 04:31
opencode
sync release versions for v2.0.19
f02c30e
@rekram1-node
fix(ai): finalize Bedrock redacted reasoning at block end (anomalyco#…
36ef6cc
…51999)
@rekram1-node
fix(ai): bind Bedrock Claude thinking blocks by default (anomalyco#51959
34a8938
)
@Hona
chore(desktop): bump electron to 44.4.5 (anomalyco#52005)
293d60a
@Hona
fix(session-ui): render moved notice as a timeline divider (anomalyco…
41d4a9c
…#52009)
@Hona
fix(ui): calm diff word highlights with @pierre/diffs 1.5.1 (anomalyc…
a604b7f
…o#51236)
@rekram1-node
fix(ai): show provider error bodies when no message is recognized (an…
14af33d
…omalyco#51978)
@Hona
fix(desktop): give isolated dev service a fixed port (anomalyco#52013)
ff72659
@rekram1-node
fix(ai): read provider error messages from common body layouts (anoma…
2aaa265
…lyco#52014)
@feiiiiii5 feiiiiii5 mentioned this pull request Sep 29, 2026
fix(ci): recognize closing keywords for non-default-base PRs #51971
Closed
3 of 6 tasks
rekram1-node and others added 7 commits September 29, 2026 00:45
@rekram1-node
fix(core): turn off Workers AI thinking through the chat template (an…
6712cc4
…omalyco#52017)
@opencode-agent @rekram1-node
fix(ai): enable explicit caching on more message protocol routes (ano…
b30c4d0
…malyco#51981)

Co-authored-by: rekram1-node <[email protected]>
@vimtor
feat(core): tell users how to sign back in to OpenCode Console (anoma…
d76f968
…lyco#51847)
@vimtor
fix(core): drop SSO link from Console sign-in error (anomalyco#52062)
b29dab3
@kitlangton
feat(tui): show recently closed tabs in new session menu
7ef4a1a
@opencode-agent
chore(core): refresh bundled models.dev snapshot
0f931d3
zhifei @claude zhifei
fix(ui): render $..$ and same-line $$..$$ math
ad24d62
The katex extension only recognized \(...\) inline math and block math
requiring newlines right after the opening $$ and before the closing $$.
Most LLM chat output uses $..$ for inline math and single-line $$..$$
for display math, so those formulas currently render as raw source.

Extend the existing extension rather than adding a new one:

- inline: try $..$ after \(...\) fails, with display mode for $$..$$
- block: accept single-line and same-line $$..$$ alongside the existing
  newline-delimited form
- start hints: report the earliest $ for inline math and \n$$ for block
  math so marked can split paragraphs around glued display math

Currency guards keep money amounts as plain text: the opening $ must
not be followed by whitespace, the closing $ must not be preceded by
whitespace nor followed by a digit, and the content cannot contain $
or newlines ("costs $5 and $10", "$1,000 to $2,000" stay literal).
Unclosed delimiters are left as text; invalid latex renders as an
inline error via the existing throwOnError:false path.

Co-Authored-By: Claude Code <[email protected]>
@wulart
wulart force-pushed the feat/markdown-dollar-math branch from bcd31a7 to ad24d62 Compare September 29, 2026 12:51
@wulart
wulart requested review from Brendonovich and Hona as code owners September 29, 2026 12:51
@wulart wulart closed this Sep 29, 2026
@wulart

wulart commented Sep 29, 2026

Copy link
Copy Markdown
Author

Retargeting to the v2 line where merges are landing — superseded by #52087. The gap exists identically on v2 (its katex extension also only matches (...)).

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Veld101 Veld101 mentioned this pull request Sep 29, 2026
[FEATURE]: AGENTS.md: state the linked-issue rule for fix/chore/test PRs; scope the import rules #52022
Closed
1 task done
@wulart wulart mentioned this pull request Sep 29, 2026
fix(ui): render $..$ and same-line $$..$$ math #52100
Closed
3 tasks done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@Hona Hona Awaiting requested review from Hona
@Brendonovich Brendonovich Awaiting requested review from Brendonovich

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

chat: LaTeX math ($...$) is not rendered in messages

Uh oh!

There was an error while loading. Please reload this page.

20 participants

@wulart @vimtor @Hona @nexxeln @rekram1-node @OpeOginni @thdxr @jlongster @Tarquinen @fwang @vglafirov @adamdotdevin @MrMushrooooom @neriousy @gotenksIN @usrnk1 @arh @simonklee @kitlangton @jerome-benoit
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.