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 — feat: render single-dollar and inline double-dollar LaTeX math with KaTeX by Cl-VII · Pull Request #40878 · anomalyco/opencode

Conversation

@Cl-VII

@Cl-VII Cl-VII commented Aug 6, 2026

Copy link
Copy Markdown

Issue for this PR

Related to #40508 (LaTeX rendering in OpenCode). This PR brings ChatGPT-style single-dollar inline math to the web/desktop rendering pipeline, which already renders KaTeX for \(...\) and block ... but not single $...$.

Type of change

  • New feature

What does this PR do?

The web/desktop markdown pipeline (packages/ui/src/context/marked-parser.tsx) registers KaTeX extensions for \(...\) (inline) and ... (block, own-paragraph). Model replies commonly use single-dollar inline math ( = \beta_0 + \beta_1 x$) and inline ... — both currently render as raw LaTeX source.

This PR adds two marked inline extensions:

  • inlineDollarKatex: renders $...$ via KaTeX
  • inlineDoubleDollarKatex: renders inline (non-own-paragraph) ... via KaTeX

Edge cases handled (with tests):

  • Currency/placeholder protection: today, .02/GB, $ 5 are left untouched
  • Formulas starting with a number still render: (L_{ur}-L_r)\sim\chi^2(Q)$
  • Unclosed $ does not swallow the rest of the text (streaming-safe)
  • Escaped \$ inside math works
  • Formulas do not cross newlines
  • The existing block ... (own-paragraph, display mode) and \(...\) behavior is unchanged

How did you verify your code works?

  • Added 9 unit tests covering rendering, currency guard, unclosed dollar, escaped dollar, newline boundary, number-leading formulas — all pass (bun test packages/ui: 35/35)
  • tsgo --noEmit typecheck passes
  • Verified against a full econometrics lecture note (23 formulas: LPM, Probit/Logit, MLE, delta method, LR/Wald tests): all 23 render as KaTeX with zero leftover $ pairs
  • Streaming check: partially-streamed $... stays as plain text until closed, then renders — no flicker or swallowed text

Screenshots / recordings

N/A (HTML output verified; KaTeX renders mathml + html dual output for accessibility)

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
opencode-latex
feat: render single-dollar and inline double-dollar LaTeX math with K…
7c9570e
…aTeX
@github-actions

github-actions Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

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

Based on the search results, here are the potentially related PRs:

  1. PR feat: render LaTeX math as Unicode in TUI #40867 - feat: render LaTeX math as Unicode in TUI

    • Related work on LaTeX rendering, but for TUI instead of web/desktop
    • Addresses the same issue domain (LaTeX math display) but in a different UI layer
  2. PR fix(app): render \[...\] LaTeX display math delimiters #35951 - fix(app): render \[...\] LaTeX display math delimiters

    • Earlier fix for LaTeX display math delimiters
    • May be a predecessor to this work
  3. PR fix(ui) latex dollar render #38829 - fix(ui) latex dollar render

    • Appears to be a previous attempt at handling dollar-sign LaTeX rendering
    • Could be related or superseded by this PR

The most relevant is PR #40867, which is recent and addresses LaTeX rendering in a complementary way. The other PRs appear to be historical or related attempts at the same problem.

All reactions

Sorry, something went wrong.

Uh oh!

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

@Cl-VII

Cl-VII commented Aug 6, 2026

Copy link
Copy Markdown
Author

Closing: conflicts with official design decision #34850 (single-dollar math intentionally disabled). Author requested removal.

All reactions

Sorry, something went wrong.

Uh oh!

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

@Cl-VII Cl-VII closed this Aug 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

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.

Uh oh!

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

1 participant

@Cl-VII
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.