diff --git a/Parsedown.php b/Parsedown.php index 5ea2e74..9369c91 100755 --- a/Parsedown.php +++ b/Parsedown.php @@ -558,19 +558,19 @@ class Parsedown # Inline Link / Image - if (strpos($text, '](') !== FALSE and preg_match_all('/(!?)\[(.*?)\]\((.*?)\)/', $text, $matches, PREG_SET_ORDER)) # inline + if (strpos($text, '](') !== FALSE and preg_match_all('/(!?)(\[((?:[^][]+|(?2))*)\])\((.*?)\)/', $text, $matches, PREG_SET_ORDER)) # inline { foreach ($matches as $matches) { if ($matches[1]) # image { - $element = ''.$matches[2].''; + $element = ''.$matches[3].''; } else { - $element_text = $this->parse_inline_elements($matches[2]); + $element_text = $this->parse_inline_elements($matches[3]); - $element = ''.$element_text.''; + $element = ''.$element_text.''; } $element_text = $this->parse_inline_elements($matches[1]); diff --git a/tests/data/inline_link.html b/tests/data/inline_link.html index e69de29..4ad6eb7 100644 --- a/tests/data/inline_link.html +++ b/tests/data/inline_link.html @@ -0,0 +1,2 @@ +

Here's a link.

+

Here's an image link: MD Logo.

\ No newline at end of file diff --git a/tests/data/inline_link.md b/tests/data/inline_link.md index e69de29..52979f4 100644 --- a/tests/data/inline_link.md +++ b/tests/data/inline_link.md @@ -0,0 +1,3 @@ +Here's a [link](http://parsedown.org). + +Here's an image link: [![MD Logo](http://parsedown.org/md.png)](http://daringfireball.net/projects/markdown/). \ No newline at end of file