Skip to content

JRiggles/sluggify-python

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

sluggify-python

A Python implementation of skeddles/sluggify for generating URL slugs

The following manipluations are performed in this order:

  1. replace slashes / \ and spaces with dashes -
  2. replace any accented characters with their closest non-accented equvalent, e.g. é becomes e
  3. remove all non-alphanumeric characters (anything other than A-Z, a-z, 0-9, and -)
  4. replace multiple consecutive dashes --- with a single dash -
  5. remove leading dashes, e.g. -Gengar- becomes Gengar-
  6. remove trailing dashes, e.g. Gengar- becomes Gengar
  7. convert to lowercase, e.g. Gengar becomes gengar

Dependencies

None

Example

import sluggify

slug = sluggify.sluggify("Pokémon Yellow!")
print(slug)
assert(slug == "pokemon-yellow")  # expected output

outputs...

pokemon-yellow

Installation

Download sluggify.py and place it in your project's root

TODO

  • Publish to PyPI

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages