make it possible to disable block and inline types

This commit is contained in:
Lukas Kahwe Smith 2019-12-01 17:47:32 +01:00
parent 6d89393817
commit b2c38b6e5c

View File

@ -101,6 +101,24 @@ class Parsedown
'steam:',
);
function setDisabledBlockTypes($disabledBlockTypes)
{
$this->disabledBlockTypes = $disabledBlockTypes;
return $this;
}
protected $disabledBlockTypes = false;
function setDisabledInlineTypes($disabledInlineTypes)
{
$this->disabledInlineTypes = $disabledInlineTypes;
return $this;
}
protected $disabledInlineTypes = false;
#
# Lines
#
@ -220,6 +238,11 @@ class Parsedown
{
foreach ($this->BlockTypes[$marker] as $blockType)
{
if ($this->disabledBlockTypes && in_array($blockType, $this->disabledBlockTypes))
{
continue;
}
$blockTypes []= $blockType;
}
}
@ -1067,6 +1090,11 @@ class Parsedown
foreach ($this->InlineTypes[$marker] as $inlineType)
{
if ($this->disabledInlineTypes && in_array($inlineType, $this->disabledInlineTypes))
{
continue;
}
# check to see if the current inline type is nestable in the current context
if ( ! empty($nonNestables) and in_array($inlineType, $nonNestables))
@ -1493,7 +1521,7 @@ class Parsedown
{
$markup .= '>';
if (!isset($Element['nonNestables']))
if (!isset($Element['nonNestables']))
{
$Element['nonNestables'] = array();
}