Expand description
Pre-parse extraction of :::shortcode blocks from markdown source.
Walks the markdown line-by-line, skipping the inert lines
crate::inert_regions reports (so :::buttons inside a code fence,
an indented code block, an inline code span or an HTML comment stays
literal text) and recognizing
:::name ...args / ::: openers/closers. Each block is replaced with
a sentinel HTML comment (<!--MOSS_SC_{nonce}_N-->) that pulldown-cmark
emits as a Block::Other raw HTML; the final parser pass walks the
AST and substitutes the sentinels with typed Shortcode variants.
Why this design:
:::block syntax is not standard CommonMark; pulldown-cmark sees it as plain text inside a paragraph. Post-parse text-matching is fragile (works only when the shortcode is the entire paragraph).- Pre-parse extraction with a sentinel is the same pattern Zola uses and preserves parsing correctness for adjacent content.
- The sentinel is an HTML comment so it survives pulldown-cmark intact
(pulldown-cmark passes HTML comments through
Event::HtmlasBlock::HtmlBlock).
Structs§
- Extracted
Shortcode - One extracted shortcode block, with its body parsed into a typed variant.
- Extraction
Result - Result of pre-parse extraction.
Functions§
- extract_
shortcodes - Walk the markdown line-by-line, replace
:::nameblocks with sentinels. - extract_
shortcodes_ with_ config extract_shortcodes, parsing shortcode bodies with the caller’sParseConfig.- parse_
apply_ args - Parse
:::apply {placeholder="..." button="..."}into a typed struct. - parse_
placeholder - Try to interpret a
Block::Otherpayload as a shortcode placeholder matching the givennonce. Returns theindexif it matches. - parse_
recent_ args - Parse
:::recent {since=... last=... count=...}body into a typed struct. - placeholder_
for - The sentinel HTML comment used to mark an extracted shortcode in the
markdown source. Pulldown-cmark emits these as [
Event::Html] inside a [Tag::HtmlBlock], which surfaces asBlock::Otherin our AST. - shortcode_
asset_ spans - Byte-offset asset paths inside
:::gallery/:::heroblocks.