pub fn slugify_heading(text: &str) -> StringExpand description
Convert a markdown heading line (“## 1. Tree-sitter, core”) into the GitHub-style slug (“1-tree-sitter-core”) used for intra-doc anchor links. Algorithm:
- Strip the leading
#s + any whitespace. - Lowercase.
- Drop any non-alphanumeric / non-hyphen / non-space character (punctuation, fences, parens, periods, etc.).
- Collapse whitespace runs to a single hyphen; collapse hyphen runs to a single hyphen.
- Trim leading / trailing hyphens.
Matches the slugs GitHub renders for # Heading blocks so links
authored against rendered docs work in-editor too.