GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Improve cream.util.string.slugify · Issue #3 · cream/python-cream

Improve cream.util.string.slugify #3

New issue
Copy link
New issue
Copy link
Open
Open
Improve cream.util.string.slugify#3
Copy link
Assignees
kkris

Description

@kkris
kkris
opened on Apr 19, 2011
Issue body actions

I would like to use this little snippet from Armin Ronacher, because it produces real nice slugs and e.g. converts ö to oe instead of o or -- like it is doing now.
But to use this we need http://pypi.python.org/pypi/translitcodec as a dependency.

import re
import translitcodec

_punct_re = re.compile(r'[\t !"#$%&\'()*\-/<=>?@\[\\\]^_`{|},.]+')


def slugify(text, delim=u'-'):
    """Generates an ASCII-only slug."""
    result = []
    for word in _punct_re.split(text.lower()):
        word = word.encode('translit/long')
        if word:
            result.append(word)
    return unicode(delim.join(result))

Activity

  1. ghost assigned
    kkris
    on Apr 19, 2011
  2. jonashaag commented on Apr 20, 2011

    @jonashaag
    jonashaag
    on Apr 20, 2011
    Contributor
    More actions

    -1 as slugify isn't used for stuff users see but just for file names (which are an implementation detail)

  3. kkris commented on Apr 20, 2011

    @kkris
    kkris
    on Apr 20, 2011
    MemberAuthor
    More actions

    yeah, but the current implementation has some pitfalls, as "ö", "ä" and "ü" result in the same string.

    e.g. it is possible to have two different profiles (think of "hülle", "hölle") which result in the same filename.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @kkris
    kkris

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.