Expand description
Intermediate representation produced by crate::render_to_ir.
The shape mirrors the TypeScript IRDocument consumed by
afm-obsidian/src/ir/types.ts (and validated in
afm-obsidian/src/ir/from-wasm.ts). Keeping the names and field
ordering aligned across the FFI boundary makes the
serde-wasm-bindgen round-trip a pass-through, no shape adapters
needed.
§Coverage
- Markdown side: paragraphs, headings, lists, blockquotes,
fenced code, tables, thematic breaks. Inline runs preserve
Strong,Emphasis,Link,Code,LineBreak, and verbatimText. - Aozora side:
Ruby/DoubleRuby/Bouten/Tcy/Gaiji/Annotation(inline) andContainer/PageBreak/SectionBreak(block). Heading hints ([#「X」は大見出し]) promote their host paragraph toIrBlock::Headingdirectly, mirroringcrate::post_process.
§Architecture
The walker is built from three small primitives:
crate::sentinels::SentinelCursor— the shared registry-stream cursor. The HTML splicer (crate::post_process) and this builder both consume the same source-order sequence ofNodeRefentries; the cursor abstraction keeps them in lockstep.ParaScan— single-descent paragraph profile. One walk per paragraph computes both the sole-block-sentinel test and the heading-hint lookahead at once, eliminating the two-scan redundancy that a naive translation of the HTML splicer would have.OpenContainer— the per-walker container stack. Where the HTML splicer can stream open/close tags into a string buffer, the IR demands a tree, so each open container collectsIrBlocks into its ownVecuntil the matching close arrives. Move semantics (noclone) carry the children into the closedIrBlock::Container.
Structs§
- IrDiagnostic
- IrDocument
- IrList
Item - IrTable
Row - IrWalker 🔒
- Tree builder that consumes comrak nodes plus a sentinel cursor and
emits
IrBlocks into a stack-balanced container hierarchy. - Open
Container 🔒 - Para
Scan 🔒 - Collected paragraph properties. The walker computes this in one pass over the paragraph’s text descendants and dispatches off the result.
- Range
- Streaming
IrBuilder - Stateful per-block IR builder for streaming mode.
- Table
Meta 🔒
Enums§
Functions§
- annotation_
kind_ 🔒resolved - bouten_
kind_ 🔒str - bouten_
position_ 🔒str - build_
ir 🔒 - Walk a comrak AST root and project it to
IrDocument. - container_
indent_ 🔒level - container_
subtype 🔒 - content_
to_ 🔒string - place_
in 🔒 - Push
blockonto the top-of-stack open container’s children, or onto the document’s top-level blocks if no container is open. - project_
annotation 🔒 - project_
block_ 🔒leaf - project_
bouten 🔒 - project_
content_ 🔒inlines - project_
double_ 🔒ruby - project_
gaiji 🔒 - project_
inline 🔒 - project_
ruby 🔒 - project_
tcy 🔒 - resolved_
to_ 🔒string - section_
kind_ 🔒subtype - sourcepos_
to_ 🔒range - table_
align 🔒 - to_u32 🔒
- Saturating
usize → u32. Source line/column overflow requires~4G-line files, so saturating tou32::MAXis safe. - top_
metadata 🔒