erusev / parsedown

Better Markdown Parser in PHP
https://parsedown.org
MIT License
14.74k stars 1.12k forks source link

Unable to handle link markdown [link](text) #704

Open laukstein opened 5 years ago

laukstein commented 5 years ago

Links markdown

[https://domain.com/]("foo bar")

[https://domain.com/](foo bar)

[https://domain.com/](foo)

results

<p>[<a href="https://domain.com/]("foo">https://domain.com/]("foo</a> bar&quot;)</p>
<p>[<a href="https://domain.com/](foo">https://domain.com/](foo</a> bar)</p>
<p><a href="foo"><a href="https://domain.com/">https://domain.com/</a></a></p>

while expected to result

<p><a href="https://domain.com/" title="foo bar">https://domain.com/</a></p>
<p><a href="https://domain.com/" title="foo bar">https://domain.com/</a></p>
<p><a href="https://domain.com/" title="foo">https://domain.com/</a></p>

grabilla q17112

aidantwoods commented 5 years ago

GitHub renders these like:

<p>[https://domain.com/]("foo bar")</p>
<p>[https://domain.com/](foo bar)</p>
<p><a href="foo">https://domain.com/</a></p>

So I think this is the expected result here. The first two aren't valid links (according to CommonMark), and Parsedown is doing the correct thing in that respect. Although Parsedown is incorrectly inserting autolinks (according to extended autolinks defined in the GFM spec), so I fixed that in c0db218d2275d387a72ae0f1f66b66e22df0c6e0.

Screenshot 2019-03-26 at 21 46 54