Add markdown-to-HTML rendering for assistant messages using Markdig with HTML sanitization. Includes cached rendering to avoid lag during streaming, styled markdown elements (code blocks, tables, lists, blockquotes) within chat bubbles, and 18 unit tests covering rendering and XSS prevention. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1.2 KiB
1.2 KiB
Why
Assistant messages currently render as plain text — markdown formatting (bold, code blocks, lists, headings) from the LLM appears as raw characters. With Semantic Kernel and tool calling now in place, responses are increasingly structured and harder to read without proper rendering. Markdig 1.1.1 is already in the stack but not wired up.
What Changes
- Render assistant message content as HTML by converting markdown via Markdig
- Sanitize rendered HTML to prevent XSS (the LLM output is untrusted content)
- Style rendered markdown elements (code blocks, lists, tables) to fit the chat bubble aesthetic
- Keep user messages as plain text (they are short inputs, not markdown)
Capabilities
New Capabilities
rich-text-display: Markdown-to-HTML rendering pipeline for assistant messages, including sanitization and styling
Modified Capabilities
chat-ui: Assistant message display changes from plain text to rendered markdown
Impact
- ChatAgent.Client: Chat.razor message rendering, new markdown service, CSS additions
- Dependencies: Markdig already in stack spec; may need an HTML sanitizer package
- No backend changes — this is purely client-side rendering