Skip to main content

parse_with_config

Function parse_with_config 

Source
pub fn parse_with_config(markdown: &str, config: &ParseConfig) -> Document
Expand description

Parse markdown into a typed Document.

This is the AST entry point. The input is post-resolve markdown (the upstream resolve pipeline has already rewritten wikilinks into standard markdown links with moss-resolved: prefixes).

Two-stage parse:

  1. [extract_shortcodes] pre-scans for :::name blocks, replacing each with a sentinel HTML comment.
  2. Pulldown-cmark parses the substituted markdown into events; each sentinel comes back as a Block::Other raw HTML.
  3. A final pass walks the AST and substitutes Block::Other sentinel payloads with the corresponding typed Block::Shortcode.

When config.emit_source_lines is true, the parser walks events via into_offset_iter() so each top-level block carries the byte offset of its first event; a [LineLookup] converts the offset to a 1-based line number stored in BlockMeta::source_line.