mirror of
https://github.com/erusev/parsedown.git
synced 2023-08-10 21:13:06 +03:00
Add recursive handle methods to generate entire AST for traversal
This commit is contained in:
parent
40e797031e
commit
9f1f5de387
|
@ -1567,6 +1567,27 @@ class Parsedown
|
||||||
return $Element;
|
return $Element;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function handleElementRecursive(array $Element)
|
||||||
|
{
|
||||||
|
$Element = $this->handle($Element);
|
||||||
|
|
||||||
|
if (isset($Element['elements']))
|
||||||
|
{
|
||||||
|
$Element['elements'] = $this->handleElementsRecursive($Element['elements']);
|
||||||
|
}
|
||||||
|
elseif (isset($Element['element']))
|
||||||
|
{
|
||||||
|
$Element['element'] = $this->handleElementRecursive($Element['element']);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $Element;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function handleElementsRecursive(array $Elements)
|
||||||
|
{
|
||||||
|
return array_map(array($this, 'handleElementRecursive'), $Elements);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
protected function element(array $Element)
|
protected function element(array $Element)
|
||||||
{
|
{
|
||||||
|
@ -1575,6 +1596,7 @@ class Parsedown
|
||||||
$Element = $this->sanitiseElement($Element);
|
$Element = $this->sanitiseElement($Element);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# identity map if element has no handler
|
||||||
$Element = $this->handle($Element);
|
$Element = $this->handle($Element);
|
||||||
|
|
||||||
$hasName = isset($Element['name']);
|
$hasName = isset($Element['name']);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user