From 4d3600f273cc3613cf420408c9016635216c15ea Mon Sep 17 00:00:00 2001 From: Aidan Woods Date: Sun, 2 Oct 2016 17:37:08 +0100 Subject: [PATCH] Extend disallowed assertion depth capabilities I've built on the functionality of feature 1. in the previous commit to allow non nestables to be asserted indefinitely, or to a specified depth. --- Parsedown.php | 39 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 36 insertions(+), 3 deletions(-) diff --git a/Parsedown.php b/Parsedown.php index e34efe8..b708236 100644 --- a/Parsedown.php +++ b/Parsedown.php @@ -1003,10 +1003,23 @@ class Parsedown foreach ($this->InlineTypes[$marker] as $inlineType) { - - if(in_array($inlineType, $non_nestables)) + foreach ($non_nestables as $key => $non_nestable) { - continue; + if (is_array($non_nestable)) + { + + if ($non_nestable[0] === $inlineType) + { + continue 2; + } + } + else + { + if ($non_nestable === $inlineType) + { + continue 2; + } + } } $Inline = $this->{'inline'.$inlineType}($Excerpt); @@ -1030,6 +1043,26 @@ class Parsedown $Inline['position'] = $markerPosition; } + foreach ($non_nestables as $key => $non_nestable) + { + if (is_array($non_nestable) && isset($non_nestable[1]) && is_int($non_nestable[1])){ + if($non_nestable[1] > 1) + { + $Inline['element']['non_nestables'][] = array($non_nestable[0], $non_nestable[1] -1); + } + + } + elseif (is_array($non_nestable) && ! isset($non_nestable[1])) + { + $Inline['element']['non_nestables'][] = array($non_nestable[0]); + } + elseif ( ! is_array($non_nestable)) + { + $Inline['element']['non_nestables'][] = $non_nestable; + } + } + + # the text that comes before the inline $unmarkedText = substr($text, 0, $Inline['position']);