Gregwar/RST

Embedded URIs with newlines result in incorrect anchors

terrencegf opened this issue · 0 comments

Embedded URIs should allow for newlines as shown in an example at http://docutils.sourceforge.net/docs/user/rst/quickref.html#hyperlink-targets . The current parsing of links assumes the link is contained on a single line, which can result in empty anchor links. Examples:

Correct when all on one line:

INPUT 
`Google <https://google.com>`_

OUTPUT
<p><a href="https://google.com">Google</a></p>

Incorrect when spanning two lines:

INPUT 
`Google
<https://google.com>`_

OUTPUT
<p><a href="">Google
&lt;https://google.com&gt;</a></p>

Note that the Online reStructuredText Editor (http://rst.ninjs.org) correctly renders the link in both cases.

I think the fix requires Parser.php to have a new 'state' when parsing links to allow for links that span multiple lines.