Function sanitize_id

Source
pub fn sanitize_id(text: &str) -> String
Expand description

Sanitize a string for use as an HTML ID

Converts a string to lowercase, replaces spaces with hyphens, and removes any characters that aren’t alphanumeric or hyphens.

§Arguments

  • text - The text to sanitize

§Example

let id = pulldown_html_ext::utils::sanitize_id("Hello World! 123");
assert_eq!(id, "hello-world-123");