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.
This commit is contained in:
Aidan Woods 2016-10-02 17:37:08 +01:00 committed by GitHub
parent d6d5f53ff4
commit 4d3600f273
1 changed files with 36 additions and 3 deletions

View File

@ -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']);