Skip to content

Commit

Permalink
Merge pull request #319 from malcolmr/fix-code-in-links
Browse files Browse the repository at this point in the history
Stop XML escaping the body of a link.
  • Loading branch information
nicholasserra committed Jan 23, 2019
2 parents a1c2850 + 80616d8 commit 2861765
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/markdown2.py
Expand Up @@ -1408,7 +1408,7 @@ def _do_links(self, text):
result_head = '<a href="#"%s>' % (title_str)
else:
result_head = '<a href="%s"%s>' % (_html_escape_url(url, safe_mode=self.safe_mode), title_str)
result = '%s%s</a>' % (result_head, _xml_escape_attr(link_text))
result = '%s%s</a>' % (result_head, link_text)
if "smarty-pants" in self.extras:
result = result.replace('"', self._escape_table['"'])
# <img> allowed from curr_pos on, <a> from
Expand Down
4 changes: 3 additions & 1 deletion test/tm-cases/inline_links.html
@@ -1,6 +1,8 @@
<p>an inline <a href="/url/">link</a></p>

<p>a <a href="/url/" title="title">link &quot;with&quot; title</a></p>
<p>a <a href="/url/" title="title">link "with" title</a></p>

<p>an inline <a href="/url/">link with <code>code</code></a></p>

<p>an inline <img src="/url/" alt="image link" /></p>

Expand Down
2 changes: 2 additions & 0 deletions test/tm-cases/inline_links.text
Expand Up @@ -2,6 +2,8 @@ an inline [link](/url/)

a [link "with" title](/url/ "title")

an inline [link with `code`](/url/)

an inline ![image link](/url/)

an ![image "with" title](/url/ "title")
6 changes: 3 additions & 3 deletions test/tm-cases/long_link.html
@@ -1,12 +1,12 @@
<h1>works</h1>

<p><a href="http://tuxdeluxe.org/node/287">wever installation of Kunnafonix was resisted by many of the local organizations they had to work with The local &quot;computer person&quot; resented a solution that was so easy to use that it undermined the power and prestige they received by being the person to consult when a Windows computer had problems</a></p>
<p><a href="http://tuxdeluxe.org/node/287">wever installation of Kunnafonix was resisted by many of the local organizations they had to work with The local "computer person" resented a solution that was so easy to use that it undermined the power and prestige they received by being the person to consult when a Windows computer had problems</a></p>

<h1>issue 24: these fail</h1>

<p><a href="http://tuxdeluxe.org/node/287">wever installation of Kunnafonix was resisted by many of the local organizations they had to
work with The local &quot;computer person&quot; resented a solution that was so easy to use that it undermined
work with The local "computer person" resented a solution that was so easy to use that it undermined
the power and prestige they received by being the person to consult when a Windows computer had
problems</a></p>

<p><a href="http://tuxdeluxe.org/node/287">However installation of Kunnafonix was resisted by many of the local organizations they had to work with The local &quot;computer person&quot; resented a solution that was so easy to use that it undermined the power and prestige they received by being the person to consult when a Windows computer had problems</a></p>
<p><a href="http://tuxdeluxe.org/node/287">However installation of Kunnafonix was resisted by many of the local organizations they had to work with The local "computer person" resented a solution that was so easy to use that it undermined the power and prestige they received by being the person to consult when a Windows computer had problems</a></p>

0 comments on commit 2861765

Please sign in to comment.