Skip to content

Render LaTeX equations with KaTeX in Content#2131

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

Render LaTeX equations with KaTeX in Content#2131
3mdistal wants to merge 4 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

Visual recap — generation failed

The visual recap could not be generated for this pull request. This is informational only and does not block the PR.

Diagnostic:

No plan URL: create-visual-recap failed 422 Unprocessable Entity: {"error":"Could not parse expression with acorn"}

Agent output: Authored recap-source.json for PR #2131. It includes the full file map, editor/error wireframes, rendering-flow diagram, and five key-code review tabs. --- ⠀ 🟢 Visual Recap source is ready for CI’s deterministic publisher. stderr: Reading additional input from stdin... 2026-07-14T21:59:55.281064Z ERROR codex_core::session::session: failed to load skill /home/runner/work/agent-native/agent-native/.agents/skills/agent-native-toolkit/SKILL.md: missing YAML frontmatter delimited by ---

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 2 potential issues 🟡

Review Details

Incremental Code Review Summary

The latest commit addresses both previously reported issues: MathRenderer now emits KaTeX markup during render for SSR/first paint, and the export parser protects inline math/code spans with collision-resistant placeholders so surrounding emphasis and links remain parseable. I resolved both prior review threads after verifying those changes in the latest diff. KaTeX remains configured with trust: false, accessible HTML+MathML output, bounded expansion, and visible malformed-source fallbacks.

New Findings

  • 🟡 MEDIUM — The placeholder scanner still tokenizes escaped $/backtick delimiters as real math or code syntax, so explicitly escaped literal examples can be transformed in HTML/PDF exports.
  • 🟡 MEDIUM — Display-math parsing is only handled by the top-level line walker; indented block equations under list items or nested structures can be emitted as sibling blocks and lose document structure.

This remains a standard-risk change affecting shared editor rendering and export behavior. The dev server is healthy, but browser executors again lacked navigation/DOM/screenshot tools; no live visual cases could be verified. Static/unit coverage exists for the main rendering and export paths, but not for these two new edge cases.

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

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