Skip to content

Commit e52c35e

Browse files
authored
Ci - Normalize accented text twice. (#143)
* pre normalize, upversion node support in ci/cd, more test
1 parent 499112d commit e52c35e

File tree

7 files changed

+20
-12
lines changed

7 files changed

+20
-12
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ jobs:
1717
python: [3.7, 3.8, 3.9, "3.10", 3.11, 3.12, pypy3.8]
1818

1919
steps:
20-
- uses: actions/checkout@v3
20+
- uses: actions/checkout@v4
2121
- name: setup python
22-
uses: actions/setup-python@v4
22+
uses: actions/setup-python@v5
2323
with:
2424
python-version: ${{ matrix.python }}
2525
- name: Install dependencies

.github/workflows/dev.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ jobs:
1717
python: [3.7, 3.8, 3.9, "3.10", 3.11, 3.12, pypy3.8]
1818

1919
steps:
20-
- uses: actions/checkout@v3
20+
- uses: actions/checkout@v4
2121
- name: setup python
22-
uses: actions/setup-python@v4
22+
uses: actions/setup-python@v5
2323
with:
2424
python-version: ${{ matrix.python }}
2525
- name: Install dependencies

.github/workflows/main.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ jobs:
1616
python: [3.7, 3.8, 3.9, "3.10", 3.11, 3.12, pypy3.8]
1717

1818
steps:
19-
- uses: actions/checkout@v3
19+
- uses: actions/checkout@v4
2020
- name: setup python
21-
uses: actions/setup-python@v4
21+
uses: actions/setup-python@v5
2222
with:
2323
python-version: ${{ matrix.python }}
2424
- name: Install dependencies

CHANGELOG.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
## Work in progress
22

3-
- Added typing to API and expose `py.typed`.
4-
- Formally support 3.12
3+
## 8.0.2
4+
5+
- Normalize text before converting to unicode. (@chuckyblack - thx)
56

67
## 8.0.1
78

slugify/__version__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@
55
__url__ = 'https://github.com/un33k/python-slugify'
66
__license__ = 'MIT'
77
__copyright__ = 'Copyright 2022 Val Neekman @ Neekware Inc.'
8-
__version__ = '8.0.1'
8+
__version__ = '8.0.2'

slugify/slugify.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,11 @@ def slugify(
118118
# replace quotes with dashes - pre-process
119119
text = QUOTE_PATTERN.sub(DEFAULT_SEPARATOR, text)
120120

121-
# decode unicode
122-
if not allow_unicode:
121+
# normalize text, convert to unicode if required
122+
if allow_unicode:
123+
text = unicodedata.normalize('NFKC', text)
124+
else:
125+
text = unicodedata.normalize('NFKD', text)
123126
text = unidecode.unidecode(text)
124127

125128
# ensure text is still in unicode
@@ -144,7 +147,7 @@ def slugify(
144147
except Exception:
145148
pass
146149

147-
# translate
150+
# re normalize text
148151
if allow_unicode:
149152
text = unicodedata.normalize('NFKC', text)
150153
else:

test.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ def test_phonetic_conversion_of_eastern_scripts(self):
3636
self.assertEqual(r, "ying-shi-ma")
3737

3838
def test_accented_text(self):
39+
txt = '𝐚́́𝕒́àáâäãąā'
40+
r = slugify(txt)
41+
self.assertEqual(r, "aaaaaaaaa")
42+
3943
txt = 'C\'est déjà l\'été.'
4044
r = slugify(txt)
4145
self.assertEqual(r, "c-est-deja-l-ete")

0 commit comments

Comments
 (0)