feat(frontend): per-message markdown rendering

Self-contained, HTML-escaped (XSS-safe) markdown for history messages;
each message rendered independently so a syntax error (e.g. unclosed
code fence) cannot leak into the next message.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
h z
2026-05-15 15:47:02 +01:00
parent 8272ed495e
commit 24eb458621
3 changed files with 72 additions and 1 deletions

View File

@@ -2,6 +2,7 @@ import axios from 'axios'
import { io, type Socket } from 'socket.io-client'
import { useEffect, useMemo, useState } from 'react'
import { useAuth } from '../auth/auth-context'
import { renderMarkdown } from '../lib/markdown'
import { guildMembersCenter, joinGuildCenter } from '../lib/center-auth-client'
type MessageItem = {
@@ -470,7 +471,7 @@ export default function ChatPage() {
<span className={`meta-badge ${m.wakeup ? 'on' : ''}`}>wakeup={String(m.wakeup)}</span>
) : null}
</div>
<div className="text">{m.content}</div>
<div className="text md" dangerouslySetInnerHTML={{ __html: renderMarkdown(m.content) }} />
{devMode ? (
<pre className="meta-raw">
{JSON.stringify(