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  (standard translation)
slugify_ru('Я ♥ борщ')                        # Ya-borsch   (alternative russian translation)
slugify_unicode('Я ♥ борщ')                   # Я-борщ      (sanitize only)

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

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.1.tar.gz (4.0 kB view details)

Uploaded Source

File details

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

File metadata

  • Download URL: awesome-slugify-1.1.tar.gz
  • Upload date:
  • Size: 4.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for awesome-slugify-1.1.tar.gz
Algorithm Hash digest
SHA256 40a0feb90bf9080f2bbd82c71ddf791ad6f8cde87530ee6258d2db0b77c68fa2
MD5 1465603cbce91b86818d50467d37ca22
BLAKE2b-256 c94c40fabbf8300a8d59113d56baef4833e26386c80dbb8cc8eaab2880ed409e

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