Skip to content

fix(ui): render LaTeX-style inline math commands in chat markdown#5

Merged
albanm merged 3 commits into
mainfrom
chore-rendering
May 28, 2026
Merged

fix(ui): render LaTeX-style inline math commands in chat markdown#5
albanm merged 3 commits into
mainfrom
chore-rendering

Conversation

@albanm
Copy link
Copy Markdown
Member

@albanm albanm commented May 28, 2026

Translate common LaTeX inline-math commands ($\rightarrow$, $\times$, $\leq$, …) to Unicode glyphs before marked.parse, so model output that uses LaTeX renders correctly instead of showing literal $\rightarrow$.

Why: LLMs frequently emit LaTeX-style notation for arrows and math symbols, which marked passes through verbatim — visible as raw $\command$ in chat.

Regression risks:

  • Substitution runs on the raw markdown string, so it also rewrites $\command$ occurrences inside fenced code blocks and inline backticks. Acceptable for chat content, but if users paste LaTeX into a code sample it will be mangled. Move the substitution into a marked renderer hook if that becomes a problem.
  • Unknown LaTeX commands fall through unchanged (kept as $\foo$), so no silent data loss.

albanm and others added 3 commits May 28, 2026 17:24
Some models emit `$\rightarrow$` and similar LaTeX commands that marked
does not render. Substitute the common ones with their Unicode equivalent
before parsing.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@albanm albanm merged commit 18a337e into main May 28, 2026
4 checks passed
@github-actions github-actions Bot added the fix label May 28, 2026
@albanm albanm deleted the chore-rendering branch May 28, 2026 15:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant