A Python implementation of skeddles/sluggify for generating URL slugs
The following manipluations are performed in this order:
- replace slashes
/\and spaceswith dashes- - replace any accented characters with their closest non-accented equvalent, e.g.
ébecomese - remove all non-alphanumeric characters (anything other than
A-Z,a-z,0-9, and-) - replace multiple consecutive dashes
---with a single dash- - remove leading dashes, e.g.
-Gengar-becomesGengar- - remove trailing dashes, e.g.
Gengar-becomesGengar - convert to lowercase, e.g.
Gengarbecomesgengar
None
import sluggify
slug = sluggify.sluggify("Pokémon Yellow!")
print(slug)
assert(slug == "pokemon-yellow") # expected outputpokemon-yellowDownload sluggify.py and place it in your project's root
- Publish to PyPI