This commit is contained in:
Stephen Sigwart 2020-08-24 22:04:29 +02:00 committed by GitHub
commit 738c9d65c0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 29 additions and 2 deletions

View File

@ -81,6 +81,24 @@ class Parsedown
return $this;
}
protected $strippedElements = array();
public function setStrippedImages($stripImages)
{
$pos = array_search('img', $this->strippedElements);
if ($stripImages)
{
if ($pos === false)
$this->strippedElements[] = 'img';
}
else
{
if ($pos !== false)
array_splice($this->strippedElements, $pos, 1);
}
}
protected $urlsLinked = true;
function setSafeMode($safeMode)
@ -316,6 +334,11 @@ class Parsedown
return $Elements;
}
protected function isElementStripped(array $Component)
{
return (isset($Component['element']['name']) && in_array($Component['element']['name'], $this->strippedElements));
}
protected function extractElement(array $Component)
{
if ( ! isset($Component['element']))
@ -1199,8 +1222,12 @@ class Parsedown
$InlineText = $this->inlineText($unmarkedText);
$Elements[] = $InlineText['element'];
# compile the inline
$Elements[] = $this->extractElement($Inline);
# make sure element is not stripped
if (!$this->isElementStripped($Inline))
{
# compile the inline
$Elements[] = $this->extractElement($Inline);
}
# remove the examined text
$text = substr($text, $Inline['position'] + $Inline['extent']);