diff --git a/slugify/slugify.py b/slugify/slugify.py index 9b5f27f..9daa8df 100644 --- a/slugify/slugify.py +++ b/slugify/slugify.py @@ -151,6 +151,7 @@ def slugify( text = unicodedata.normalize('NFKC', text) else: text = unicodedata.normalize('NFKD', text) + text = unidecode.unidecode(text) # make the text lowercase (optional) if lowercase: diff --git a/test.py b/test.py index fcec4b6..d561851 100644 --- a/test.py +++ b/test.py @@ -166,6 +166,26 @@ def test_html_decimal_on(self): r = slugify(txt, decimal=True) self.assertEqual(r, 'z') + def test_html_decimal_on_transliterated(self): + # A decoded numeric entity must be transliterated to ASCII exactly like + # the same character passed in directly (docstring: Ž -> Ž -> z). + txt = 'ß' # ß + r = slugify(txt, decimal=True) + self.assertEqual(r, slugify('ß')) + self.assertEqual(r, 'ss') + + def test_html_hexadecimal_on_transliterated(self): + txt = 'ß' # ß + r = slugify(txt, hexadecimal=True) + self.assertEqual(r, slugify('ß')) + self.assertEqual(r, 'ss') + + def test_html_entities_on_transliterated(self): + txt = 'ß' # ß + r = slugify(txt, entities=True) + self.assertEqual(r, slugify('ß')) + self.assertEqual(r, 'ss') + def test_html_decimal_off(self): txt = 'Ž' r = slugify(txt, entities=False, decimal=False)