Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

A slugifier that works in unicode

License

NotificationsYou must be signed in to change notification settings

mozilla/unicode-slugify

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.

Usage

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'

Thanks

Tomaz Solc, unidecode,https://pypi.python.org/pypi/Unidecode

About

A slugifier that works in unicode

Resources

License

Code of conduct

Stars

Watchers

Forks

Contributors12

Languages


[8]ページ先頭

©2009-2025 Movatter.jp