Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
Mi Yu committed Sep 8, 2018
2 parents 0f3da7a + f0179b7 commit 846a419
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 8 deletions.
2 changes: 1 addition & 1 deletion makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ benchmark:
${PYTHON_EXEC} test/benchmark.py

commonmark:
${PYTHON_EXEC} test/commonmark/commonmark.py
${PYTHON_EXEC} -m test.commonmark

docs:
${PYTHON_EXEC} -m docs
Expand Down
9 changes: 3 additions & 6 deletions mistletoe/html_renderer.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ def __exit__(self, *args):

def render_to_plain(self, token):
if hasattr(token, 'children'):
return self.render_inner(token)
inner = [self.render_to_plain(child) for child in token.children]
return ''.join(inner)
return self.escape_html(token.content)

def render_strong(self, token):
Expand All @@ -64,15 +65,11 @@ def render_strikethrough(self, token):

def render_image(self, token):
template = '<img src="{}" alt="{}"{} />'
render_func = self.render
self.render = self.render_to_plain
inner = self.render_inner(token)
self.render = render_func
if token.title:
title = ' title="{}"'.format(self.escape_html(token.title))
else:
title = ''
return template.format(token.src, inner, title)
return template.format(token.src, self.render_to_plain(token), title)

def render_link(self, token):
template = '<a href="{target}"{title}>{inner}</a>'
Expand Down
2 changes: 1 addition & 1 deletion test/test_html_renderer.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def test_strikethrough(self):
self._test_token('Strikethrough', '<del>inner</del>')

def test_image(self):
output = '<img src="src" alt="inner" title="title" />'
output = '<img src="src" alt="" title="title" />'
self._test_token('Image', output, src='src', title='title')

def test_link(self):
Expand Down

0 comments on commit 846a419

Please sign in to comment.