heading_slug
The anchor GitHub gives to a heading: "Hello, World!" becomes "hello-world".
The text is trimmed and lowercased, letters (any language), digits, - and _ are kept, every
whitespace character becomes a - (they are not merged, so "a b" is "a--b"), and
everything else is dropped. Unlike slugify
it follows GitHub’s rules rather than making a tidy slug, so use it to build the #fragment of a
link to a heading. Two headings with the same text get a numeric suffix on GitHub; that part
needs the whole document and is left to you.
Import
Section titled “Import”Cargo feature markdown (enabled by default). To compile only this module:
or in Cargo.toml:
Signature
Section titled “Signature”Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
heading | &str | The text of the heading, without the leading #s. |
Returns
Section titled “Returns”String — The anchor, without the leading #.
