Skip to main content

Fork of un33k/python-slugify to fix issue #68

Project description

permissive-slugify

Fork of un33k/python-slugify to fix issue 68.

License Version
Travis CI Coverage
AppVeyor Supported versions
Wheel Implementation
Status Downloads
Show your support

Improvements

  • Support for extras_require and cmdclass
  • Refactored
  • Deploy from Travis CI
  • Added Appveyor Integration
  • Uses pytest
  • Uses CodeCov

How to install

By default, permissive-slugify uses Unidecode as decoder which is GPL-licensed.

pip install permissive-slugify

Specifying decoder

You can specify which decoder will be used:

  • Unidecode - (GPL-licensed).

    pip install permissive-slugify[unidecode]
    easy_install permissive-slugify[unidecode]
    
  • text-unidecode (GPL & Perl Artistic)

    pip install permissive-slugify[text-unidecode]
    easy_install permissive-slugify[text-unidecode]
    

How to use

# -*- coding: utf-8 -*-
from slugify import slugify

txt = "This is a test ---"
slug = slugify(txt)
assert slug == "this-is-a-test"

txt = '影師嗎'
slug = slugify(txt)
assert slug == "ying-shi-ma"

txt = 'C\'est déjà l\'été.'
slug = slugify(txt)
assert slug == "c-est-deja-l-ete"

txt = 'Nín hǎo. Wǒ shì zhōng guó rén'
slug = slugify(txt)
assert slug == "nin-hao-wo-shi-zhong-guo-ren"

txt = 'Компьютер'
slug = slugify(txt)
assert slug == "kompiuter"

txt = 'jaja---lol-méméméoo--a'
slug = slugify(txt, max_length=9)
assert slug == "jaja-lol"

txt = 'jaja---lol-méméméoo--a'
slug = slugify(txt, max_length=15, word_boundary=True)
assert slug == "jaja-lol-a"

txt = 'jaja---lol-méméméoo--a'
slug = slugify(txt, max_length=20, word_boundary=True, separator=".")
assert slug == "jaja.lol.mememeoo.a"

txt = 'one two three four five'
slug = slugify(txt, max_length=13, word_boundary=True, save_order=True)
assert slug == "one-two-three"

txt = 'the quick brown fox jumps over the lazy dog'
slug = slugify(txt, stopwords=['the'])
assert slug == 'quick-brown-fox-jumps-over-lazy-dog'

txt = 'the quick brown fox jumps over the lazy dog in a hurry'
slug = slugify(txt, stopwords=['the', 'in', 'a', 'hurry'])
assert slug == 'quick-brown-fox-jumps-over-lazy-dog'

txt = 'thIs Has a stopword Stopword'
slug = slugify(txt, stopwords=['Stopword'], lowercase=False)
assert slug == 'thIs-Has-a-stopword'

txt = "___This is a test___"
regex_pattern = r'[^-a-z0-9_]+'
slug = slugify(txt, regex_pattern=regex_pattern)
assert slug == "___this-is-a-test___"

txt = "___This is a test___"
regex_pattern = r'[^-a-z0-9_]+'
slug = slugify(txt, separator='_', regex_pattern=regex_pattern)
assert slug != "_this_is_a_test_"

txt = '10 | 20 %'
slug = slugify(txt, replacements=[['|', 'or'], ['%', 'percent']])
assert slug == "10-or-20-percent"

References

Author

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

permissive-slugify-1.0.0.tar.gz (6.3 kB view details)

Uploaded Source

File details

Details for the file permissive-slugify-1.0.0.tar.gz.

File metadata

  • Download URL: permissive-slugify-1.0.0.tar.gz
  • Upload date:
  • Size: 6.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.29.1 CPython/3.6.3

File hashes

Hashes for permissive-slugify-1.0.0.tar.gz
Algorithm Hash digest
SHA256 5509b9dce00260fe84b4e142aae32ff46d332452db56a11eebc9c20251805eea
MD5 1a6cda70433bc53a173194a6e8310aba
BLAKE2b-256 95340f59f950c6e9d94dc09a5675c711cf39b7da53b4d673c0c79ab71575cccd

See more details on using hashes here.

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