Skip to content

fix(app): a math or latex code block of equations draws as typeset math - #108

Merged
sean-brydon merged 2 commits into
mainfrom
fix/math-code-blocks
Oct 14, 2026
Merged

sean-brydon merged 2 commits into
mainfrom
fix/math-code-blocks

Conversation

@sean-brydon

Copy link
Copy Markdown
Collaborator

Asked for physics maths, an agent on cal answered with a ```latex code block, and the chat showed it as code. Math only drew from $$…$$, `(…)` and `[…]` in the reply's text, so code blocks of maths stayed code. That reply was actually a whole `physics.tex` document to compile with `pdflatex`.

Now (lib/markdown-html.ts, after micromark, through the same placeholder path as $$ blocks):

  • A ```math block draws as display math. That's GitHub's syntax for a formula.
  • A latex, tex or ```katex block draws as display math too, unless it looks like a document: \documentclass, `\usepackage`, `\begin{document}`, `\section`, `\title`, `\item` and the like. A document stays code, since it's meant for `pdflatex`.
  • A block that hasn't closed yet, in a reply still being written, stays code until it does. A half-written formula would only show KaTeX's errors.
  • Other languages and unnamed blocks are unchanged.

Proof: the app on mock data, a reply with a math block, a latex block of one equation, and a ```latex document.

Berth Light Berth Dark

Checks

  • markdown-html.test.ts: new cases cover math blocks, latex/tex equations, HTML escapes undone (<, &), documents and \section staying code, other languages untouched, and an open block in a draft.
  • e2e/math.spec.ts: a new browser test passes, and the old one still does.
  • tsc, check:titles, check:csp, pnpm test (441 tests), pnpm build, npx tsc -p e2e and the docs build pass.

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@vercel

vercel Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
berth Ready Ready Preview Oct 14, 2026 4:21pm UTC
berth-docs Ready Ready Preview Oct 14, 2026 4:21pm UTC

Request Review

@sean-brydon
sean-brydon merged commit 6f4d88e into main Oct 14, 2026
2 of 3 checks passed
@linear-code

linear-code Bot commented Oct 14, 2026

Copy link
Copy Markdown

ENG-6095

This branch was successfully deployed

2 active deployments
Preview – berth-docs — c2bc54cf Deployed Oct 14, 2026 by vercel[bot]
Preview – berth — c2bc54cf Deployed Oct 14, 2026 by vercel[bot]
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