Expand description
Read-only reference extraction for linting. Walks a document body and reports every wikilink, markdown link/image, heading, fenced code block and directive with (approximate, see below) 1-based source positions — without touching the render/build path.
Positions: comrak populates sourcepos on AST nodes during parsing, so
lines come straight from the AST. Two approximations apply:
- Wikilink
colis the start column of the folded Text/HtmlInline run that contains the[[…]], advanced by the character offset of the link within that run. Markdown escapes or entity references consumed by the parser can make this drift a little within the line; the line is exact. - Lines inside a block directive’s body are the directive’s opening line
plus the 1-based line within
inner_md— exact for the common case, but nested rewrites deeper down inherit the same additive scheme, so treat inner positions as best-effort.
Directive extraction runs first (via directivepass::extract), so
everything the render pipeline would treat as directive content is reported
under its directive, and sentinel-substituted lines are re-padded so the
content after a block directive keeps its original line numbers.
Structs§
- Directive
Ref - One directive occurrence (block or leaf).
- DocRefs
- Every reference found in one document body.
- Fence
Ref - One fenced code block (indented code blocks are not reported).
- Heading
Ref - One heading, any level h1–h6.
- MdLink
Ref - One markdown link or image, url as written.
- Wikilink
Ref - One
[[target#anchor|label]]wikilink occurrence.
Functions§
- extract_
refs - Extract all references from a markdown body (frontmatter already stripped). Read-only: shares parsing helpers with the render path but never mutates render behavior. Directive bodies are recursed into; their references are reported with lines offset by the directive’s opening line.