- Notifications
You must be signed in to change notification settings - Fork50
A slugifier that works in unicode
License
NotificationsYou must be signed in to change notification settings
mozilla/unicode-slugify
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
Unicode Slugify is a slugifier that generates unicode slugs. It was originallyused in the Firefox Add-ons web site to generate slugs for add-ons and add-oncollections. Many of these add-ons and collections had unicode characters andrequired more than simple transliteration.
fromslugifyimportslugify,SLUG_OK# Default usage : lower, spaces replaced with "-", only alphanum and "-_~" chars, keeps unicodeslugify(u'Bän...g (bang)')# u'bäng-bang'# Keep capital letters and spacesslugify(u'Bän...g (bang)',lower=False,spaces=True)# u'Bäng bang'# Replace non ascii chars with their "best" representationslugify(u'北京 (capital of China)',only_ascii=True)# u'bei-jing-capital-of-china'# Allow some extra charsslugify(u'北京 (capital of China)',ok=SLUG_OK+'()',only_ascii=True)# u'bei-jing-(capital-of-china)'# "snake_case" exampledefsnake_case(s):# As "-" is not in allowed Chars, first one (`_`) is used for space replacementreturnslugify(s,ok='_',only_ascii=True)snake_case(u'北京 (capital of china)')# u'bei_jing_capital_of_china'# "CamelCase" exampledefcamel_case(s):returnslugify(s.title(),ok='',only_ascii=True,lower=False)camel_case(u'北京 (capital of china)')# u'BeiJingCapitalOfChina'
Tomaz Solc, unidecode,https://pypi.python.org/pypi/Unidecode
About
A slugifier that works in unicode
Resources
License
Code of conduct
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Contributors12
Uh oh!
There was an error while loading.Please reload this page.