Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 29 additions & 2 deletions Parsedown.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,24 @@ function setUrlsLinked($urlsLinked)
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)
Expand Down Expand Up @@ -316,6 +334,11 @@ protected function linesElements(array $lines)
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']))
Expand Down Expand Up @@ -1199,8 +1222,12 @@ protected function lineElements($text, $nonNestables = array())
$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']);
Expand Down