Skip to content

Commit

Permalink
Ci - Normalize accented text twice. (#143)
Browse files Browse the repository at this point in the history
* pre normalize, upversion node support in ci/cd, more test
  • Loading branch information
un33k committed Jan 25, 2024
1 parent 499112d commit e52c35e
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 12 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ jobs:
python: [3.7, 3.8, 3.9, "3.10", 3.11, 3.12, pypy3.8]

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: setup python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python }}
- name: Install dependencies
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ jobs:
python: [3.7, 3.8, 3.9, "3.10", 3.11, 3.12, pypy3.8]

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: setup python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python }}
- name: Install dependencies
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ jobs:
python: [3.7, 3.8, 3.9, "3.10", 3.11, 3.12, pypy3.8]

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: setup python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python }}
- name: Install dependencies
Expand Down
5 changes: 3 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
## Work in progress

- Added typing to API and expose `py.typed`.
- Formally support 3.12
## 8.0.2

- Normalize text before converting to unicode. (@chuckyblack - thx)

## 8.0.1

Expand Down
2 changes: 1 addition & 1 deletion slugify/__version__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
__url__ = 'https://github.com/un33k/python-slugify'
__license__ = 'MIT'
__copyright__ = 'Copyright 2022 Val Neekman @ Neekware Inc.'
__version__ = '8.0.1'
__version__ = '8.0.2'
9 changes: 6 additions & 3 deletions slugify/slugify.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,11 @@ def slugify(
# replace quotes with dashes - pre-process
text = QUOTE_PATTERN.sub(DEFAULT_SEPARATOR, text)

# decode unicode
if not allow_unicode:
# normalize text, convert to unicode if required
if allow_unicode:
text = unicodedata.normalize('NFKC', text)
else:
text = unicodedata.normalize('NFKD', text)
text = unidecode.unidecode(text)

# ensure text is still in unicode
Expand All @@ -144,7 +147,7 @@ def slugify(
except Exception:
pass

# translate
# re normalize text
if allow_unicode:
text = unicodedata.normalize('NFKC', text)
else:
Expand Down
4 changes: 4 additions & 0 deletions test.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ def test_phonetic_conversion_of_eastern_scripts(self):
self.assertEqual(r, "ying-shi-ma")

def test_accented_text(self):
txt = '𝐚́́𝕒́àáâäãąā'
r = slugify(txt)
self.assertEqual(r, "aaaaaaaaa")

txt = 'C\'est déjà l\'été.'
r = slugify(txt)
self.assertEqual(r, "c-est-deja-l-ete")
Expand Down

0 comments on commit e52c35e

Please sign in to comment.