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:
parent
3ff5c623f2
commit
5aad1d42d2
@ -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]);
|
||||
|
@ -0,0 +1,2 @@
|
||||
<p>Here's a <a href="http://parsedown.org">link</a>.</p>
|
||||
<p>Here's an image link: <a href="http://daringfireball.net/projects/markdown/"><img alt="MD Logo" src="http://parsedown.org/md.png"></a>.</p>
|
@ -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/).
|
Loading…
Reference in New Issue
Block a user