Skip to main content

Python flexible slugify module

Project description

Python flexible slugify module

Install

pip install awesome-slugify

Function args

slugify

text                  # text for translate. position arg
max_length = None     # output string max length
separator = '-'       # separator string
capitalize = False    # upper first letter if True

Retuns translated text.

get_slugify

pretranslate = None               # function or dict for replace before translation
translate = unidecode.unidecode   # function for slugifying or None
# + slugify's keyword args

Returns slugify function.

Examples

from slugify import slugify, get_slugify, slugify_unicode, slugify_ru

slugify('one kožušček')                       # one-kozuscek
slugify('one-=-two-%-three', separator='.')   # one.two.three
slugify('one two Three', capitalize=True)     # One-two-Three
slugify('one two three four', max_length=12)  # one-two-four   (12 chars)

slugify('я ♥ борщ')                           # ia-borshch
slugify_unicode('я ♥ борщ')                   # я-борщ    (sanitize only)

my_slugify = get_slugify(pretranslate={'я': 'i', '♥': 'love', 'щ': 'sch'}, separator='.')
my_slugify('я ♥ борщ')                        # i.love.borsch  (custom translate)

slugify_ru('я ♥ борщ')                        # ya-borsch  (alternative russian translation)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

awesome-slugify-1.0.2.tar.gz (3.8 kB view details)

Uploaded Source

File details

Details for the file awesome-slugify-1.0.2.tar.gz.

File metadata

File hashes

Hashes for awesome-slugify-1.0.2.tar.gz
Algorithm Hash digest
SHA256 6a7dffef7f196be8e4514c1a768ef3a3f46c532bc8d4b9f06ce229e56c8e10c9
MD5 66e132b4855fa8c7f2d1cf897d0e1240
BLAKE2b-256 015026c23e767a78ca583716fdfa3840959fab40cb51a0daa7a74a6ee1f3f68c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page