Skip to content

Add LaTeX math support to markdown rendering - #42

Open
tlehman wants to merge 1 commit into
kriswill:mainfrom
tlehman:latex-math
Open

Add LaTeX math support to markdown rendering#42
tlehman wants to merge 1 commit into
kriswill:mainfrom
tlehman:latex-math

Conversation

@tlehman

@tlehman tlehman commented Sep 2, 2026

Copy link
Copy Markdown

Summary

Renders LaTeX math in the viz-app markdown pipeline via KaTeX.

  • Inline math: $…$ and \(…\). Code spans are skipped verbatim, so `$5 and $7` stays literal; unpaired delimiters and prose like "$5 to $10" stay literal too. \$ is an escaped literal dollar.
  • Display math: $$…$$ and \[…\], either on one line or spanning several. Checked before fences/lists so a line starting with $$ never falls through to paragraph text; an unterminated block still renders what it collected.
  • Rendered math is parked behind NUL placeholders through the inline pipeline, so the escaping/bold/link passes never see KaTeX markup.
  • throwOnError: false — one bad formula renders as KaTeX's error markup instead of taking down the document.
  • MathML output is kept alongside the visual HTML for screen readers and copy-paste.

The viewer is a single-file page, so KaTeX's stylesheet is inlined with its woff2 faces as data URIs; the woff/ttf fallbacks (same glyphs, ~4x the bytes) are dropped.

image

Test plan

viz-app/markdown.test.ts adds coverage for inline/display delimiters, code-span and currency false positives, escaped dollars, and unterminated blocks.

🤖 Generated with Claude Code

https://claude.ai/code/session_01U3GB2wFs7izFyFGjPmYnMQ

@tlehman tlehman changed the title Add LaTeX math support to markdown rendering Add $\LaTeX math support to markdown rendering Sep 2, 2026
@tlehman tlehman changed the title Add $\LaTeX math support to markdown rendering Add $\LaTeX$ math support to markdown rendering Sep 2, 2026
@tlehman tlehman changed the title Add $\LaTeX$ math support to markdown rendering Add LaTeX math support to markdown rendering Sep 2, 2026
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