Skip to content

feat: render LaTeX math in Markdown docs - #218

Merged
vite-hub[bot] merged 4 commits into
mainfrom
feat/math
Nov 17, 2026
Merged

vite-hub[bot] merged 4 commits into
mainfrom
feat/math

Conversation

@onmax

@onmax onmax commented Nov 17, 2026 •

Copy link
Copy Markdown
Member

A doc with math shows every formula as its TeX in monospace, and Drop refuses to publish it once it has a $$ block (::comark-mathml-2` is not a known component). The economics paper we published from a PDF had to turn every equation into a PNG because of this.

The parsing was already there: comark-ui's comark-mathml typesets $…$, $$…$$ and ```math fences to MathML on the server. Two bugs in comark-ui broke it under Drop's setup: security stripped the MathML, and the linter rejected display math. onmax/comark-ui#449 fixes both, and this PR moves Drop onto that PR's latest build. MathML needs no script, font or stylesheet in the browser, and the server imports Temml only for a doc that has a formula. "Copy as Markdown" already returns the source, so it keeps the LaTeX.

Comments needed three fixes in shared/plan-runtime.ts:

  • A quote's anchor skips text that isn't drawn: the inline <style> comark-mathml puts before the first formula, and each formula's TeX <annotation>. Before this, a comment whose quote crossed the first formula never found its text.
  • A quote's anchor also skips the invisible text under <mphantom>.
  • A selection quotes a formula as drawn, with a space between symbols and k as the italic 𝑘. A quote that doesn't match exactly is matched again without whitespace and in NFKC form, and a character only a formula draws that way has to land inside a formula, so a comment on the formula's 𝑘 can't move to the k of "stock".
  • A bubble or suggestion at a quote's end inside a formula goes right after its <math>, which can't hold HTML. A display formula's bubble sits beside it.

The comark-ui update also brings #447, which leaves Kroki fences as code unless drawing is on, so the preset passes diagrams: true to keep drawing them. The render cache goes to drop.23 so existing docs re-render with their math. The Markdown reference documents math, and math comes off the "What Drop doesn't render" table.

Evidence: https://drop.vitehub.dev/d/ytyz8f3ce9sw/before-after

test/skills/math.test.mjs (render, lint, a doc without math) and test/viewer/math-comments-browser.test.mjs fail without this change. The browser test also fails with only plan-runtime.ts reverted. Typecheck, lint and doctor pass. The four review and viewer browser tests that fail on this branch (marker, highlight, dock overflow, send) fail on main the same way on my machine.

The live editor keeps inline math and math fences. A doc with a $$ block stays read-only there, as on main, since the editor doesn't save it back unchanged.

Depends on onmax/comark-ui#449: package.json points at its pkg.pr.new build, and moves to the release once it's merged.

🤖 Generated with Claude Code

Docs typeset `$…$`, `$$…$$`, and ```math fences as MathML while parsing, through comark-ui's comark-mathml,
which now keeps its formulas through Drop's security allowlist and lints display math clean (onmax/comark-ui#449).
A doc without math loads nothing for it, and Copy as Markdown keeps the LaTeX.

Comments work on and around formulas: a quote's anchor skips text that isn't drawn (an inline block's <style>,
a formula's TeX annotation) and matches a formula as a selection quotes it, with its symbols spaced and in their
italic forms. A bubble at a quote's end inside a formula sits right after its <math>, beside a display formula.

The comark-ui update leaves Kroki fences as code unless drawing is on, so Drop turns it on, as before. The render
cache revision goes up so existing docs render their math.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@chatgpt-codex-connector

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-17T09:49:07.377771Z
We couldn’t complete this review. Comment @codex review to try again.
cb6a6e4 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@vite-hub

vite-hub Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor
Session Status Started Duration
Pending Completed Not started —
View session Waiting 2026-11-17T12:57:37.763Z 2m 39s
View session Cancelled 2026-11-17T12:36:42.749Z 5m 44s
View session Cancelled 2026-11-17T10:45:25.304Z 1m 57s
View session Cancelled 2026-11-17T10:44:54.452Z 7s

Latest result

Pull request merged.

Final answers

Session

Pull request merged.

Session

Merged 7cd03b9 directly: required checks passed and review threads were resolved.

View session

No repair needed: prior findings are fixed, threads resolved, and hosted checks green. Local lint and three math tests passed; two browser tests could not launch because Chromium is absent. Upstream prerequisite remains unverified because github.com DNS resolution failed.

Session

Pull request evidence changed.

Session

Waiting for review checks before the next pass.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Important

Formula comments can attach to unrelated prose, and formulas with phantom spacing leave their comments unplaced.

Reviewed changes — Reviewed the math-rendering dependency update, cache invalidation, comment anchoring, documentation, and regression coverage.

  • Math rendering: Updates the Comark packages to the build that preserves server-rendered MathML through sanitization and accepts display math when publishing.
  • Rendering compatibility: Explicitly retains Kroki diagrams and invalidates existing Markdown renders with drop.23.
  • Formula comments: Filters non-rendered text, adds normalized quote matching, and places comment bubbles and suggestions outside MathML.
  • Documentation and validation: Documents the supported math syntax and adds render/lint/browser coverage; 46 focused tests, changed-file lint, Nuxt typecheck, and the Doctor gate passed.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using gpt-6.1-sol(xhigh) | 𝕏

Comment thread shared/plan-runtime.ts Resolved
Comment thread shared/plan-runtime.ts Resolved
onmax and others added 2 commits November 17, 2026 11:23
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…st invisible MathML

A quote matched in plain form (NFKC) only lands where its formula-only characters, such as 𝑘, fall in a formula, so
a comment on the k of $k$ no longer moves to the k of "stock" before it. Text under <mphantom>, which a selection
never quotes, is skipped like <annotation>.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Important

The new formula-only check also rejects ordinary Unicode prose in selections spanning math, leaving those comments unplaced.

Reviewed changes — Reviewed the dependency refresh and comment-anchor fixes added since the previous Pullfrog review.

  • Updated Comark dependencies to build c883574, including corrected entity escaping, formula-reference parsing, and case-insensitive component detection.
  • Restricted Normalized quote matches so rendered mathematical glyphs cannot match earlier prose, and added the stock/$k$ browser regression.
  • Excluded Phantom MathML text from quote lookup and extended browser coverage with $x\phantom{ABC}+y$.

Validated both previous fixes and resolved their threads. All 47 existing focused tests passed, along with changed-file lint, Nuxt typecheck, and Doctor; an additional Chromium round-trip reproduction confirmed the new defect inline.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using gpt-6.1-sol(xhigh) | 𝕏

Comment thread shared/plan-runtime.ts Resolved

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ No P0 or P1 findings remain; one P2 quote-restoration regression is noted inline.

Reviewed changes — Reviewed the dependency refresh and comment-anchoring fixes since cb6a6e4.

  • Updated Comark packages: Moved to c883574, including fixes for literal entity escaping, formula references, and cased component linting.
  • Restricted normalized matches: Required compatibility-transformed quote characters to match inside MathML, preventing the reported formula-letter collision with prose.
  • Excluded phantom text: Removed invisible mphantom content from quote matching and expanded the browser regression.
  • Validated behavior: Passed 46 focused tests, changed-file lint, Nuxt typecheck, and Doctor; independently checked runtime-reported selections and restored DOM ranges.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using gpt-6.1-sol(xhigh) | 𝕏

Comment thread shared/plan-runtime.ts Resolved

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found; no P0 or P1 findings remain.

Reviewed changes — Reviewed the quote-restoration fix and browser regressions added since 9003b73.

  • Preserved prose compatibility characters: Allowed normalized matches to retain identical original prose characters while keeping transformed formula letters off ordinary prose.
  • Added selection round-trip coverage: Verified runtime-reported quotes containing µ, ², and fi restore to the correct paragraph, alongside the existing formula-letter and phantom-spacing regressions.

All 47 focused tests passed, including the reviewed-site popover and HTML-frame tooltip suites; changed-file lint, Nuxt typecheck, and Doctor also passed.

Pullfrog  | View workflow run | Using gpt-6.1-sol(xhigh) | 𝕏

@vite-hub
vite-hub Bot merged commit f74e964 into main Nov 17, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant