diff --git a/Parsedown.php b/Parsedown.php index a34b44f0f..8d010e649 100644 --- a/Parsedown.php +++ b/Parsedown.php @@ -101,6 +101,24 @@ function setSafeMode($safeMode) '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 @@ protected function lines(array $lines) { foreach ($this->BlockTypes[$marker] as $blockType) { + if ($this->disabledBlockTypes && in_array($blockType, $this->disabledBlockTypes)) + { + continue; + } + $blockTypes []= $blockType; } } @@ -1067,6 +1090,11 @@ public function line($text, $nonNestables=array()) 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 @@ protected function element(array $Element) { $markup .= '>'; - if (!isset($Element['nonNestables'])) + if (!isset($Element['nonNestables'])) { $Element['nonNestables'] = array(); }