@@ -42,7 +42,8 @@ def slugify(
4242 stopwords = (),
4343 regex_pattern = None ,
4444 lowercase = True ,
45- replacements = ()
45+ replacements = (),
46+ allow_unicode = False
4647 ):
4748 """
4849 Make a slug from the given text.
@@ -55,9 +56,10 @@ def slugify(
5556 :param save_order (bool): if parameter is True and max_length > 0 return whole words in the initial order
5657 :param separator (str): separator between words
5758 :param stopwords (iterable): words to discount
58- :param regex_pattern (str): regex pattern for allowed characters
59+ :param regex_pattern (str): regex pattern for disallowed characters
5960 :param lowercase (bool): activate case sensitivity by setting it to False
6061 :param replacements (iterable): list of replacement rules e.g. [['|', 'or'], ['%', 'percent']]
62+ :param allow_unicode (bool): allow unicode characters
6163 :return (str): slugify text
6264 """
6365```
@@ -75,6 +77,10 @@ txt = '影師嗎'
7577r = slugify(txt)
7678self .assertEqual(r, " ying-shi-ma" )
7779
80+ txt = ' 影師嗎'
81+ r = slugify(txt, allow_unicode = True )
82+ self .assertEqual(r, " 影師嗎" )
83+
7884txt = ' C\' est déjà l\' été.'
7985r = slugify(txt)
8086self .assertEqual(r, " c-est-deja-l-ete" )
@@ -133,6 +139,14 @@ txt = 'ÜBER Über German Umlaut'
133139r = slugify(txt, replacements = [[' Ü' , ' UE' ], [' ü' , ' ue' ]])
134140self .assertEqual(r, " ueber-ueber-german-umlaut" )
135141
142+ txt = ' i love 🦄'
143+ r = slugify(txt, allow_unicode = True )
144+ self .assertEqual(r, " i-love" )
145+
146+ txt = ' i love 🦄'
147+ r = slugify(txt, allow_unicode = True , regex_pattern = r ' [^ 🦄 ]+ ' )
148+ self .assertEqual(r, " 🦄" )
149+
136150```
137151
138152For more examples, have a look at the [ test.py] ( test.py ) file.
@@ -164,10 +178,6 @@ quick-brown-fox-jumps-over-lazy-dog
164178
165179# Running the tests
166180
167- To run the tests against all environments:
168-
169- tox
170-
171181To run the tests against the current environment:
172182
173183 python test.py
@@ -188,8 +198,8 @@ X.Y.Z Version
188198 `MINOR` version -- when you add functionality in a backwards-compatible manner, and
189199 `PATCH` version -- when you make backwards-compatible bug fixes.
190200
191- [ status-image ] : https://travis-ci.org /un33k/python-slugify. svg?branch=master
192- [ status-link ] : https://travis-ci.org /un33k/python-slugify
201+ [ status-image ] : https://github.com /un33k/python-slugify/actions/workflows/ci.yml/badge. svg
202+ [ status-link ] : https://github.com /un33k/python-slugify/actions/workflows/ci.yml
193203[ version-image ] : https://img.shields.io/pypi/v/python-slugify.svg
194204[ version-link ] : https://pypi.python.org/pypi/python-slugify
195205[ coverage-image ] : https://coveralls.io/repos/un33k/python-slugify/badge.svg
0 commit comments