diff options
author | Reza Moradi <mrezzamoradi@gmail.com> | 2022-02-22 20:05:08 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-22 14:05:08 -0500 |
commit | d968ca7419e6f4e40685888c56d03bea50fd39d7 (patch) | |
tree | c26388f34c2e91260fed09a0369f88c8791f94b6 /README.md | |
parent | 07b87da81140cf51e4a585e43d4fe9113f4c2ad5 (diff) | |
download | python-slugify-d968ca7419e6f4e40685888c56d03bea50fd39d7.tar.gz |
allow unicode (#111)v6.1.0
* initial commit to allow unicode
* update version and changelog
* add the flag to the CLI
* update README.md
Diffstat (limited to 'README.md')
-rw-r--r-- | README.md | 16 |
1 files changed, 15 insertions, 1 deletions
@@ -42,7 +42,8 @@ def slugify( stopwords=(), regex_pattern=None, lowercase=True, - replacements=() + replacements=(), + allow_unicode=False ): """ Make a slug from the given text. @@ -58,6 +59,7 @@ def slugify( :param regex_pattern (str): regex pattern for disallowed characters :param lowercase (bool): activate case sensitivity by setting it to False :param replacements (iterable): list of replacement rules e.g. [['|', 'or'], ['%', 'percent']] + :param allow_unicode (bool): allow unicode characters :return (str): slugify text """ ``` @@ -75,6 +77,10 @@ txt = '影師嗎' r = slugify(txt) self.assertEqual(r, "ying-shi-ma") +txt = '影師嗎' +r = slugify(txt, allow_unicode=True) +self.assertEqual(r, "影師嗎") + txt = 'C\'est déjà l\'été.' r = slugify(txt) self.assertEqual(r, "c-est-deja-l-ete") @@ -133,6 +139,14 @@ txt = 'ÜBER Über German Umlaut' r = slugify(txt, replacements=[['Ü', 'UE'], ['ü', 'ue']]) self.assertEqual(r, "ueber-ueber-german-umlaut") +txt = 'i love 🦄' +r = slugify(txt, allow_unicode=True) +self.assertEqual(r, "i-love") + +txt = 'i love 🦄' +r = slugify(txt, allow_unicode=True, regex_pattern=r'[^🦄]+') +self.assertEqual(r, "🦄") + ``` For more examples, have a look at the [test.py](test.py) file. |