Skip to main content

suffix_duplicate_heading_anchors

Function suffix_duplicate_heading_anchors 

Source
pub fn suffix_duplicate_heading_anchors(
    input: Vec<GutenbergBlock>,
) -> Vec<GutenbergBlock>
Expand description

Gives repeated heading anchors a -2, -3, … suffix so that every heading on the page renders a unique id. Duplicating a heading block copies its anchor, which is the usual way repeats end up on a page.

The first heading using an anchor, in document order, keeps it, so links to the original stay valid. A suffix is never one that another heading already uses. Anchors are compared trimmed, as the material renders them.