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): fallback math rendering for multiline $$ blocks by 8Nothing8 · Pull Request #34642 · anomalyco/opencode

Conversation

@8Nothing8

@8Nothing8 8Nothing8 commented Jun 30, 2026 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown

Issue for this PR

Closes #34656

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Display math blocks ($$...$$) don't render when the content spans multiple lines.
For example:

$$\begin{aligned} \end{aligned}$$

appears as plain text instead of rendered math.

The root cause is in marked-katex-extension v5.1.6: its inline tokenizer regex
does not match across newlines (. without /s flag), so multiline $$ blocks
are treated as regular paragraphs and the delimiters pass through unprocessed.

The fix adds a post-processing step in the primary (non-nativeParser) rendering
path. After marked.parse() produces HTML, we run the output through the
existing renderMathExpressions() function. This function already has a
multiline-aware regex (/\$\$([\s\S]*?)\$\$/g) that catches any $$ blocks
the extension missed. The function also skips <pre>, <code>, and <kbd>
blocks, so it doesn't interfere with syntax-highlighted code.

Change is one file (packages/ui/src/context/marked.tsx), replacing a direct
return jsParser with a wrapper that calls renderMathExpressions() on the
parsed output.

How did you verify your code works?

Tested renderMathInText() directly with three inputs:

  • $$\begin{aligned}\end{aligned}$$ (single line) → rendered
  • $$\begin{aligned}\n\end{aligned}$$ (multiline) → rendered
  • $$\begin{aligned}\nx &= 1 \\\ny &= 2\n\end{aligned}$$ (real math) → rendered

All three produce valid KaTeX HTML with no residual $$ characters.

Screenshots / recordings

N/A — regex parsing change, no UI change.

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
@8Nothing8
fix(ui): fallback math rendering for multiline $$ blocks
8ee25f6
marked-katex-extension v5.1.6 fails to match display math ($$...$$) that
spans multiple lines because its inline tokenizer regex likely does not
use the dotAll (/s) flag, so a newline between \begin{aligned} and
\end{aligned} causes the block to be treated as plain text.

The fix: wrap the non-nativeParser path to post-process the HTML output
with the existing renderMathExpressions() function, which already uses a
multiline-aware regex (/\$\$([\s\S]*?)\$\$/g) to catch any $$ blocks
the extension missed. Successfully-rendered blocks contain no residual $$
and are safe from double-processing; code/pre/kbd blocks are protected by
the existing skip pattern in renderMathExpressions().
@github-actions github-actions Bot added needs:compliance This means the issue will auto-close after 2 hours. needs:issue labels Jun 30, 2026
@github-actions

github-actions Bot commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

All reactions

Sorry, something went wrong.

Uh oh!

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

@8Nothing8
Merge branch 'dev' into fix-multiline-math
11f9212
@github-actions github-actions Bot removed needs:compliance This means the issue will auto-close after 2 hours. needs:issue labels Jun 30, 2026
@github-actions

github-actions Bot commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

All reactions

Sorry, something went wrong.

Uh oh!

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

8Nothing8 added 6 commits July 1, 2026 01:18
@8Nothing8
Merge branch 'dev' into fix-multiline-math
8ae7f34
@8Nothing8
Merge branch 'dev' into fix-multiline-math
67c8bca
@8Nothing8
Merge branch 'dev' into fix-multiline-math
5ffb89a
@8Nothing8
Merge branch 'dev' into fix-multiline-math
6724af5
@8Nothing8
Merge branch 'dev' into fix-multiline-math
22d5499
@8Nothing8
Merge branch 'dev' into fix-multiline-math
5390a40
@github-actions github-actions Bot mentioned this pull request Jul 8, 2026
fix(app): render \[...\] LaTeX display math delimiters #35951
Closed
3 of 6 tasks
8Nothing8 added 2 commits July 14, 2026 17:08
@8Nothing8
Merge branch 'dev' into fix-multiline-math
b233d72
@8Nothing8
Merge branch 'dev' into fix-multiline-math
c0b97e6
@8Nothing8 8Nothing8 closed this Jul 24, 2026
@8Nothing8
8Nothing8 deleted the fix-multiline-math branch July 24, 2026 07:41
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.

Multiline display math ($$...$$) not rendered

Uh oh!

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

1 participant

@8Nothing8
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.