Add the ability to read from markdown too.

This commit is contained in:
Alexis Metaireau 2010-10-31 00:08:16 +01:00
commit c83d234773
6 changed files with 40 additions and 20 deletions

View file

@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
import re
from datetime import datetime
from codecs import open as _open
@ -41,8 +42,9 @@ def slugify(value):
Took from django sources.
"""
import unicodedata
value = unicodedata.normalize('NFKD', value).encode('ascii', 'ignore')
if type(value) == unicode:
import unicodedata
value = unicodedata.normalize('NFKD', value).encode('ascii', 'ignore')
value = unicode(re.sub('[^\w\s-]', '', value).strip().lower())
return re.sub('[-\s]+', '-', value)