misc: don't fold apostrophes in slugs (#7108)

This commit is contained in:
Frédéric Péters 2015-04-30 11:24:13 +02:00
parent 74c2beddae
commit d4bff9858c
2 changed files with 6 additions and 2 deletions

View File

@ -65,6 +65,10 @@ def test_simplify_space():
assert simplify('test again', '_') == 'test_again'
assert simplify(' test again ', '_') == 'test_again'
def test_simplify_apostrophes():
assert simplify('test\'again') == 'test-again'
assert simplify('test\'\'\'again') == 'test-again'
def test_simplify_accented():
assert simplify(u'cliché') == 'cliche'
assert simplify(u'cliché'.encode('iso-8859-1')) == 'cliche'

View File

@ -139,8 +139,8 @@ def simplify(s, space='-'):
else:
s = unicode(s, 'iso-8859-1', 'ignore')
s = unicodedata.normalize('NFKD', s).encode('ascii', 'ignore')
s = re.sub('[^\w\s%s]' % space, '', s).strip().lower()
s = re.sub('[\s%s]+' % space, space, s)
s = re.sub(r'[^\w\s\'%s]' % space, '', s).strip().lower()
s = re.sub(r'[\s\'%s]+' % space, space, s)
return s
def get_datetime_language():