mity / md4c

C Markdown parser. Fast. SAX-like interface. Compliant to CommonMark specification.
MIT License
776 stars 146 forks source link

Invalid HTML with --fpermissive-url-autolinks #53

Closed mitxela closed 5 years ago

mitxela commented 5 years ago

With permissive-url-autolinks enabled, md2html appears to generate an extra closing tag after an ordinary inline link.

$ echo "This is a [link](http://github.com/)." | ./md2html
<p>This is a <a href="http://github.com/">link</a>.</p>

$ echo "This is a [link](http://github.com/)." | ./md2html --fpermissive-url-autolinks
<p>This is a <a href="http://github.com/">link</a></a>.</p>
mity commented 5 years ago

Thanks, will take a look at it.

mity commented 5 years ago

Interesting. The bug depends on the char just after the link.

When dot follows:

 $ echo '[link](http://github.com).' | md2html/md2html.exe --github
<p><a href="http://github.com">link</a></a>.</p>

When a letter follows, it's broken in a different way:

$ echo '[link](http://github.com)X' | md2html/md2html.exe --github
<p><a href="http://github.com">link</a>X</a></p>

And when space or EOF follows, it works correctly:

$ echo '[link](http://github.com) ' | md2html/md2html.exe --github
<p><a href="http://github.com">link</a></p>
mity commented 5 years ago

With permissive WWW autolinks, there is the same issue:

/prj/md4c/build $ echo '[link](www.github.com).' | md2html/md2html.exe --github
<p><a href="www.github.com">link</a></a>.</p>
/prj/md4c/build $ echo '[link](www.github.com)X' | md2html/md2html.exe --github
<p><a href="www.github.com">link</a>X</a></p>