Skip to main content

create_link_anchors

Function create_link_anchors 

Source
pub fn create_link_anchors(
    document: &mut HtmlDocument,
    targets: &FxHashSet<Location>,
) -> FxHashMap<Location, EcoString>
Expand description

Attaches IDs to nodes produced by link targets to make them linkable.

The targets set should contain the locations of all elements in the HTML document that are linked to from somewhere.

May produce <span>s for link targets that turned into text nodes or no nodes at all. See the LinkElem documentation for more details.

Anchor ID generation attempts to use existing HTML element IDs and Typst labels to generate human-readable fragment names. If a label occurs multiple times, it’s disambiguated with a suffix. This disambiguation is per document, even in bundle output. It uses the document’s own introspector.