Validates nodes according to definition and returns modification.
{
$this->whitespace = false;
if (empty($tokens_of_children)) return false;
$nesting = 0;
$all_whitespace = true;
$seen_li = false;
$need_close_li = false;
foreach ($tokens_of_children as $token) {
if (!empty($token->is_whitespace)) {
continue;
}
$all_whitespace = false;
if ($nesting == 1 && $need_close_li) {
$nesting--;
$need_close_li = false;
}
$is_child = ($nesting == 0);
$nesting++;
$nesting--;
}
if ($is_child) {
if ($token->name === 'li') {
$seen_li = true;
} elseif ($token->name === 'ul' || $token->name === 'ol') {
$need_close_li = true;
$nesting++;
if (!$seen_li) {
$result[] =
new HTMLPurifier_Token_Start(
'li');
} else {
while(true) {
trigger_error("Only li present invariant violated in List ChildDef", E_USER_ERROR);
return false;
}
break;
trigger_error("Only li present invariant violated in List ChildDef", E_USER_ERROR);
return false;
}
$result[] =
new HTMLPurifier_Token_Start(
'li',
$t->attr,
$t->line,
$t->col,
$t->armor);
break;
} else {
if (!
$t->is_whitespace) {
trigger_error("Only whitespace present invariant violated in List ChildDef", E_USER_ERROR);
return false;
}
}
}
}
} else {
$result[] =
new HTMLPurifier_Token_Start(
'li');
$nesting++;
$seen_li = true;
$need_close_li = true;
}
}
}
if ($need_close_li) {
}
if ($all_whitespace) {
return false;
}
if ($tokens_of_children ==
$result)
return true;
}