Hwaro::Content::Processors::HeadingIds
Instance methods
assign(title_text : String, existing_id : String | Nil, used_ids : Set(String), id_counters : Hash(String, Int32)) : String
Assigns a unique id for one heading, mutating used_ids/
id_counters (shared, document-scoped state threaded across every
heading of one page) so later calls see this id as taken.
title_text is the heading's plain-text title — tags stripped,
HTML entities still escaped (as post_process_html extracts it
from the rendered inner HTML). existing_id is the heading's own
id="..." attribute when it already has one (a custom {#id},
or — on the hook path — an id a hook template already emitted);
when present it's used as-is instead of slugifying the title.
Dedup: a collision appends -1, -2, ... via id_counters
(O(1) amortized instead of re-scanning used_ids for a free
suffix).