Skip to main content

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

Metadata

Release files for permissive-slugify 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for permissive-slugify 1.0.0
File Size Uploaded
permissive-slugify-1.0.0.tar.gz 6.3 kB Details

Release files / permissive-slugify-1.0.0.tar.gz

Download URL permissive-slugify-1.0.0.tar.gz
Size 6.3 kB
Tags Source
SHA-256 checksum
How to use checksums
5509b9dce00260fe84b4e142aae32ff46d332452db56a11eebc9c20251805eea
BLAKE2b-256 checksum
How to use checksums
95340f59f950c6e9d94dc09a5675c711cf39b7da53b4d673c0c79ab71575cccd
Upload date
Uploaded using Trusted Publishing?
What is 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

Release history Release notifications | RSS feed

This release

1.0.0 This release

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page