41 public function execute($tokens, $config, $context)
52 $definition = $config->getHTMLDefinition();
54 $excludes_enabled = !$config->get(
'Core.DisableExcludes');
60 $is_inline = $definition->info_parent_def->descendants_are_inline;
61 $context->register(
'IsInline', $is_inline);
64 $e =& $context->get(
'ErrorCollector',
true);
73 $exclude_stack = array($definition->info_parent_def->excludes);
79 list($token,
$d) = $node->toTokenPair();
80 $context->register(
'CurrentNode', $node);
81 $context->register(
'CurrentToken', $token);
103 $parent_def = $definition->info_parent_def;
106 $parent_def->descendants_are_inline,
107 $parent_def->excludes,
111 while (!empty($stack)) {
112 list($node, $is_inline, $excludes, $ix) = array_pop($stack);
115 $def = empty($stack) ? $definition->info_parent_def : $definition->info[$node->name];
116 while (isset($node->children[$ix])) {
117 $child = $node->children[$ix++];
120 $stack[] = array($node, $is_inline, $excludes, $ix);
121 $stack[] = array($child,
124 $is_inline || $def->descendants_are_inline,
125 empty($def->excludes) ? $excludes
126 : array_merge($excludes, $def->excludes),
132 list($token,
$d) = $node->toTokenPair();
134 if ($excludes_enabled && isset($excludes[$node->name])) {
136 if ($e) $e->send(E_ERROR,
'Strategy_FixNesting: Node excluded');
142 foreach ($node->children as $child) {
143 if (!$child->dead) $children[] = $child;
145 $result = $def->child->validateChildren($children, $config, $context);
148 $node->children = $children;
151 if ($e) $e->send(E_ERROR,
'Strategy_FixNesting: Node removed');
156 if (empty(
$result) && !empty($children)) {
157 $e->send(E_ERROR,
'Strategy_FixNesting: Node contents removed');
158 }
else if (
$result != $children) {
159 $e->send(E_WARNING,
'Strategy_FixNesting: Node reorganized');
170 $context->destroy(
'IsInline');
171 $context->destroy(
'CurrentNode');
172 $context->destroy(
'CurrentToken');