Skip to content

Render LaTeX equations with KaTeX in Content#2131

Open
3mdistal wants to merge 5 commits into
BuilderIO:mainfrom
3mdistal:codex/content-katex-equations
Open

Render LaTeX equations with KaTeX in Content#2131
3mdistal wants to merge 5 commits into
BuilderIO:mainfrom
3mdistal:codex/content-katex-equations

Conversation

@3mdistal

Copy link
Copy Markdown
Contributor

Summary

  • render canonical inline and block LaTeX with KaTeX in editable documents and read-only/public readers
  • render equations in standalone HTML and PDF-ready exports while preserving canonical source in Markdown
  • keep malformed equations visible and repairable, with KaTeX trust disabled and accessible MathML output
  • document the syntax for agents and add a Content changelog entry
  • cover rendering, security, editing, copy/paste, export, and NFM round-trips

Why

Content already parses inline $...$ and block $$ delimiters into structured NFM atoms, but those atoms were displayed as plain labels. This completes the presentation and export layers without changing the canonical source format or adding a second math grammar.

Validation

  • 225 focused Vitest tests passed across math rendering, exports, NFM, editor interactions, and the public route
  • production Content build passed and bundles KaTeX for client and server rendering
  • frozen lockfile install and diff checks passed
  • independent real-Chrome QA passed inline, display, malformed-source fallback, terminal-caret editing with refresh persistence, accessibility exposure, and narrow-viewport math overflow
  • repository-wide typecheck still reports 152 pre-existing errors; none reference changed files

Notes

The local-file page actions menu does not expose HTML/PDF export, so export output is covered by focused integration tests rather than manual download QA.

@netlify

This comment has been minimized.

@netlify

This comment has been minimized.

@netlify

This comment has been minimized.

@github-actions

github-actions Bot commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Here's a visual recap of what changed:

Visual recap

Open the full interactive recap

builder-io-integration[bot]

This comment was marked as outdated.

builder-io-integration[bot]

This comment was marked as outdated.

@builder-io-integration builder-io-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Builder reviewed your changes and found 3 potential issues 🟡

Review Details

Incremental Code Review Summary

The latest commit fixes both previously open findings: escaped delimiter parity is now handled, and indented display equations are retained inside list items. I resolved those two stale review threads before this review. The broader approach remains sound: KaTeX is shared across editor and export paths, SSR markup is emitted during render, and malformed expressions remain visible rather than being discarded.

New Findings

  • 🟡 MEDIUM — Same-type nested bullet lists are still flattened because the collector treats any indented matching marker as a sibling.
  • 🟡 MEDIUM — Inline code spans ending in a backslash no longer close correctly because code-fence detection applies Markdown escape parity inside code content.
  • 🟡 MEDIUM — A malformed inline math opener can skip a backslash-adjacent closing delimiter and then consume a later code span, corrupting the remainder of the paragraph.

The change remains standard risk, centered on shared export parsing and user-facing document structure. The dev server is healthy. Full browser verification was attempted, but executor sessions still lacked browser navigation/DOM/screenshot tools; static/unit checks covered the main rendering paths but could not validate these live export edge cases.

🧪 Browser testing: Could not verify — browser automation tools were unavailable in the executor environment; all planned cases were environment-blocked.

Comment thread templates/content/shared/document-export.ts Outdated
Comment thread templates/content/shared/document-export.ts Outdated
Comment thread templates/content/shared/document-export.ts Outdated
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