streamdown package. These are useful when building custom streaming UIs, pre-processing content before rendering, or integrating Streamdown features into your own components.
parseMarkdownIntoBlocks()
The Markdown source string to split.
string[] — an array of block strings. Each block retains its original whitespace and newlines.
Special cases
- Footnotes — if the document contains any footnote references (
[^1]) or definitions ([^1]: ...), the entire document is returned as a single block. Footnote references and definitions must share the same mdast tree to resolve correctly. - Math blocks — consecutive blocks are merged when the accumulated text contains an odd number of
$$markers (indicating an unclosed block math expression). This handles cases wheremarked’s lexer splits math blocks across multiple tokens. - HTML blocks — consecutive tokens are merged when they are inside an unclosed HTML tag pair, tracking nesting depth to avoid premature closure.
Example
Custom block parser
You can replace the built-in block parser by passingparseMarkdownIntoBlocksFn to <Streamdown>:
normalizeHtmlIndentation()
The raw HTML/Markdown string to process.
This function is a no-op unless the content starts with an HTML tag. It only strips indentation from lines where the first non-whitespace content is an HTML tag — regular Markdown content is not affected.
Usage
Enable normalisation on<Streamdown> with the normalizeHtmlIndentation prop (disabled by default):
detectTextDirection()
The Markdown string to analyse.
"rtl" if the first strong directional character falls in a right-to-left Unicode range (Hebrew, Arabic, Syriac, Thaana, NKo, Samaritan, Mandaic, Arabic Supplement/Extended, or RTL presentation forms). Returns "ltr" otherwise, including when no directional character is found.
Usage with Streamdown
Passdir="auto" to <Streamdown> to enable per-block direction detection:
detectTextDirection. The detected direction is applied as the dir attribute on a display: contents wrapper <div>.
Example
useIsCodeFenceIncomplete()
true when the code fence in the current block has not yet been closed — i.e. Streamdown is actively streaming content into it.
This hook reads from BlockIncompleteContext, which is set by the Block component. It is only meaningful inside components rendered within a Streamdown Block.
When to use
Use this hook inside a custom renderer (viaplugins.renderers) or a component rendered inside a code block to defer expensive operations until the code is complete:
The
isIncomplete prop on CustomRendererProps carries the same value as this hook and is available directly in custom renderers without needing to call the hook.