Streaming Markdown
Render Markdown incrementally as tokens arrive, powered by
streaming-markdown. It parses only the new text and
appends DOM nodes per chunk — no per-token re-parse, no innerHTML rebuild.
npm install @aparte/plugin-streaming-markdown @aparte/core streaming-markdown@aparte/core and streaming-markdown are peer dependencies.
import { setupStreamingMarkdownProvider } from '@aparte/plugin-streaming-markdown';
setupStreamingMarkdownProvider();Call it once at startup. It fills the AparteConfig.setStreamingMarkdownProvider seam, which the chat
bubble uses while a message is streaming. Pair it with marked — the one-shot
provider re-renders the finished message at full fidelity.
Security
Section titled “Security”The streaming path writes DOM nodes directly, so it bypasses the one-shot HTML sanitiser. To keep the
same URL policy live, the plugin drops any href/src whose scheme fails core’s isSafeUrl as it
streams — a [x](javascript:…) token never becomes a clickable javascript: link, even if the scheme
is split across two chunks. The one-shot re-render at completion remains the full re-sanitisation.