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
32 changes: 31 additions & 1 deletion Parsedown.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,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 @@ -1109,7 +1127,14 @@ public function line($text, $nonNestables=array())
$markup .= $this->unmarkedText($unmarkedText);

# compile the inline
$markup .= isset($Inline['markup']) ? $Inline['markup'] : $this->element($Inline['element']);
if (isset($Inline['markup']))
$markup .= $Inline['markup'];
else
{
# make sure element is not stripped
if (!$this->isElementStripped($Inline['element']))
$markup .= $this->element($Inline['element']);
}

# remove the examined text
$text = substr($text, $Inline['position'] + $Inline['extent']);
Expand Down Expand Up @@ -1467,6 +1492,11 @@ protected function unmarkedText($text)
# Handlers
#

protected function isElementStripped(array $Element)
{
return (isset($Element['name']) && in_array($Element['name'], $this->strippedElements));
}

protected function element(array $Element)
{
if ($this->safeMode)
Expand Down