1
0
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:
Aidan Woods 2018-03-28 20:59:56 +01:00
parent 40e797031e
commit 9f1f5de387
No known key found for this signature in database
GPG Key ID: 9A6A8EFAA512BBB9

View File

@ -1567,6 +1567,27 @@ class Parsedown
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)
{
@ -1575,6 +1596,7 @@ class Parsedown
$Element = $this->sanitiseElement($Element);
}
# identity map if element has no handler
$Element = $this->handle($Element);
$hasName = isset($Element['name']);