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

inline links should work with images

This commit is contained in:
Emanuil
2013-07-25 01:33:40 +03:00
parent 3ff5c623f2
commit 5aad1d42d2
3 changed files with 9 additions and 4 deletions

View File

@@ -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].'">';
}
else
{
$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]);