@preferred-markdown-stream/renderer
v0.6.0
Published
Framework-agnostic streaming markdown render pipeline shared by the Vue and React packages
Readme
@preferred-markdown-stream/renderer
The framework-agnostic streaming Markdown pipeline shared by
@preferred-markdown-stream/vue and @preferred-markdown-stream/react.
Most applications should depend on one of those packages instead of this one.
It contains everything that is not framework-specific:
- the markdown-it renderer plugin that emits a node tree through a
TreeAdapter(each framework supplies one: Vue builds vnodes directly, React builds mutable intermediate nodes finalized into elements), - the frozen-prefix incremental renderer (
createIncrementalMarkdownRenderer), - the markdown runtime factory with lazy Shiki/KaTeX loading
(
createMarkdownRuntime), - the mermaid loader registry and progressive fence renderer
(
configureMermaid,createMermaidController), - code-block line splitting for per-line fade-in (
parseCodeBlockLines), - typewriter smoothing (
createSmoothStreamController).
Writing an adapter for another framework
Implement TreeAdapter<N> (see src/adapter.ts for the contract), create a
module-level runtime with createMarkdownRuntime({ adapter, codeBlockComponent,
mermaidComponent }), and drive createIncrementalMarkdownRenderer(runtime)
with (content, loading) on every stream update. The returned nodes reuse the
document's frozen prefix by object identity — keep handing them to your
framework unchanged and re-renders of settled content stay O(1).
Component styles (code block toolbar, mermaid container) are published via
@preferred-markdown-stream/renderer/styles.css; the fade-in animation itself
lives in @preferred-markdown-stream/core/styles.css.
