Skip to content

Commit

Permalink
Merge pull request #344 from alphatownsman/emsp
Browse files Browse the repository at this point in the history
keep leading unicode spaces like emsp (full-width space)
  • Loading branch information
lepture committed Jun 7, 2023
2 parents 6f93b02 + d07faa9 commit 1f66750
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/mistune/markdown.py
Expand Up @@ -53,7 +53,8 @@ def _iter_render(self, tokens, state):
elif 'text' in tok:
text = tok.pop('text')
# process inline text
tok['children'] = self.inline(text.strip(), state.env)
# avoid striping emsp or other unicode spaces
tok['children'] = self.inline(text.strip(' \r\n\t\f'), state.env)
yield tok

def parse(self, s: str, state: Optional[BlockState]=None):
Expand Down
7 changes: 7 additions & 0 deletions tests/test_misc.py
Expand Up @@ -96,3 +96,10 @@ def test_ast_output(self):
},
]
self.assertEqual(result, expected)


def test_emsp(self):
md = mistune.create_markdown(escape=False, hard_wrap=True)
result = md('\u2003\u2003foo\nbar\n\n\u2003\u2003foobar')
expected = '<p>\u2003\u2003foo<br />\nbar</p>\n<p>\u2003\u2003foobar</p>'
self.assertEqual(result.strip(), expected)

0 comments on commit 1f66750

Please sign in to comment.