Skip to content

Commit b15d37d

Browse files
Merge pull request #535 from Crozzers/fix-non-ascii-header-ids
Update `_slugify` to use utf-8 encoding (issue #534)
2 parents 958eea4 + 756e024 commit b15d37d

File tree

5 files changed

+7
-6
lines changed

5 files changed

+7
-6
lines changed

CHANGES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
- [pull #527] Fix base64 images being corrupted in safe mode (issue #526)
77
- [pull #529] Add `breaks` extra with ability to hard break on backslashes (issue #525)
88
- [pull #532] Fix #493 persisting when `code-friendly` extra enabled
9+
- [pull #535] Update `_slugify` to use utf-8 encoding (issue #534)
910

1011
## python-markdown2 2.4.10
1112

lib/markdown2.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2843,7 +2843,7 @@ def _slugify(value):
28432843
From Django's "django/template/defaultfilters.py".
28442844
"""
28452845
import unicodedata
2846-
value = unicodedata.normalize('NFKD', value).encode('ascii', 'ignore').decode()
2846+
value = unicodedata.normalize('NFKD', value).encode('utf-8', 'ignore').decode()
28472847
value = _slugify_strip_re.sub('', value).strip().lower()
28482848
return _slugify_hyphenate_re.sub('-', value)
28492849
## end of http://code.activestate.com/recipes/577257/ }}}

test/tm-cases/header_ids_4.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<!-- -*- coding: utf-8 -*- -->
22

3-
<h1 id="fruit-really-likes">Fruit заголовок <em>really</em> likes</h1>
3+
<h1 id="fruit-заголовок-really-likes">Fruit заголовок <em>really</em> likes</h1>
44

55
<ul>
66
<li>apples</li>

test/tm-cases/toc_4.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<h1 id="python">Python</h1>
22

3-
<h2 id="-1">蟒蛇</h2>
3+
<h2 id="蟒蛇">蟒蛇</h2>
44

55
<ul>
66
<li>外形特性</li>
@@ -9,7 +9,7 @@ <h2 id="-1">蟒蛇</h2>
99

1010
<h2 id="markdown">Markdown</h2>
1111

12-
<h2 id="-2">标记语言</h2>
12+
<h2 id="标记语言">标记语言</h2>
1313

1414
<ul>
1515
<li>类型</li>

test/tm-cases/toc_4.toc_html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<ul>
22
<li><a href="#python">Python</a>
33
<ul>
4-
<li><a href="#-1">蟒蛇</a></li>
4+
<li><a href="#蟒蛇">蟒蛇</a></li>
55
<li><a href="#markdown">Markdown</a></li>
6-
<li><a href="#-2">标记语言</a></li>
6+
<li><a href="#标记语言">标记语言</a></li>
77
</ul></li>
88
</ul>

0 commit comments

Comments
 (0)