Repository navigation
fix(math,lint): keep formulas through Comark's security plugin, and lint display math clean - #449
Conversation
…int display math clean
comark-mathml carried each formula's MathML in an `html` prop. Comark's security plugin removes every
`*html` prop as a markup sink, so with `security({ allowedTags })`, the setup the docs recommend, every
formula fell back to its TeX. The MathML now reaches the renderers as the formula's children, elements
that security checks one by one, and `comarkUi().tags` lists them. A formula a document writes itself
loses its content, as its `html` already did.
comark-linter counted the block comark-mathml makes from `$$` and math fences as an authored component,
so a host that lints with its components refused display math as `::comark-mathml-2`. Only a block whose
line writes `:name` is checked now.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codex Review Summary: ❌ FailedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
comark-annotate
comark-badge
comark-bundle
comark-cards
comark-carousel
comark-cast
comark-charts
comark-chat
comark-chips
comark-cjk
comark-code
comark-code-notes
comark-colors
comark-comments
comark-critic
comark-deflist
comark-details
comark-diagrams
comark-diff
comark-embed
comark-fields
comark-figure
comark-file-tree
comark-footnotes
comark-git-graph
comark-github
comark-icon
comark-include
comark-keys
comark-links
comark-linter
comark-magic-move
comark-mark
markdown-it-to-comark
marked-to-comark
comark-mathml
comark-media
comark-metrics
migrate-to-comark
comark-outline
comark-properties
comark-qr
comark-quiz
comark-reading-time
remark-to-comark
comark-sources
comark-steps
comark-table
comark-tabs
comark-tests
comark-time
comark-ui
comark-xref
comark-zoom
commit: |
There was a problem hiding this comment.
Important
The security fix works for the covered formulas, but the new rendering path breaks Svelte client math and its TeX fallback, and the lint filter skips authored PascalCase components. Two additional round-trip defects affect formula content.
Reviewed changes across both commits, including the math AST conversion, all renderer entries, security allowlists, and component linting.
- Formula representation: Typeset markup moves from
htmlinto child nodes, with authored formula content rejected. - Rendering and security: HTML serializes those children without added whitespace; Vue, React, and Svelte render them as children, and the preset exposes the required element allowlists.
- Component linting: Source matching excludes plugin-generated blocks from unknown-component diagnostics.
- Coverage and documentation: Added math/security and lint regressions, updated framework parity handling, and documented standalone allowlist registration.
Validation: the workspace build, TypeScript check, math/lint/UI suites, Doctor examples, and math/lint package Doctor checks pass. Focused public-interface reproductions expose the findings below; Svelte client namespace checks used instrumented DOM creation rather than visual browser testing.
gpt-6.1-sol(xhigh) | 𝕏
Latest result Pull request merged. Final answersSession Pull request merged. Session Pass interrupted; current webhook state retained. Session Pass interrupted; current webhook state retained. Session Pass interrupted; current webhook state retained. |
…sed components - Svelte: a typeset formula carries `typeset`, since @comark/svelte always passes a children snippet, so a formula that didn't typeset shows its TeX again. @comark/svelte's <svelte:element> gives MathML's tags the HTML namespace in the browser, so a formula made there is parsed again into a MathML copy shown in place of Svelte's own. - The HTML renderer escapes every `&` in a formula's decoded text and its TeX, so `\verb|<|` shows `<`. - The markup reader takes single-quoted attributes, as Temml writes for `\ref`, and closes only the element that's open, so a reference no longer breaks the rest of its formula. `a` joins MATHML_TAGS. - The linter compares a block with the names its line writes in kebab case, so `::Screnshot` and `:Screnshot[x]` are still reported. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…hromium is installed Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… too The copy that fixes the namespace now follows the span with Svelte's render through an effect, so a formula that starts as TeX and typesets after an update gets it as well. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Important
Reactive Svelte updates can display a previous formula, and the new browser test fails in the existing CI check job.
Reviewed changes in 24bf309 since the previous Pullfrog review.
- Normalized authored names: Compared source component names and token names using the same casing normalization while retaining the generated-math exclusion.
- Preserved formula content: Added strict HTML escaping, single-quoted attribute parsing, matched closing tags, and reference-anchor allowlisting.
- Reworked Svelte rendering: Added an explicit
typesetflag and browser-parsed MathML copies synchronized with a mutation observer. - Expanded regression coverage: Added literal-entity, reference, PascalCase-component, Svelte SSR, and Chromium namespace tests.
Validation: workspace build, TypeScript, math/lint/UI suites, and math/lint Doctor checks pass locally after browser installation and dependency preparation. Independent Chromium document-update reproductions expose the stale-formula defect; current-head CI logs confirm the missing-browser failure.
gpt-6.1-sol(xhigh) | 𝕏
…MathML Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
✅ No new issues found; no P0 or P1 findings remain.
Reviewed changes since the previous Pullfrog review at 24bf309, including the additional regression commit that landed during this run.
- Moved browser coverage: Relocated Chromium checks to the provisioned E2E suite, retained browser-free SSR coverage, and extracted the shared Svelte bundling helper.
- Bound synchronization to element lifetime: Replaced one-time initialization with a reactive effect that clears stale copied markup, observes replacement elements, and disconnects previous observers.
- Added reactive regressions: Covered invalid-to-valid updates and valid → invalid → different-valid updates, checking native MathML namespaces and the final visible token.
Validation passed: workspace build, all 25 math tests, the Svelte E2E test, TypeScript, and math Doctor. Independent Chromium checks also passed repeated formula replacement and removal; the SSR test passed with its browser path pointed at an empty location.
gpt-6.1-sol(xhigh) | 𝕏
There was a problem hiding this comment.
✅ No new issues found. No P0 or P1 findings remain.
Reviewed changes in the commits since the previous Pullfrog review at 24bf309.
- Moved browser coverage: Relocated Chromium checks into the existing browser-provisioned E2E pipeline while retaining server-rendering coverage in the unit suite.
- Fixed reactive MathML synchronization: Bound copied markup, state reset, and observer cleanup to the lifetime of the rendered element using
$effect. - Added document-update regressions: Covered broken-to-valid namespace preservation and verified that
$a$→ broken TeX →$b$visibly renders the newb.
Validation passed: workspace build, math/lint/UI suites, Chromium E2E coverage including five repeated runs, TypeScript, focused lint, and math/lint Doctor checks.
gpt-6.1-sol(xhigh) | 𝕏
* feat: render LaTeX math in Markdown docs 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> * chore: run on comark-ui #449 c883574 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(viewer): keep a formula's comment on the formula, and place it past 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> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: vite-hub[bot] <320448255+vite-hub[bot]@users.noreply.github.com>

