Adjusted parser to render paragraphs which only contain a single image without the paragraph. So instead
<img ...>
it just renders<img ...><?php
/**
* Adjusted parser to render paragraphs which only contain a single image without the paragraph.
*
* So instead
* <p><img ...></p>
*
* it just renders
* <img ...>
*/
class Parser extends Parsedown
{
/**
* The regex which matches an markdown image definition
*
* @var string
*/
private $markdownImage = "~^!\[.*?\]\(.*?\)$~";
/**
* {@inheritdoc}
*/
protected function paragraph($Line)
{
if (1 === preg_match($this->markdownImage, $Line["text"]))
{
return $this->inlineImage($Line['text']);
}
return parent::paragraph($Line);
}
}