use unicode_normalization::UnicodeNormalization;
pub fn slugify(input: &str) -> String {
let normalized = input.nfkd().collect::<String>().to_lowercase();
let mut slug = String::new();
for c in normalized.chars() {
if c.is_alphanumeric() {
slug.push(c);
} else if c.is_whitespace() || is_gfm_punctuation(c) {
slug.push('-');
}
}
slug
}
fn is_gfm_punctuation(c: char) -> bool {
matches!(
c,
'!' | '"'
| '#'
| '$'
| '%'
| '&'
| '('
| ')'
| '*'
| '+'
| ','
| '.'
| '/'
| ':'
| ';'
| '<'
| '='
| '>'
| '@'
| '['
| '\\'
| ']'
| '^'
| '_'
| '`'
| '{'
| '|'
| '}'
| '~'
| '-'
)
}