Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ci - Normalize accented text twice. #143

Merged
merged 4 commits into from
Jan 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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