Skip to main content

A slug generator that turns strings into unicode slugs.

Project description

Unicode Slugify

Unicode Slugify is a slugifier that generates unicode slugs. It was originally used in the Firefox Add-ons web site to generate slugs for add-ons and add-on collections. Many of these add-ons and collections had unicode characters and required more than simple transliteration.

Usage

from slugify import slugify, SLUG_OK

# Default usage : lower, spaces replaced with "-", only alphanum and "-_~" chars, keeps unicode
slugify(u'Bän...g (bang)')
# u'bäng-bang'

# Keep capital letters and spaces
slugify(u'Bän...g (bang)', lower=False, spaces=True)
# u'Bäng bang'

# Replace non ascii chars with their "best" representation
slugify(u'北京 (capital of China)', only_ascii=True)
# u'bei-jing-capital-of-china'

# Allow some extra chars
slugify(u'北京 (capital of China)', ok=SLUG_OK+'()', only_ascii=True)
# u'bei-jing-(capital-of-china)'

# "snake_case" example
def snake_case(s):
    # As "-" is not in allowed Chars, first one (`_`) is used for space replacement
    return slugify(s, ok='_', only_ascii=True)
snake_case(u'北京 (capital of china)')
# u'bei_jing_capital_of_china'

# "CamelCase" example
def camel_case(s):
    return slugify(s.title(), ok='', only_ascii=True, lower=False)
camel_case(u'北京 (capital of china)')
# u'BeiJingCapitalOfChina'

Thanks

Tomaz Solc, unidecode, https://pypi-hypernode.com/pypi/Unidecode

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

unicode-slugify-0.1.5.tar.gz (5.8 kB view details)

Uploaded Source

Built Distribution

unicode_slugify-0.1.5-py3-none-any.whl (6.4 kB view details)

Uploaded Python 3

File details

Details for the file unicode-slugify-0.1.5.tar.gz.

File metadata

  • Download URL: unicode-slugify-0.1.5.tar.gz
  • Upload date:
  • Size: 5.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.7.11

File hashes

Hashes for unicode-slugify-0.1.5.tar.gz
Algorithm Hash digest
SHA256 25f424258317e4cb41093e2953374b3af1f23097297664731cdb3ae46f6bd6c3
MD5 d301732b492fac3c3a2b7d8e35fe3ea7
BLAKE2b-256 ed37c82a28893c7bfd881c011cbebf777d2a61f129409d83775f835f70e02c20

See more details on using hashes here.

Provenance

File details

Details for the file unicode_slugify-0.1.5-py3-none-any.whl.

File metadata

  • Download URL: unicode_slugify-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 6.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.7.11

File hashes

Hashes for unicode_slugify-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 33a11c0ac901f7220659dd0dd6f232cf39637dfd1b9f5f35ef5ead9fef696879
MD5 508cb89f26314be2bb24c444f3f00e03
BLAKE2b-256 c7a153414fffc089249eee742c1ce04b22761980d2aaea37e23b94775ff51007

See more details on using hashes here.

Provenance

Supported by

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