From a8877279075edc6b9fa496efb9aa0aa9d9682f4f Mon Sep 17 00:00:00 2001 From: Benny Date: Fri, 23 Sep 2016 18:50:56 +0200 Subject: [PATCH] ParsedownGravTrait `addBlockType` and `addInlineType` enhancements --- .../Grav/Common/Markdown/ParsedownGravTrait.php | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/system/src/Grav/Common/Markdown/ParsedownGravTrait.php b/system/src/Grav/Common/Markdown/ParsedownGravTrait.php index 19b7103862..c697f19221 100644 --- a/system/src/Grav/Common/Markdown/ParsedownGravTrait.php +++ b/system/src/Grav/Common/Markdown/ParsedownGravTrait.php @@ -69,16 +69,23 @@ protected function init($page, $defaults) */ public function addBlockType($type, $tag, $continuable = false, $completable = false, $index = null) { + $block = &$this->unmarkedBlockTypes; + if ($type) { + if (!isset($this->BlockTypes[$type])) { + $this->BlockTypes[$type] = []; + } + $block = &$this->BlockTypes[$type]; + } + if (!isset($index)) { - $this->BlockTypes[$type] [] = $tag; + $block[] = $tag; } else { - array_splice($this->BlockTypes[$type], $index, 0, $tag); + array_splice($block, $index, 0, [$tag]); } if ($continuable) { $this->continuable_blocks[] = $tag; } - if ($completable) { $this->completable_blocks[] = $tag; } @@ -92,10 +99,10 @@ public function addBlockType($type, $tag, $continuable = false, $completable = f */ public function addInlineType($type, $tag, $index = null) { - if (!isset($index)) { + if (!isset($index) || !isset($this->InlineTypes[$type])) { $this->InlineTypes[$type] [] = $tag; } else { - array_splice($this->InlineTypes[$type], $index, 0, $tag); + array_splice($this->InlineTypes[$type], $index, 0, [$tag]); } if (strpos($this->inlineMarkerList, $type) === false) {