url_tags.py 文件源码

python
阅读 23 收藏 0 点赞 0 评论 0

项目:prestashop-sync 作者: dragoon 项目源码 文件源码
def slugify2(value):
    """
    Normalizes string, converts to lowercase, removes non-alpha characters,
    and converts spaces to hyphens.

    It is similar to built-in :filter:`slugify` but it also handles special characters in variety of languages
    so that they are not simply removed but properly transliterated/downcoded.
    """
    try:
        value = unicodedata.normalize('NFC', value)
        value = downcode(value)
        value = unicodedata.normalize('NFD', value).encode('ascii', 'ignore')
        value = unicode(re.sub('[^\w\s-]', '', value).strip().lower())
        return safestring.mark_safe(re.sub('[-\s]+', '-', value))
    except:
        if settings.TEMPLATE_DEBUG:
            raise
        else:
            return u''
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号