Skip to main content

link_spans

Function link_spans 

Source
pub fn link_spans(
    body: &str,
    format: ContentFormat,
) -> Result<Vec<Range<usize>>>
Expand description

The byte ranges in body that twig parses as inline links — the whole [text](target) construct of each link node, in source order. This is the syntax-aware, code-aware complement to prov’s lexical [[…]] scan: twig never reports a [x](y) inside a code fence, an autolink’s angle brackets, or bracket text that is not actually a link, so a body-link scan built on these spans cannot mistake prose or code for a link. The caller slices each span and parses it with crate::link::Link::parse to read the target — each span holds exactly one link, so the parse never over-reaches.

Reference-style and autolink forms also surface as link nodes; the caller keeps only the inline [label](target) ones (a successful markdown parse), which is the form prov can resolve and rewrite in place.

Links inside a footnote definition are included, which a walk from the document root does not reach — see spans_where.