1
0
mirror of https://github.com/erusev/parsedown.git synced 2023-08-10 21:13:06 +03:00

Add seperate depth-first function instead of replacing recursive method

This commit is contained in:
Aidan Woods 2018-04-08 17:39:24 +01:00
parent 1d65fb858a
commit cdaf86b039
No known key found for this signature in database
GPG Key ID: 9A6A8EFAA512BBB9

View File

@ -1631,6 +1631,22 @@ class Parsedown
}
protected function elementApplyRecursive($closure, array $Element)
{
$Element = call_user_func($closure, $Element);
if (isset($Element['elements']))
{
$Element['elements'] = $this->elementsApplyRecursive($closure, $Element['elements']);
}
elseif (isset($Element['element']))
{
$Element['element'] = $this->elementApplyRecursive($closure, $Element['element']);
}
return $Element;
}
protected function elementApplyRecursiveDepthFirst($closure, array $Element)
{
if (isset($Element['elements']))
{
@ -1658,6 +1674,18 @@ class Parsedown
return $newElements;
}
protected function elementsApplyRecursiveDepthFirst($closure, array $Elements)
{
$newElements = array();
foreach ($Elements as $Element)
{
$newElements[] = $this->elementApplyRecursiveDepthFirst($closure, $Element);
}
return $newElements;
}
protected function element(array $Element)
{
if ($this->safeMode)