diff options
| author | Fabio Caccamo <fabio.caccamo@gmail.com> | 2016-01-15 15:31:32 +0100 |
|---|---|---|
| committer | Fabio Caccamo <fabio.caccamo@gmail.com> | 2016-01-15 15:31:32 +0100 |
| commit | 0c9b8e069994f6ab76b4f4f5efd2d85cf795bdd8 (patch) | |
| tree | 090be5fb6c0110e19d7b3c97dbb5c2c3bfa6cfbb /slugify | |
| parent | eeabcc29eb67dd9ab34c693db44f9ece312e7a2c (diff) | |
| download | python-slugify-0c9b8e069994f6ab76b4f4f5efd2d85cf795bdd8.tar.gz | |
Fixed apos quote not replaced by separator - Issue #17
Diffstat (limited to 'slugify')
| -rw-r--r-- | slugify/slugify.py | 9 |
1 files changed, 7 insertions, 2 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) |