With Comark's
securityplugin, every formula renders as its TeX in monospace.comark-mathmlpassed the typeset MathML to the renderers in anhtmlprop.securitydrops every*htmlprop as a markup sink, so the formula reaches the renderer with only itstex. The getting-started guide recommendssecurity({ allowedTags: [...tags, ...Object.keys(components)] }), so any host that follows it loses its math. Drop runs this setup and hits it.This PR puts the MathML in the tree as the formula's children.
securitychecks those elements and their attributes like the rest of the document, andcomarkUi().tagslists them: Temml's elements, plus KaTeX'sspan/svgones whenoutputisn't"mathml".comark-mathmlexports them asMATHML_TAGSandKATEX_TAGSfor hosts that don't use the preset. The HTML renderer writes the MathML without the indentation Comark adds to elements it doesn't know, so the output matches the old markup. The Vue, React and Svelte components render their children. Aformulaa document writes itself loses its content, the same way it already lost itshtml.In Svelte, a typeset formula carries
typeset: true, because@comark/sveltealways passes a children snippet.@comark/sveltealso creates every element with<svelte:element>, which gives MathML the HTML namespace in the browser. So a formula mounted on the client is parsed again into a MathML copy, shown in place of Svelte's own and kept in sync. Server HTML already parses as MathML. The real fix is anxmlnsin@comark/svelte: comarkdown/comark#602. Once that's released, the copy can go.It also fixes
comark-linter. It counted the block thatcomark-mathmlmakes from$$andmathfences as an authored component. A host that lints with its own component list, as Drop does before publishing, rejected display math as::comark-mathml-2` is not a known component. The linter now checks a block only when its line writes:name.The new tests fail on
mainand pass here, includinge2e/math-svelte.e2e.ts, which mounts and updates a doc in Chromium. The math, lint and ui suites,tsrs --noEmit, and doctor for both packages pass.Drop moves onto this build in vite-hub/drop#218. Evidence from Drop: https://drop.vitehub.dev/d/ytyz8f3ce9sw/before-after
Breaking for anyone who reads a formula's
htmlattribute directly, since it's no longer set.🤖 Generated with Claude Code