Repository navigation
Fixes #35450: render block-editor math with katex directly, drop react-latex-next - #35451
harsh-vador wants to merge 3 commits into
Conversation
…ex-next react-latex-next 3.0.0 (its latest release) bundles its own copy of katex 0.16.10, so bumping the katex package never changed the code that renders equations: only the stylesheet moved, leaving it out of step with the renderer. Render through katex's own auto-render instead, with the same delimiters react-latex-next used, and move katex to ^0.18.2. auto-render keeps the text outside the delimiters as text nodes, and malformed math still falls back to its source text.
❌ PR checklist incompleteThis PR cannot be merged until the following are addressed on its linked issue:
The fields live on the linked issue in the Shipping project (open the issue → right sidebar → Projects). After you set them, re-run this check (or push a commit) — issue/project changes do not re-trigger it automatically. Maintainers can bypass this check by adding the |
|
Hi there 👋 Thanks for your contribution! The OpenMetadata team will review the PR shortly! Once it has been labeled as Let us know if you need any help! |
main has since bumped katex to ^0.19.0 (#35282) but still ships react-latex-next, so its renderer stays on the bundled katex 0.16.10. Keep main's katex ^0.19.0 and drop only react-latex-next; the lockfile change is just its three blocks.
Sonar S7780: write the \( \) \[ \] delimiters with String.raw instead of escaped backslashes. The values are unchanged.
Code Review ✅ Approved🟡 Medium risk · Replacing react-latex-next with KaTeX auto-render changes equation parsing and error handling; delimiter differences could render stored descriptions incorrectly. Renders block-editor math with KaTeX's own auto-render in place of VerificationRules No rules evaluated Functional validation Not enabledAuto-approval Not enabledFor more verification details, comment OptionsDisplay: compact → Showing compact verification results. Comment with these commands to change the behavior for this request:
Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source |
|
🚦 Removed from the merge queue —
|



Describe your changes:
Fixes #35450
react-latex-next@3.0.0, its latest release, ships its own copy of katex 0.16.10 indist/index.js. That copy is what renders block-editor equations. Thekatexpackage only supplied the stylesheet. Bumpingkatex, as Dependabot tried in #34736, would have moved the CSS to a new version and left the renderer on 0.16.10. So the katex advisory fixed in 0.18.2 couldn't be cleared withkatexorresolutions.This PR:
katex/contrib/auto-renderinstead ofreact-latex-next. It uses the same delimiters ($$…$$,$…$,\(…\),\[…\]), so stored equations render as before. Text outside the delimiters stays as text, and malformed math falls back to its source text, as before.react-latex-next.mainhas since movedkatexto^0.19.0(build(deps): bump the npm-minor-patch group across 1 directory with 44 updates #35282) but still shippedreact-latex-next, so its renderer stayed on the bundled 0.16.10. With it gone, the stylesheet and the renderer both come from katex 0.19.0.KaTeX 0.17–0.19 list three breaking changes, and none affects us. The internal
__defineFunctionAPI changed (we don't use it). Internal CSS classes were renamed (nothing in the UI overrides them). Andstrictwarnings now cover missing character metrics (we don't configurestrict).Type of change:
High-level design:
N/A, small change: one component, its test, one Playwright assertion, and dependencies.
Tests:
Use cases covered
$$…$$and$…$equations render with KaTeX in the block editor and in the saved description, including after a reload.Unit tests
MathEquationComponent.test.tsx: thereact-latex-nextmock is gone, so the tests now run real KaTeX. Added: delimited math renders.katex, text outside the delimiters is rendered as text, and malformed math stays as its source text.Playwright (UI) tests
BlockEditorMathEquations.spec.tsnow also checks that KaTeX output (.katex) is shown after the save and reload, not just the node wrapper.make playwright_affectedselects 26 specs, becausepackage.json,yarn.lockand the component files are not in the impact map. Locally I ran the changed spec plus the 4 specs mapped to these files (they all render descriptions in the block editor). The remaining smoke and canary specs change global settings (access control, search RBAC, intake forms) or need Explore search, which this local backend can't provide; the merge queue runs the full suite.Branch merged with
mainatdcd6cd58d96(katex 0.19.0), served by Vite against a local server with CI's sample data loaded, in the classic shell,PLAYWRIGHT_IS_OSS=true,--retries=0 --workers=4, HTML reporter. Thesetup,entity-data-setupandentity-data-teardownsteps ran as dependencies, as in CI.Features/BlockEditorMathEquations.spec.tsFeatures/Table.spec.tsFeatures/Topic.spec.tsPages/CustomPropertiesApiContract.spec.tsPages/CustomProperties.spec.tsReport screenshot:
Manual testing performed
$$x^2 + y^2 = z^2$$math block plus text after it. The equation renders with KaTeX and the text appears as plain text.main's component for comparison: the equation renders, and the text after it is parsed as HTML.tsc(no errors in the changed files), ESLint, Prettier, andyarn ui-checkstyle:changed/ui-checkstyle:playwright:changed. All clean.UI screen recording:
Not applicable. This is a dependency and rendering fix with no new UI; the Playwright spec covers the rendered output.
Checklist:
Fixes <issue-number>: <short explanation>Fixes #<issue-number>above.🤖 Generated with Claude Code