Skip to content

Commit fc7e8a1

Browse files
authored
Merge pull request #267 from transifex/github-markdown-handle-non-unicode
Handle non Unicode spaces
2 parents e43dce4 + ea1664e commit fc7e8a1

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

openformats/formats/github_markdown_v2.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import re
44

55
import six
6-
6+
import unicodedata
77
from mistune import Markdown
88
from yaml.reader import Reader
99

@@ -71,7 +71,7 @@ def parse(self, content, **kwargs):
7171
# need to do the same in order to be able to match the substrings
7272
template = content.expandtabs(4)
7373
pattern = re.compile(ensure_unicode(r'^ +$'), re.M)
74-
content = pattern.sub('', template)
74+
content = unicodedata.normalize('NFKC', pattern.sub('', template))
7575

7676
stringset = []
7777

openformats/tests/formats/github_markdown_v2/test_github_markdown.py

+7
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,13 @@ def test_parse(self):
3434
content_with_spaces = self.handler.parse(content=u"# foo bar")
3535
self.assertEqual(content_with_tab[0], content_with_spaces[0])
3636

37+
def test_parse_non_unicode(self):
38+
"""Test parse converts tabs to spaces"""
39+
content_with_non_unicode_space = self.handler.parse(content=u"# foo\xa0bar")
40+
content_with_normal_space = self.handler.parse(content=u"# foo bar")
41+
self.assertEqual(
42+
content_with_non_unicode_space[0], content_with_normal_space[0])
43+
3744

3845
class GithubMarkdownV2CustomTestCase(unittest.TestCase):
3946
"""Tests some additional functionality of GithubMarkdownHandlerV2.

0 commit comments

Comments
 (0)