unicode-slugify


Nameunicode-slugify JSON
Version 0.1.5 PyPI version JSON
download
home_pagehttp://github.com/mozilla/unicode-slugify
SummaryA slug generator that turns strings into unicode slugs.
upload_time2021-10-20 19:06:27
maintainer
docs_urlNone
authorJeff Balogh, Dave Dash
requires_python
licenseBSD
keywords
VCS
bugtrack_url
requirements six unidecode
Travis-CI
coveralls test coverage No coveralls.
            # Unicode Slugify

Unicode Slugify is a slugifier that generates unicode slugs.  It was originally
used in the Firefox Add-ons web site to generate slugs for add-ons and add-on
collections. Many of these add-ons and collections had unicode characters and
required more than simple transliteration.

## Usage

```python

from slugify import slugify, SLUG_OK

# Default usage : lower, spaces replaced with "-", only alphanum and "-_~" chars, keeps unicode
slugify(u'Bän...g (bang)')
# u'bäng-bang'

# Keep capital letters and spaces
slugify(u'Bän...g (bang)', lower=False, spaces=True)
# u'Bäng bang'

# Replace non ascii chars with their "best" representation
slugify(u'北京 (capital of China)', only_ascii=True)
# u'bei-jing-capital-of-china'

# Allow some extra chars
slugify(u'北京 (capital of China)', ok=SLUG_OK+'()', only_ascii=True)
# u'bei-jing-(capital-of-china)'

# "snake_case" example
def snake_case(s):
    # As "-" is not in allowed Chars, first one (`_`) is used for space replacement
    return slugify(s, ok='_', only_ascii=True)
snake_case(u'北京 (capital of china)')
# u'bei_jing_capital_of_china'

# "CamelCase" example
def camel_case(s):
    return slugify(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



            

Raw data

            {
    "_id": null,
    "home_page": "http://github.com/mozilla/unicode-slugify",
    "name": "unicode-slugify",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "",
    "author": "Jeff Balogh, Dave Dash",
    "author_email": "jbalogh@mozilla.com, dd@mozilla.com",
    "download_url": "https://files.pythonhosted.org/packages/ed/37/c82a28893c7bfd881c011cbebf777d2a61f129409d83775f835f70e02c20/unicode-slugify-0.1.5.tar.gz",
    "platform": "",
    "description": "# Unicode Slugify\n\nUnicode Slugify is a slugifier that generates unicode slugs.  It was originally\nused in the Firefox Add-ons web site to generate slugs for add-ons and add-on\ncollections. Many of these add-ons and collections had unicode characters and\nrequired more than simple transliteration.\n\n## Usage\n\n```python\n\nfrom slugify import slugify, SLUG_OK\n\n# Default usage : lower, spaces replaced with \"-\", only alphanum and \"-_~\" chars, keeps unicode\nslugify(u'B\u00e4n...g (bang)')\n# u'b\u00e4ng-bang'\n\n# Keep capital letters and spaces\nslugify(u'B\u00e4n...g (bang)', lower=False, spaces=True)\n# u'B\u00e4ng bang'\n\n# Replace non ascii chars with their \"best\" representation\nslugify(u'\u5317\u4eac (capital of China)', only_ascii=True)\n# u'bei-jing-capital-of-china'\n\n# Allow some extra chars\nslugify(u'\u5317\u4eac (capital of China)', ok=SLUG_OK+'()', only_ascii=True)\n# u'bei-jing-(capital-of-china)'\n\n# \"snake_case\" example\ndef snake_case(s):\n    # As \"-\" is not in allowed Chars, first one (`_`) is used for space replacement\n    return slugify(s, ok='_', only_ascii=True)\nsnake_case(u'\u5317\u4eac (capital of china)')\n# u'bei_jing_capital_of_china'\n\n# \"CamelCase\" example\ndef camel_case(s):\n    return slugify(s.title(), ok='', only_ascii=True, lower=False)\ncamel_case(u'\u5317\u4eac (capital of china)')\n# u'BeiJingCapitalOfChina'\n```\n\n## Thanks\n\nTomaz Solc, unidecode, https://pypi.python.org/pypi/Unidecode\n\n\n",
    "bugtrack_url": null,
    "license": "BSD",
    "summary": "A slug generator that turns strings into unicode slugs.",
    "version": "0.1.5",
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "md5": "508cb89f26314be2bb24c444f3f00e03",
                "sha256": "33a11c0ac901f7220659dd0dd6f232cf39637dfd1b9f5f35ef5ead9fef696879"
            },
            "downloads": -1,
            "filename": "unicode_slugify-0.1.5-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "508cb89f26314be2bb24c444f3f00e03",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 6358,
            "upload_time": "2021-10-20T19:06:26",
            "upload_time_iso_8601": "2021-10-20T19:06:26.465740Z",
            "url": "https://files.pythonhosted.org/packages/c7/a1/53414fffc089249eee742c1ce04b22761980d2aaea37e23b94775ff51007/unicode_slugify-0.1.5-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "md5": "d301732b492fac3c3a2b7d8e35fe3ea7",
                "sha256": "25f424258317e4cb41093e2953374b3af1f23097297664731cdb3ae46f6bd6c3"
            },
            "downloads": -1,
            "filename": "unicode-slugify-0.1.5.tar.gz",
            "has_sig": false,
            "md5_digest": "d301732b492fac3c3a2b7d8e35fe3ea7",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 5784,
            "upload_time": "2021-10-20T19:06:27",
            "upload_time_iso_8601": "2021-10-20T19:06:27.908644Z",
            "url": "https://files.pythonhosted.org/packages/ed/37/c82a28893c7bfd881c011cbebf777d2a61f129409d83775f835f70e02c20/unicode-slugify-0.1.5.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2021-10-20 19:06:27",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "mozilla",
    "github_project": "unicode-slugify",
    "travis_ci": true,
    "coveralls": false,
    "github_actions": false,
    "requirements": [
        {
            "name": "six",
            "specs": []
        },
        {
            "name": "unidecode",
            "specs": []
        }
    ],
    "tox": true,
    "lcname": "unicode-slugify"
}
        
Elapsed time: 0.02850s