1
0
mirror of https://github.com/erusev/parsedown.git synced 2023-08-10 21:13:06 +03:00

Permit empty links

This commit is contained in:
Aidan Woods 2019-01-27 20:53:11 +00:00
parent 5ada761532
commit 0f55cd5b26
No known key found for this signature in database
GPG Key ID: 9A6A8EFAA512BBB9
5 changed files with 8 additions and 10 deletions

View File

@ -61,8 +61,8 @@ final class Link implements Inline
$remainder = \substr($remainder, $width); $remainder = \substr($remainder, $width);
if (\preg_match('/^[(]\s*+((?:[^ ()]++|[(][^ )]+[)])++)(?:[ ]+("[^"]*+"|\'[^\']*+\'))?\s*+[)]/', $remainder, $matches)) { if (\preg_match('/^[(]\s*+(?:((?:[^ ()]++|[(][^ )]+[)])++)(?:[ ]+("[^"]*+"|\'[^\']*+\'))?\s*+)?[)]/', $remainder, $matches)) {
$url = $matches[1]; $url = isset($matches[1]) ? $matches[1] : '';
$title = isset($matches[2]) ? \substr($matches[2], 1, - 1) : null; $title = isset($matches[2]) ? \substr($matches[2], 1, - 1) : null;
$width += \strlen($matches[0]); $width += \strlen($matches[0]);

View File

@ -1,3 +1 @@
<p><a href="#fragment">link</a></p> <p><a href="">link</a></p>
<p><a href="http://example.com#fragment">link</a></p>
<p><a href="http://example.com?foo=3#frag">link</a></p>

View File

@ -1,5 +1 @@
[link](#fragment) [link]()
[link](http://example.com#fragment)
[link](http://example.com?foo=3#frag)

View File

@ -0,0 +1 @@
<p><a href="">foo</a></p>

View File

@ -0,0 +1,3 @@
[foo]()
[foo]: /url1