2180 switch (
$token[
'type']) {
2198 switch (
$token[
'name']) {
2225 if (count($this->stack) === 1 || $this->stack[1]->nodeName !==
'body') {
2234 foreach (
$token[
'attr'] as $attr) {
2235 if (!$this->stack[1]->hasAttribute($attr[
'name'])) {
2236 $this->stack[1]->setAttribute($attr[
'name'], $attr[
'value']);
2277 if ($this->form_pointer !== null) {
2297 $this->form_pointer = $element;
2317 $stack_length = count($this->stack) - 1;
2319 for (
$n = $stack_length; 0 <=
$n;
$n--) {
2323 $node = $this->stack[
$n];
2329 if (
$token[
'name'] === $node->tagName || (
$token[
'name'] !==
'li' 2330 && ($node->tagName ===
'dd' || $node->tagName ===
'dt'))
2332 for (
$x = $stack_length;
$x >=
$n;
$x--) {
2333 array_pop($this->stack);
2342 if ($cat !== self::FORMATTING && $cat !== self::PHRASING &&
2343 $node->tagName !==
'address' && $node->tagName !==
'div' 2398 while ($this->
elementInScope(array(
'h1',
'h2',
'h3',
'h4',
'h5',
'h6'))) {
2399 array_pop($this->stack);
2417 $leng = count($this->a_formatting);
2419 for (
$n = $leng - 1;
$n >= 0;
$n--) {
2420 if ($this->a_formatting[
$n] === self::MARKER) {
2423 } elseif ($this->a_formatting[
$n]->nodeName ===
'a') {
2442 $this->a_formatting[] = $el;
2467 $this->a_formatting[] = $el;
2493 $this->a_formatting[] = self::MARKER;
2507 $this->a_formatting[] = self::MARKER;
2539 $this->mode = self::IN_TABLE;
2560 array_pop($this->stack);
2580 array_pop($this->stack);
2602 $this->form_pointer !== null
2603 ? $this->form_pointer->appendChild($element)
2604 : end($this->stack)->appendChild($element);
2607 array_pop($this->stack);
2617 if ($this->form_pointer === null) {
2660 'This is a searchable index. ' .
2661 'Insert your search keywords here: ' 2669 $attr[] = array(
'name' =>
'name',
'value' =>
'isindex');
2682 'This is a searchable index. ' .
2683 'Insert your search keywords here: ' 2753 $this->mode = self::IN_SELECT;
2779 case 'event-source':
2802 switch (
$token[
'name']) {
2808 if (count($this->stack) < 2 || $this->stack[1]->nodeName !==
'body') {
2813 } elseif (end($this->stack)->nodeName !==
'body') {
2818 $this->mode = self::AFTER_BODY;
2866 for (
$n = count($this->stack) - 1;
$n >= 0;
$n--) {
2867 if ($this->stack[
$n]->nodeName ===
$token[
'name']) {
2871 array_pop($this->stack);
2886 if (end($this->stack)->nodeName !==
$token[
'name']) {
2896 array_pop($this->stack);
2900 $this->form_pointer = null;
2917 for (
$n = count($this->stack) - 1;
$n >= 0;
$n--) {
2919 array_pop($this->stack);
2947 for (
$n = count($this->stack) - 1;
$n >= 0;
$n--) {
2948 if ($this->stack[
$n]->nodeName ===
$token[
'name']) {
2952 array_pop($this->stack);
2965 $elements = array(
'h1',
'h2',
'h3',
'h4',
'h5',
'h6');
2982 array_pop($this->stack);
3010 for ($a = count($this->a_formatting) - 1; $a >= 0; $a--) {
3011 if ($this->a_formatting[$a] === self::MARKER) {
3014 } elseif ($this->a_formatting[$a]->tagName ===
$token[
'name']) {
3015 $formatting_element = $this->a_formatting[$a];
3016 $in_stack = in_array($formatting_element, $this->stack,
true);
3026 if (!isset($formatting_element) || ($in_stack &&
3035 } elseif (isset($formatting_element) && !$in_stack) {
3036 unset($this->a_formatting[$fe_af_pos]);
3037 $this->a_formatting = array_merge($this->a_formatting);
3046 $fe_s_pos = array_search($formatting_element, $this->stack,
true);
3047 $length = count($this->stack);
3049 for (
$s = $fe_s_pos + 1;
$s < $length;
$s++) {
3052 if ($category !== self::PHRASING && $category !== self::FORMATTING) {
3053 $furthest_block = $this->stack[
$s];
3063 if (!isset($furthest_block)) {
3064 for (
$n = $length - 1;
$n >= $fe_s_pos;
$n--) {
3065 array_pop($this->stack);
3068 unset($this->a_formatting[$fe_af_pos]);
3069 $this->a_formatting = array_merge($this->a_formatting);
3076 $common_ancestor = $this->stack[$fe_s_pos - 1];
3080 if ($furthest_block->parentNode !== null) {
3081 $furthest_block->parentNode->removeChild($furthest_block);
3088 $bookmark = $fe_af_pos;
3092 $node = $furthest_block;
3093 $last_node = $furthest_block;
3096 for (
$n = array_search($node, $this->stack,
true) - 1;
$n >= 0;
$n--) {
3099 $node = $this->stack[
$n];
3105 if (!in_array($node, $this->a_formatting,
true)) {
3106 unset($this->stack[
$n]);
3107 $this->stack = array_merge($this->stack);
3117 if ($node === $formatting_element) {
3124 } elseif ($last_node === $furthest_block) {
3125 $bookmark = array_search($node, $this->a_formatting,
true) + 1;
3134 if ($node->hasChildNodes()) {
3135 $clone = $node->cloneNode();
3136 $s_pos = array_search($node, $this->stack,
true);
3137 $a_pos = array_search($node, $this->a_formatting,
true);
3139 $this->stack[$s_pos] = $clone;
3140 $this->a_formatting[$a_pos] = $clone;
3146 if ($last_node->parentNode !== null) {
3147 $last_node->parentNode->removeChild($last_node);
3150 $node->appendChild($last_node);
3160 if ($last_node->parentNode !== null) {
3161 $last_node->parentNode->removeChild($last_node);
3164 $common_ancestor->appendChild($last_node);
3168 $clone = $formatting_element->cloneNode();
3173 while ($furthest_block->hasChildNodes()) {
3174 $child = $furthest_block->firstChild;
3175 $furthest_block->removeChild($child);
3176 $clone->appendChild($child);
3180 $furthest_block->appendChild($clone);
3186 $fe_af_pos = array_search($formatting_element, $this->a_formatting,
true);
3187 unset($this->a_formatting[$fe_af_pos]);
3188 $this->a_formatting = array_merge($this->a_formatting);
3190 $af_part1 = array_slice($this->a_formatting, 0, $bookmark - 1);
3191 $af_part2 = array_slice($this->a_formatting, $bookmark, count($this->a_formatting));
3192 $this->a_formatting = array_merge($af_part1, array($clone), $af_part2);
3199 $fe_s_pos = array_search($formatting_element, $this->stack,
true);
3200 $fb_s_pos = array_search($furthest_block, $this->stack,
true);
3201 unset($this->stack[$fe_s_pos]);
3203 $s_part1 = array_slice($this->stack, 0, $fb_s_pos);
3204 $s_part2 = array_slice($this->stack, $fb_s_pos + 1, count($this->stack));
3205 $this->stack = array_merge($s_part1, array($clone), $s_part2);
3208 unset($formatting_element, $fe_af_pos, $fe_s_pos, $furthest_block);
3232 for (
$n = count($this->stack) - 1;
$n >= 0;
$n--) {
3233 if ($this->stack[
$n]->nodeName ===
$token[
'name']) {
3237 array_pop($this->stack);
3240 $marker = end(array_keys($this->a_formatting, self::MARKER,
true));
3242 for (
$n = count($this->a_formatting) - 1;
$n > $marker;
$n--) {
3243 array_pop($this->a_formatting);
3276 for (
$n = count($this->stack) - 1;
$n >= 0;
$n--) {
3279 $node = end($this->stack);
3283 if (
$token[
'name'] === $node->nodeName) {
3294 for (
$x = count($this->stack) -
$n;
$x >=
$n;
$x--) {
3295 array_pop($this->stack);
3301 if ($category !== self::SPECIAL && $category !== self::SCOPING) {
getElementCategory($node)
generateImpliedEndTags($exclude=array())
elementInScope($el, $table=false)
insertElement($token, $append=true, $check=false)
reconstructActiveFormattingElements()