Skip to main content

Crate afm_wasm

Crate afm_wasm 

Source
Expand description

WebAssembly bindings for afm-markdown.

Exposes a thin set of #[wasm_bindgen] exports that afm-obsidian (and other browser hosts) call across the WASM boundary. The IR shape returned by render_afm and render_aozora_only mirrors the TS IRDocument defined in afm-obsidian/src/ir/types.ts and is validated on the JS side by from-wasm.ts.

§Stability

Public exports here are version-pinned to afm-markdown’s workspace version. A bump on this crate implies an afm-obsidian recompilation against the new IR shape.

§Surface

  • init_panic_hook — opt-in panic forwarder (debug builds).
  • render_afm — full afm pipeline (CommonMark + GFM + aozora).
  • render_aozora_only — aozora-only inline mode (used by afm-obsidian’s inline post-processor; bypasses comrak).
  • hash_source — xxh3-64 over the source, returned as u64 for cache-key construction on the JS side.

Structs§

BlockResult 🔒
BlocksResult 🔒
DiagnosticOut 🔒
Wire-format projection of [Diagnostic] for the JS side.
RenderOptions 🔒
Optional render configuration accepted from JS. All fields are optional; missing fields fall back to Options::afm_default() (aozora on, anchors off).
RenderResult 🔒
Result envelope returned to JS. Matches the shape consumed by afm-obsidian/src/ir/from-wasm.ts.

Functions§

build_options 🔒
hash_source
xxh3-64 over the source, returned as a u64 (JS receives a bigint). Used for cache keys.
init_panic_hook
Install a console.error panic hook for friendlier debugging. No-op when compiled without the panic-hook feature.
render_afm
Render afm source to IR + HTML + diagnostics.
render_aozora_only
Render aozora-only inline text (no markdown re-parse).
render_blocks
Per-block streaming render.