diff --git a/Parsedown.php b/Parsedown.php index ca888d7..d729740 100755 --- a/Parsedown.php +++ b/Parsedown.php @@ -1298,7 +1298,7 @@ class Parsedown return; } - if (preg_match('/^\([ ]*([^ ]+?)(?:[ ]+(".+?"|\'.+?\'))?[ ]*\)/', $remainder, $matches)) + if (preg_match('/^[(]((?:[^ (]|[(][^ )]+[)])+)(?:[ ]+("[^"]+"|\'[^\']+\'))?[)]/', $remainder, $matches)) { $Element['attributes']['href'] = $matches[1]; diff --git a/test/data/inline_link.html b/test/data/inline_link.html index 226fa53..0a0e0a7 100644 --- a/test/data/inline_link.html +++ b/test/data/inline_link.html @@ -1,4 +1,4 @@ -

link and another link

+

link and another link

link

MD Logo

MD Logo and text

\ No newline at end of file diff --git a/test/data/inline_link.md b/test/data/inline_link.md index cd8e5a6..bef9031 100644 --- a/test/data/inline_link.md +++ b/test/data/inline_link.md @@ -1,4 +1,4 @@ -[link](http://example.com) and [another link](/tests/) +[link](http://example.com) and [another link](/url-with-(parentheses)) [`link`](http://example.com) diff --git a/test/data/inline_link_title.html b/test/data/inline_link_title.html index 70e589a..22cf309 100644 --- a/test/data/inline_link_title.html +++ b/test/data/inline_link_title.html @@ -1 +1,4 @@ -

single quotes and double quotes

\ No newline at end of file +

single quotes

+

double quotes

+

space

+

parentheses

\ No newline at end of file diff --git a/test/data/inline_link_title.md b/test/data/inline_link_title.md index 162b832..d756af1 100644 --- a/test/data/inline_link_title.md +++ b/test/data/inline_link_title.md @@ -1 +1,7 @@ -[single quotes](http://example.com 'Title') and [double quotes](http://example.com "Title") \ No newline at end of file +[single quotes](http://example.com 'Title') + +[double quotes](http://example.com "Title") + +[space](http://example.com "2 Words") + +[parentheses](http://example.com/url-(parentheses) "Title") \ No newline at end of file