Skip to main content

render_blocks_to_ir

Function render_blocks_to_ir 

Source
pub fn render_blocks_to_ir(
    input: &str,
    options: &Options<'_>,
) -> (Vec<RenderedBlock>, Vec<Diagnostic>)
Expand description

Per-block streaming render.

Produces one RenderedBlock per top-level comrak child, in document order. Used by afm-obsidian’s chunked-cancellation path (ADR-0009): the JS bridge can iterate the returned vector and check its AbortSignal between blocks.

The current implementation parses the document once (a single comrak pass) and renders each top-level block’s HTML separately using comrak::format_html. Diagnostics from the lexer are returned alongside the blocks, attached to the document as a whole rather than per-block (the lexer pass is non-block-scoped).

Limitation: container constructs that span multiple top-level blocks (e.g., [#ここから2字下げ][#ここで字下げ終わり]) are emitted as separate blocks; the consumer is responsible for re-assembling them. The whole-document render_to_ir path preserves cross-block structure if you need it.