summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVal Neekman <un33kvu@gmail.com>2016-01-15 22:28:45 -0500
committerVal Neekman <un33kvu@gmail.com>2016-01-15 22:28:45 -0500
commita63ed53616a60addd00dfd8f579c1a531725987f (patch)
tree5db80cd575b53044c5f15d08c06ee9696ac2fc49
parenteeabcc29eb67dd9ab34c693db44f9ece312e7a2c (diff)
parent76f0678e9b28ae54a9a29b95d9fedb74bc8855cd (diff)
downloadpython-slugify-a63ed53616a60addd00dfd8f579c1a531725987f.tar.gz
Merge pull request #23 from fabiocaccamo/master
Fixed issue #17
-rw-r--r--slugify/slugify.py9
-rw-r--r--test.py2
2 files changed, 8 insertions, 3 deletions
diff --git a/slugify/slugify.py b/slugify/slugify.py
index 9eeabef..9d17d3c 100644
--- a/slugify/slugify.py
+++ b/slugify/slugify.py
@@ -88,9 +88,11 @@ def slugify(text, entities=True, decimal=True, hexadecimal=True, max_length=0, w
if not isinstance(text, _unicode_type):
text = _unicode(text, 'utf-8', 'ignore')
+ text = QUOTE_PATTERN.sub('-', text)
+
# decode unicode
text = unidecode.unidecode(text)
-
+
# ensure text is still in unicode
if not isinstance(text, _unicode_type):
text = _unicode(text, 'utf-8', 'ignore')
@@ -118,8 +120,11 @@ def slugify(text, entities=True, decimal=True, hexadecimal=True, max_length=0, w
if sys.version_info < (3,):
text = text.encode('ascii', 'ignore')
+ # make the text lowercase
+ text = text.lower()
+
# replace unwanted characters
- text = QUOTE_PATTERN.sub('', text.lower()) # replace ' with nothing instead with -
+ text = QUOTE_PATTERN.sub('', text)
text = NUMBERS_PATTERN.sub('', text)
text = ALLOWED_CHARS_PATTERN.sub('-', text)
diff --git a/test.py b/test.py
index c5e6265..5bad955 100644
--- a/test.py
+++ b/test.py
@@ -33,7 +33,7 @@ class TestSlugification(unittest.TestCase):
def test_accented_text(self):
txt = 'C\'est déjà l\'été.'
r = slugify(txt)
- self.assertEqual(r, "cest-deja-lete")
+ self.assertEqual(r, "c-est-deja-l-ete")
txt = 'Nín hǎo. Wǒ shì zhōng guó rén'
r = slugify(txt)