Skip to content

fix: rendering for model-emitted bracketed math blocks - #595

Merged
agegr merged 2 commits into
agegr:mainfrom
baisechundu:fix/markdown-loose-bracket-math
Aug 25, 2026
Merged

fix: rendering for model-emitted bracketed math blocks#595
agegr merged 2 commits into
agegr:mainfrom
baisechundu:fix/markdown-loose-bracket-math

Conversation

@baisechundu

Copy link
Copy Markdown

Summary

Fix rendering for model-emitted display math blocks written as standalone bracketed lines.

Some models emit formulas like this:

[ C(x) = \frac{2}{T(T-1)} \sum_{i<j} S(\hat{y}^{(i)}, \hat{y}^{(j)}) ]

Pi Web previously rendered that as plain text. This change normalizes likely math-only bracket lines into standard display
math before Markdown parsing:

$$
C(x) = \frac{2}{T(T-1)} \sum_{i<j} S(\hat{y}^{(i)}, \hat{y}^{(j)})
$$

Expected rendered result:

$$C(x) = \frac{2}{T(T-1)} \sum_{i<j} S(\hat{y}^{(i)}, \hat{y}^{(j)})$$

Changes

  • Normalize standalone [ ... ] lines that look like math into display math fences.
  • Leave ordinary bracket-only prose unchanged.
  • Add regression tests for normalization and KaTeX rendering.

Test Plan

node --experimental-strip-types --test components/MarkdownBody.test.mjs lib/markdown.test.mjs
node_modules/.bin/tsc --noEmit
git diff --check -- lib/markdown.ts components/MarkdownBody.test.mjs lib/markdown.test.mjs

@baisechundu baisechundu changed the title Fix rendering for model-emitted bracketed math blocksFix loose bracket math rendering Fix rendering for model-emitted bracketed math blocks Aug 25, 2026
@baisechundu baisechundu changed the title Fix rendering for model-emitted bracketed math blocks fix: rendering for model-emitted bracketed math blocks Aug 25, 2026
@agegr
agegr merged commit 5f35d6f into agegr:main Aug 25, 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.

2 participants