Render a finished chat reply as markdown

A reply streams as text as before; once it ends, the server renders it
with the model card's rules - raw HTML dropped, dangerous links emptied,
images as links - and the page places that. Headings, lists, tables and
code blocks read as they were written.

Maths outside code is set aside before the markdown, so its underscores
and asterisks are not taken for emphasis, and marked for the page to
typeset. KaTeX no longer searches the reply for delimiters, which took
"$5 and $10" for a formula. A reply that cannot be rendered stays
plain text, with the old search.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Ilker ManapandClaude Opus 5.5 committed 2026-09-28 22:44:18 +02:00
1 parent 9b663eb23c
commit 6b1f8b0827
7 files changed
+236 -7

No files matched your search

+16
View File
@@ -506,3 +506,19 @@ table.repo-files form.inline input[name=version] { width: 6.5rem; }
table.repo-files form.inline button { padding: .3rem .7rem; font-size: .8rem; }
table.repo-files td:last-child { width: 1%; white-space: nowrap; }
table.repo-files td:last-child .opt { display: block; margin-bottom: .2rem; }
/* A finished reply, rendered from markdown. Wrapping goes back to normal:
pre-wrap, right for text as it streams, doubles every gap between blocks. */
.bubble.md { white-space: normal; }
.bubble.md > :first-child { margin-top: 0; }
.bubble.md > :last-child { margin-bottom: 0; }
.bubble.md p, .bubble.md ul, .bubble.md ol, .bubble.md pre, .bubble.md table, .bubble.md blockquote { margin: .5rem 0; }
.bubble.md ul, .bubble.md ol { padding-left: 1.4rem; }
.bubble.md h1, .bubble.md h2, .bubble.md h3, .bubble.md h4 { margin: .8rem 0 .35rem; font-size: 1rem; }
.bubble.md h1 { font-size: 1.15rem; }
.bubble.md code { font-size: .85em; background: var(--card); padding: .05rem .3rem; border-radius: 4px; }
.bubble.md pre { white-space: pre; overflow-x: auto; background: var(--card); border: 1px solid var(--line);
border-radius: 6px; padding: .6rem .75rem; }
.bubble.md pre code { background: none; padding: 0; font-size: .82rem; }
.bubble.md table { width: auto; max-width: 100%; display: block; overflow-x: auto; font-size: .85rem; }
.bubble.md th, .bubble.md td { padding: .25rem .6rem; border-bottom: 1px solid var(--line); }
.bubble.md blockquote { border-left: 3px solid var(--line); padding-left: .75rem; color: var(--muted); }