summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.md10
-rw-r--r--slugify/__init__.py2
-rw-r--r--slugify/slugify.py17
3 files changed, 22 insertions, 7 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 247c090..af16f3d 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,13 @@
+## 1.2.0
+
+Backward incompatible change: (@fabiocaccamo)
+
+ - In version < 1.2.0 all single quotes ( ' ) were removed, and
+ moving forward, >= 1.2.0, they will be replaced with ( - ).
+ Example:
+ < 1.2.0 -- ('C\'est déjà l\'été.' -> "cest-deja-lete")
+ >= 1.2.0 -- ('C\'est déjà l\'été.' -> "c-est-deja-l-ete")
+
## 1.1.4
Bugfix:
diff --git a/slugify/__init__.py b/slugify/__init__.py
index 4dc1be5..8b20b5f 100644
--- a/slugify/__init__.py
+++ b/slugify/__init__.py
@@ -3,4 +3,4 @@ from .slugify import *
__author__ = 'Val Neekman @ Neekware Inc. [@vneekman]'
__description__ = 'A Python slugify application that also handles Unicode'
-__version__ = '1.1.4'
+__version__ = '1.2.0'
diff --git a/slugify/slugify.py b/slugify/slugify.py
index 9d17d3c..113afdd 100644
--- a/slugify/slugify.py
+++ b/slugify/slugify.py
@@ -29,7 +29,8 @@ NUMBERS_PATTERN = re.compile('(?<=\d),(?=\d)')
def smart_truncate(string, max_length=0, word_boundaries=False, separator=' ', save_order=False):
- """Truncate a string.
+ """
+ Truncate a string.
:param string (str): string for modification
:param max_length (int): output string length
:param word_boundaries (bool):
@@ -71,7 +72,8 @@ def smart_truncate(string, max_length=0, word_boundaries=False, separator=' ', s
def slugify(text, entities=True, decimal=True, hexadecimal=True, max_length=0, word_boundary=False,
separator='-', save_order=False, stopwords=()):
- """Make a slug from the given text.
+ """
+ Make a slug from the given text.
:param text (str): initial text
:param entities (bool):
:param decimal (bool):
@@ -88,11 +90,12 @@ 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')
+ # replace quotes with dashes - pre-process
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')
@@ -122,9 +125,11 @@ def slugify(text, entities=True, decimal=True, hexadecimal=True, max_length=0, w
# make the text lowercase
text = text.lower()
-
- # replace unwanted characters
+
+ # remove generated quotes -- post-process
text = QUOTE_PATTERN.sub('', text)
+
+ # replace unwanted characters
text = NUMBERS_PATTERN.sub('', text)
text = ALLOWED_CHARS_PATTERN.sub('-', text)