mirror of
https://github.com/erusev/parsedown.git
synced 2023-08-10 21:13:06 +03:00
Merge pull request #608 from aidantwoods/fix/recursion
Add seperate depth-first function instead of replacing recursive method
This commit is contained in:
commit
1d68e5506c
@ -1631,6 +1631,22 @@ class Parsedown
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected function elementApplyRecursive($closure, array $Element)
|
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']))
|
if (isset($Element['elements']))
|
||||||
{
|
{
|
||||||
@ -1648,14 +1664,22 @@ class Parsedown
|
|||||||
|
|
||||||
protected function elementsApplyRecursive($closure, array $Elements)
|
protected function elementsApplyRecursive($closure, array $Elements)
|
||||||
{
|
{
|
||||||
$newElements = array();
|
foreach ($Elements as &$Element)
|
||||||
|
|
||||||
foreach ($Elements as $Element)
|
|
||||||
{
|
{
|
||||||
$newElements[] = $this->elementApplyRecursive($closure, $Element);
|
$Element = $this->elementApplyRecursive($closure, $Element);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $newElements;
|
return $Elements;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function elementsApplyRecursiveDepthFirst($closure, array $Elements)
|
||||||
|
{
|
||||||
|
foreach ($Elements as &$Element)
|
||||||
|
{
|
||||||
|
$Element = $this->elementApplyRecursiveDepthFirst($closure, $Element);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $Elements;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function element(array $Element)
|
protected function element(array $Element)
|
||||||
|
Loading…
Reference in New Issue
Block a user