39 $definition =
$config->getHTMLDefinition();
43 $parent_name = $definition->info_parent;
51 $is_inline = $definition->info_parent_def->descendants_are_inline;
52 $context->register(
'IsInline', $is_inline);
55 $e =& $context->get(
'ErrorCollector',
true);
68 $exclude_stack = array();
73 $context->register(
'CurrentToken', $start_token);
80 for ($i = 0,
$size = count($tokens) ; $i <
$size; ) {
86 $child_tokens = array();
90 for ($j = $i, $depth = 0; ; $j++) {
95 if ($depth == 1)
continue;
100 if ($depth == 0)
break;
102 $child_tokens[] = $tokens[$j];
108 $start_token = $tokens[$i];
114 if ($count = count($stack)) {
115 $parent_index = $stack[$count-1];
116 $parent_name = $tokens[$parent_index]->name;
117 if ($parent_index == 0) {
118 $parent_def = $definition->info_parent_def;
120 $parent_def = $definition->info[$parent_name];
127 $parent_index = $parent_name = $parent_def = null;
131 if ($is_inline ===
false) {
133 if (!empty($parent_def) && $parent_def->descendants_are_inline) {
134 $is_inline = $count - 1;
138 if ($count === $is_inline) {
150 if (!empty($exclude_stack)) {
151 foreach ($exclude_stack as $lookup) {
152 if (isset($lookup[$tokens[$i]->name])) {
171 $def = $definition->info_parent_def;
173 $def = $definition->info[$tokens[$i]->name];
177 if (!empty($def->child)) {
179 $result = $def->child->validateChildren(
180 $child_tokens,
$config, $context);
187 $excludes = $def->excludes;
202 if (!empty($excludes)) $exclude_stack[] = $excludes;
212 $e->send(E_ERROR,
'Strategy_FixNesting: Node excluded');
214 $e->send(E_ERROR,
'Strategy_FixNesting: Node removed');
219 $length = $j - $i + 1;
222 array_splice($tokens, $i, $length);
237 if (!$parent_def->child->allow_empty) {
250 $length = $j - $i - 1;
253 if (empty(
$result) && $length) {
254 $e->send(E_ERROR,
'Strategy_FixNesting: Node contents removed');
256 $e->send(E_WARNING,
'Strategy_FixNesting: Node reorganized');
261 array_splice($tokens, $i + 1, $length,
$result);
271 if (!empty($excludes)) $exclude_stack[] = $excludes;
286 $size = count($tokens);
293 if ($i == 0 || $i == $size - 1) {
295 $s_excludes = $definition->info_parent_def->excludes;
297 $s_excludes = $definition->info[$tokens[$i]->name]->excludes;
300 array_pop($exclude_stack);
312 array_shift($tokens);
316 $context->destroy(
'IsInline');
317 $context->destroy(
'CurrentToken');