Commit 5aad1d42 authored by Emanuil's avatar Emanuil
Browse files

inline links should work with images

parent 3ff5c623
......@@ -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 = '<img alt="'.$matches[2].'" src="'.$matches[3].'">';
$element = '<img alt="'.$matches[3].'" src="'.$matches[4].'">';
$element_text = $this->parse_inline_elements($matches[2]);
$element_text = $this->parse_inline_elements($matches[3]);
$element = '<a href="'.$matches[3].'">'.$element_text.'</a>';
$element = '<a href="'.$matches[4].'">'.$element_text.'</a>';
$element_text = $this->parse_inline_elements($matches[1]);
<p>Here's a <a href="">link</a>.</p>
<p>Here's an image link: <a href=""><img alt="MD Logo" src=""></a>.</p>
\ No newline at end of file
Here's a [link](
Here's an image link: [![MD Logo](](
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment