Crate wpslugify

Crate wpslugify 

Source
Expand description

§Wordpress-style slugification

This library provides a simple slugification algorithm that is a close-as-possible direct port of the WordPress sanitize_title_with_dashes() function that WordPress uses to generate slugs.

Examples:

assert_eq!(slugify("This is a test."), "this-is-a-test");
assert_eq!(slugify("This is a <script>alertslugify('!')</script> test"), "this-is-a-test");
assert_eq!(slugify("Excellent!!!1!1"), "excellent-1-1");
assert_eq!(slugify("user@example.com"), "user-example-com");

This slugification feature leaves UTF-8 that is within the Unicode {Alphabetic} properties class intact. Yes, there’s really a band with this name:

assert_eq!(slugify("Töxic Tësticle Färm?"), "töxic-tësticle-färm");

Functions§

sanitize_and_split
Sanitize a string and return an array of the atomized words, all lowercased. This function is here because there are other uses for slugified titles than just as slugs, and clients may want to limit the length of a slug, remove stopwords or just “a|an|the” language articles, or other modifications.
slugify
Sanitize a string and return the string lowercased with a single hyphen between the words.