{"id":13502415,"url":"https://github.com/voronind/awesome-slugify","last_synced_at":"2025-12-11T22:47:16.470Z","repository":{"id":41438823,"uuid":"13694352","full_name":"voronind/awesome-slugify","owner":"voronind","description":"Python flexible slugify function","archived":false,"fork":false,"pushed_at":"2020-04-17T14:24:23.000Z","size":76,"stargazers_count":483,"open_issues_count":18,"forks_count":45,"subscribers_count":11,"default_branch":"master","last_synced_at":"2024-05-22T15:24:05.325Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://pypi.python.org/pypi/awesome-slugify","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/voronind.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-10-19T02:58:27.000Z","updated_at":"2024-05-05T12:56:55.000Z","dependencies_parsed_at":"2022-08-25T06:10:35.891Z","dependency_job_id":null,"html_url":"https://github.com/voronind/awesome-slugify","commit_stats":null,"previous_names":["dimka665/awesome-slugify"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/voronind%2Fawesome-slugify","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/voronind%2Fawesome-slugify/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/voronind%2Fawesome-slugify/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/voronind%2Fawesome-slugify/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/voronind","download_url":"https://codeload.github.com/voronind/awesome-slugify/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247353746,"owners_count":20925329,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-31T22:02:13.150Z","updated_at":"2025-12-11T22:47:11.437Z","avatar_url":"https://github.com/voronind.png","language":"Python","funding_links":[],"categories":["Python","文本处理","Awesome Python"],"sub_categories":["Text Processing"],"readme":"===============\nawesome-slugify\n===============\n.. image:: https://travis-ci.org/dimka665/awesome-slugify.svg?branch=master\n    :target: https://travis-ci.org/dimka665/awesome-slugify\n\n**Python flexible slugify function**\n\n| PyPi: https://pypi.python.org/pypi/awesome-slugify\n| Github: https://github.com/dimka665/awesome-slugify\n\n\nInstall\n=======\n.. code-block:: bash\n\n    pip install awesome-slugify\n\nUsage\n=====\n\n.. code-block:: python\n\n    from slugify import slugify\n\n    slugify('Any text')  # 'Any-text'\n\nCustom slugify\n==============\n\n.. code-block:: python\n\n    from slugify import slugify, Slugify, UniqueSlugify\n\n    slugify('Any text', to_lower=True)  # 'any-text'\n\n    custom_slugify = Slugify(to_lower=True)\n    custom_slugify('Any text')          # 'any-text'\n\n    custom_slugify.separator = '_'\n    custom_slugify('Any text')          # 'any_text'\n\n    custom_slugify = UniqueSlugify()\n    custom_slugify('Any text')          # 'any-text'\n    custom_slugify('Any text')          # 'any-text-1'\n\nslugify function optional args\n------------------------------\n\n.. code-block:: python\n\n    to_lower              # if True convert text to lowercase\n    max_length            # output string max length\n    separator             # separator string\n    capitalize            # if True upper first letter\n\n\nSlugify class args\n------------------\n\n.. code-block:: python\n\n    pretranslate = None               # function or dict for replace before translation\n    translate = unidecode.unidecode   # function for slugifying or None\n    safe_chars = ''                   # additional safe chars\n    stop_words = ()                   # remove these words from slug\n\n    to_lower = False                  # default to_lower value\n    max_length = None                 # default max_length value\n    separator = '-'                   # default separator value\n    capitalize = False                # default capitalize value\n\nUniqueSlugify class args\n------------------------\n\n.. code-block:: python\n\n    # all Slugify class args +\n    uids = []                         # initial unique ids\n\nPredefined slugify functions\n============================\n\nSome slugify functions is predefined this way:\n\n.. code-block:: python\n\n    from slugify import Slugify, CYRILLIC, GERMAN, GREEK\n\n    slugify = Slugify()\n    slugify_unicode = Slugify(translate=None)\n\n    slugify_url = Slugify()\n    slugify_url.to_lower = True\n    slugify_url.stop_words = ('a', 'an', 'the')\n    slugify_url.max_length = 200\n\n    slugify_filename = Slugify()\n    slugify_filename.separator = '_'\n    slugify_filename.safe_chars = '-.'\n    slugify_filename.max_length = 255\n\n    slugify_ru = Slugify(pretranslate=CYRILLIC)\n    slugify_de = Slugify(pretranslate=GERMAN)\n    slugify_el = Slugify(pretranslate=GREEK)\n\nExamples\n========\n\n.. code-block:: python\n\n    from slugify import Slugify, UniqueSlugify, slugify, slugify_unicode\n    from slugify import slugify_url, slugify_filename\n    from slugify import slugify_ru, slugify_de\n\n    slugify('one kožušček')                       # one-kozuscek\n    slugify('one two three', separator='.')       # one.two.three\n    slugify('one two three four', max_length=12)  # one-two-four   (12 chars)\n    slugify('one TWO', to_lower=True)             # one-two\n    slugify('one TWO', capitalize=True)           # One-TWO\n\n    slugify_filename(u'Дrаft №2.txt')             # Draft_2.txt\n    slugify_url(u'Дrаft №2.txt')                  # draft-2-txt\n\n    my_slugify = Slugify()\n    my_slugify.separator = '.'\n    my_slugify.pretranslate = {'я': 'i', '♥': 'love'}\n    my_slugify('Я ♥ борщ')                        # I.love.borshch  (custom translate)\n\n    slugify('Я ♥ борщ')                           # Ia-borshch  (standard translation)\n    slugify_ru('Я ♥ борщ')                        # Ya-borsch   (alternative russian translation)\n    slugify_unicode('Я ♥ борщ')                   # Я-борщ      (sanitize only)\n\n    slugify_de('ÜBER Über slugify')               # UEBER-Ueber-slugify\n\n    slugify_unique = UniqueSlugify(separator='_')\n    slugify_unique('one TWO')                     # One_TWO\n    slugify_unique('one TWO')                     # One_TWO_1\n\n    slugify_unique = UniqueSlugify(uids=['cellar-door'])\n    slugify_unique('cellar door')                 # cellar-door-1\n\n\nCustom Unique Slugify Checker\n=============================\n\n.. code-block:: python\n\n    from slugify import UniqueSlugify\n\n    def my_unique_check(text, uids):\n        if text in uids:\n            return False\n        return not SomeDBClass.objects.filter(slug_field=text).exists()\n\n    custom_slugify_unique = UniqueSlugify(unique_check=my_unique_check)\n\n    # Checks the database for a matching document\n    custom_slugify_unique('te occidere possunt')\n\n\nRunning UnitTests\n=================\n\n.. code-block:: bash\n\n    $ virtualenv venv\n    $ venv/bin/pip install -r requirements.txt\n    $ venv/bin/nosetests slugify\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvoronind%2Fawesome-slugify","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvoronind%2Fawesome-slugify","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvoronind%2Fawesome-slugify/lists"}