Skip to content

Commit

Permalink
Update _slugify to use utf-8 encoding
Browse files Browse the repository at this point in the history
  • Loading branch information
Crozzers committed Nov 9, 2023
1 parent 958eea4 commit c09c744
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion lib/markdown2.py
Original file line number Diff line number Diff line change
Expand Up @@ -2843,7 +2843,7 @@ def _slugify(value):
From Django's "django/template/defaultfilters.py".
"""
import unicodedata
value = unicodedata.normalize('NFKD', value).encode('ascii', 'ignore').decode()
value = unicodedata.normalize('NFKD', value).encode('utf-8', 'ignore').decode()
value = _slugify_strip_re.sub('', value).strip().lower()
return _slugify_hyphenate_re.sub('-', value)
## end of http://code.activestate.com/recipes/577257/ }}}
Expand Down
2 changes: 1 addition & 1 deletion test/tm-cases/header_ids_4.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<!-- -*- coding: utf-8 -*- -->

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

<ul>
<li>apples</li>
Expand Down
4 changes: 2 additions & 2 deletions test/tm-cases/toc_4.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<h1 id="python">Python</h1>

<h2 id="-1">蟒蛇</h2>
<h2 id="蟒蛇">蟒蛇</h2>

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

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

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

<ul>
<li>类型</li>
Expand Down
4 changes: 2 additions & 2 deletions test/tm-cases/toc_4.toc_html
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<ul>
<li><a href="#python">Python</a>
<ul>
<li><a href="#-1">蟒蛇</a></li>
<li><a href="#蟒蛇">蟒蛇</a></li>
<li><a href="#markdown">Markdown</a></li>
<li><a href="#-2">标记语言</a></li>
<li><a href="#标记语言">标记语言</a></li>
</ul></li>
</ul>

0 comments on commit c09c744

Please sign in to comment.