2179 switch ($token[
'type']) {
2197 switch ($token[
'name']) {
2204 return $this->
inHead($token);
2215 return $this->
inHead($token);
2224 if (count($this->stack) === 1 || $this->stack[1]->nodeName !==
'body') {
2233 foreach ($token[
'attr'] as $attr) {
2234 if (!$this->stack[1]->hasAttribute($attr[
'name'])) {
2235 $this->stack[1]->setAttribute($attr[
'name'], $attr[
'value']);
2276 if ($this->form_pointer !== null) {
2296 $this->form_pointer = $element;
2316 $stack_length = count($this->stack) - 1;
2318 for (
$n = $stack_length; 0 <=
$n;
$n--) {
2322 $node = $this->stack[
$n];
2328 if ($token[
'name'] === $node->tagName || ($token[
'name'] !==
'li' 2329 && ($node->tagName ===
'dd' || $node->tagName ===
'dt'))
2331 for (
$x = $stack_length;
$x >=
$n;
$x--) {
2332 array_pop($this->stack);
2341 if ($cat !== self::FORMATTING && $cat !== self::PHRASING &&
2342 $node->tagName !==
'address' && $node->tagName !==
'div' 2398 array_pop($this->stack);
2416 $leng = count($this->a_formatting);
2418 for (
$n = $leng - 1;
$n >= 0;
$n--) {
2419 if ($this->a_formatting[
$n] === self::MARKER) {
2422 } elseif ($this->a_formatting[
$n]->nodeName ===
'a') {
2441 $this->a_formatting[] = $el;
2466 $this->a_formatting[] = $el;
2492 $this->a_formatting[] = self::MARKER;
2506 $this->a_formatting[] = self::MARKER;
2538 $this->mode = self::IN_TABLE;
2559 array_pop($this->stack);
2579 array_pop($this->stack);
2586 $token[
'name'] =
'img';
2587 return $this->
inBody($token);
2601 $this->form_pointer !== null
2602 ? $this->form_pointer->appendChild($element)
2603 : end($this->stack)->appendChild($element);
2606 array_pop($this->stack);
2616 if ($this->form_pointer === null) {
2659 'This is a searchable index. ' .
2660 'Insert your search keywords here: ' 2667 $attr = $token[
'attr'];
2668 $attr[] =
array(
'name' =>
'name',
'value' =>
'isindex');
2681 'This is a searchable index. ' .
2682 'Insert your search keywords here: ' 2752 $this->mode = self::IN_SELECT;
2778 case 'event-source':
2801 switch ($token[
'name']) {
2807 if (count($this->stack) < 2 || $this->stack[1]->nodeName !==
'body') {
2812 } elseif (end($this->stack)->nodeName !==
'body') {
2817 $this->mode = self::AFTER_BODY;
2865 for (
$n = count($this->stack) - 1;
$n >= 0;
$n--) {
2866 if ($this->stack[
$n]->nodeName === $token[
'name']) {
2870 array_pop($this->stack);
2885 if (end($this->stack)->nodeName !== $token[
'name']) {
2895 array_pop($this->stack);
2899 $this->form_pointer = null;
2916 for (
$n = count($this->stack) - 1;
$n >= 0;
$n--) {
2918 array_pop($this->stack);
2946 for (
$n = count($this->stack) - 1;
$n >= 0;
$n--) {
2947 if ($this->stack[
$n]->nodeName === $token[
'name']) {
2951 array_pop($this->stack);
2964 $elements =
array(
'h1',
'h2',
'h3',
'h4',
'h5',
'h6');
2981 array_pop($this->stack);
3009 for ($a = count($this->a_formatting) - 1; $a >= 0; $a--) {
3010 if ($this->a_formatting[$a] === self::MARKER) {
3013 } elseif ($this->a_formatting[$a]->tagName === $token[
'name']) {
3014 $formatting_element = $this->a_formatting[$a];
3015 $in_stack = in_array($formatting_element, $this->stack,
true);
3025 if (!isset($formatting_element) || ($in_stack &&
3034 } elseif (isset($formatting_element) && !$in_stack) {
3035 unset($this->a_formatting[$fe_af_pos]);
3036 $this->a_formatting = array_merge($this->a_formatting);
3045 $fe_s_pos = array_search($formatting_element, $this->stack,
true);
3046 $length = count($this->stack);
3048 for ($s = $fe_s_pos + 1; $s < $length; $s++) {
3051 if ($category !== self::PHRASING && $category !== self::FORMATTING) {
3052 $furthest_block = $this->stack[$s];
3062 if (!isset($furthest_block)) {
3063 for (
$n = $length - 1;
$n >= $fe_s_pos;
$n--) {
3064 array_pop($this->stack);
3067 unset($this->a_formatting[$fe_af_pos]);
3068 $this->a_formatting = array_merge($this->a_formatting);
3075 $common_ancestor = $this->stack[$fe_s_pos - 1];
3079 if ($furthest_block->parentNode !== null) {
3080 $furthest_block->parentNode->removeChild($furthest_block);
3087 $bookmark = $fe_af_pos;
3091 $node = $furthest_block;
3092 $last_node = $furthest_block;
3095 for (
$n = array_search($node, $this->stack,
true) - 1;
$n >= 0;
$n--) {
3098 $node = $this->stack[
$n];
3104 if (!in_array($node, $this->a_formatting,
true)) {
3105 unset($this->stack[
$n]);
3106 $this->stack = array_merge($this->stack);
3116 if ($node === $formatting_element) {
3123 } elseif ($last_node === $furthest_block) {
3124 $bookmark = array_search($node, $this->a_formatting,
true) + 1;
3133 if ($node->hasChildNodes()) {
3134 $clone = $node->cloneNode();
3135 $s_pos = array_search($node, $this->stack,
true);
3136 $a_pos = array_search($node, $this->a_formatting,
true);
3138 $this->stack[$s_pos] = $clone;
3139 $this->a_formatting[$a_pos] = $clone;
3145 if ($last_node->parentNode !== null) {
3146 $last_node->parentNode->removeChild($last_node);
3149 $node->appendChild($last_node);
3159 if ($last_node->parentNode !== null) {
3160 $last_node->parentNode->removeChild($last_node);
3163 $common_ancestor->appendChild($last_node);
3167 $clone = $formatting_element->cloneNode();
3172 while ($furthest_block->hasChildNodes()) {
3173 $child = $furthest_block->firstChild;
3174 $furthest_block->removeChild($child);
3175 $clone->appendChild($child);
3179 $furthest_block->appendChild($clone);
3185 $fe_af_pos = array_search($formatting_element, $this->a_formatting,
true);
3186 unset($this->a_formatting[$fe_af_pos]);
3187 $this->a_formatting = array_merge($this->a_formatting);
3189 $af_part1 = array_slice($this->a_formatting, 0, $bookmark - 1);
3190 $af_part2 = array_slice($this->a_formatting, $bookmark, count($this->a_formatting));
3191 $this->a_formatting = array_merge($af_part1,
array($clone), $af_part2);
3198 $fe_s_pos = array_search($formatting_element, $this->stack,
true);
3199 $fb_s_pos = array_search($furthest_block, $this->stack,
true);
3200 unset($this->stack[$fe_s_pos]);
3202 $s_part1 = array_slice($this->stack, 0, $fb_s_pos);
3203 $s_part2 = array_slice($this->stack, $fb_s_pos + 1, count($this->stack));
3204 $this->stack = array_merge($s_part1,
array($clone), $s_part2);
3207 unset($formatting_element, $fe_af_pos, $fe_s_pos, $furthest_block);
3231 for (
$n = count($this->stack) - 1;
$n >= 0;
$n--) {
3232 if ($this->stack[
$n]->nodeName === $token[
'name']) {
3236 array_pop($this->stack);
3239 $marker = end(array_keys($this->a_formatting, self::MARKER,
true));
3241 for (
$n = count($this->a_formatting) - 1;
$n > $marker;
$n--) {
3242 array_pop($this->a_formatting);
3275 for (
$n = count($this->stack) - 1;
$n >= 0;
$n--) {
3278 $node = end($this->stack);
3282 if ($token[
'name'] === $node->nodeName) {
3293 for (
$x = count($this->stack) -
$n;
$x >=
$n;
$x--) {
3294 array_pop($this->stack);
3300 if ($category !== self::SPECIAL && $category !== self::SCOPING) {
getElementCategory($node)
generateImpliedEndTags($exclude=array())
elementInScope($el, $table=false)
insertElement($token, $append=true, $check=false)
Create styles array
The data for the language used.
reconstructActiveFormattingElements()