Render assistant Markdown and LaTeX as sanitized HTML with native MathML
Server-side rendering keeps the browser free of any Markdown/MathJax toolchain (single-binary). New src/render.rs: pulldown-cmark (tables/strikethrough/math) + pulldown-latex -> MathML Core. Safety: raw HTML events are escaped to text (pulldown-cmark 0.13 has no ENABLE_HTML opt-out) and link/image URLs pass a scheme allowlist (javascript:/data:/vbscript: stripped, control chars removed). content_html is added to get_messages (assistant only) and to the agent Final SSE event; the GUI injects it via innerHTML for assistant bubbles (history + live) while user text stays textContent. CSS styles Markdown and native MathML; block math must not override display (UA block math layout) or it collapses to vertical stacks. 10 render unit tests incl. XSS; 136 tests green, clippy/fmt clean; verified live + visually.
This commit is contained in:
1 parent
d1b56d2c23
commit
7dd66ea138
7 files changed
+386
-13
No files matched your search
@@ -26,6 +26,8 @@ tracing-subscriber = { version = "0.3.23", features = ["env-filter"] }
|
||||
rusqlite = { version = "0.32", features = ["bundled"] }
|
||||
# Embeds the web/ GUI assets into the binary (single-binary, offline-capable).
|
||||
rust-embed = "8"
|
||||
pulldown-cmark = "0.13.6"
|
||||
pulldown-latex = "0.8.0"
|
||||
|
||||
[dev-dependencies]
|
||||
http-body-util = "0.1.5"
|
||||
|
||||
Reference in new issue
Block a user