1635 switch($token[
'type']) {
1653 switch($token[
'name']) {
1656 case 'script':
case 'style':
1659 return $this->
inHead($token);
1664 case 'base':
case 'link':
case 'meta':
case 'title':
1667 return $this->
inHead($token);
1676 if(count($this->stack) === 1 || $this->stack[1]->nodeName !==
'body') {
1685 foreach($token[
'attr'] as $attr) {
1686 if(!$this->stack[1]->hasAttribute($attr[
'name'])) {
1687 $this->stack[1]->setAttribute($attr[
'name'], $attr[
'value']);
1696 case 'address':
case 'blockquote':
case 'center':
case 'dir':
1697 case 'div':
case 'dl':
case 'fieldset':
case 'listing':
1698 case 'menu':
case 'ol':
case 'p':
case 'ul':
1717 if($this->form_pointer !== null) {
1735 $this->form_pointer = $element;
1740 case 'li':
case 'dd':
case 'dt':
1751 $stack_length = count($this->stack) - 1;
1753 for(
$n = $stack_length; 0 <=
$n;
$n--) {
1757 $node = $this->stack[
$n];
1763 if($token[
'name'] === $node->tagName || ($token[
'name'] !==
'li' 1764 && ($node->tagName ===
'dd' || $node->tagName ===
'dt'))) {
1765 for($x = $stack_length; $x >=
$n ; $x--) {
1766 array_pop($this->stack);
1775 if($cat !== self::FORMATTING && $cat !== self::PHRASING &&
1776 $node->tagName !==
'address' && $node->tagName !==
'div') {
1806 case 'h1':
case 'h2':
case 'h3':
case 'h4':
case 'h5':
case 'h6':
1821 while($this->
elementInScope(array(
'h1',
'h2',
'h3',
'h4',
'h5',
'h6'))) {
1822 array_pop($this->stack);
1840 $leng = count($this->a_formatting);
1842 for(
$n = $leng - 1;
$n >= 0;
$n--) {
1843 if($this->a_formatting[
$n] === self::MARKER) {
1846 } elseif($this->a_formatting[
$n]->nodeName ===
'a') {
1863 $this->a_formatting[] = $el;
1868 case 'b':
case 'big':
case 'em':
case 'font':
case 'i':
1869 case 'nobr':
case 's':
case 'small':
case 'strike':
1870 case 'strong':
case 'tt':
case 'u':
1879 $this->a_formatting[] = $el;
1903 $this->a_formatting[] = self::MARKER;
1907 case 'marquee':
case 'object':
1916 $this->a_formatting[] = self::MARKER;
1946 $this->mode = self::IN_TABLE;
1951 case 'area':
case 'basefont':
case 'bgsound':
case 'br':
1952 case 'embed':
case 'img':
case 'param':
case 'spacer':
1961 array_pop($this->stack);
1979 array_pop($this->stack);
1986 $token[
'name'] =
'img';
1987 return $this->
inBody($token);
2001 $this->form_pointer !== null
2002 ? $this->form_pointer->appendChild($element)
2003 : end($this->stack)->appendChild($element);
2006 array_pop($this->stack);
2016 if($this->form_pointer === null) {
2050 $this->
insertText(
'This is a searchable index. '.
2051 'Insert your search keywords here: ');
2057 $attr = $token[
'attr'];
2058 $attr[] = array(
'name' =>
'name',
'value' =>
'isindex');
2068 $this->
insertText(
'This is a searchable index. '.
2069 'Insert your search keywords here: ');
2112 case 'iframe':
case 'noembed':
case 'noframes':
2128 $this->mode = self::IN_SELECT;
2134 case 'caption':
case 'col':
case 'colgroup':
case 'frame':
2135 case 'frameset':
case 'head':
case 'option':
case 'optgroup':
2136 case 'tbody':
case 'td':
case 'tfoot':
case 'th':
case 'thead':
2144 case 'event-source':
case 'section':
case 'nav':
case 'article':
2145 case 'aside':
case 'header':
case 'footer':
case 'datagrid':
2161 switch($token[
'name']) {
2167 if(count($this->stack) < 2 || $this->stack[1]->nodeName !==
'body') {
2172 } elseif(end($this->stack)->nodeName !==
'body') {
2177 $this->mode = self::AFTER_BODY;
2196 case 'address':
case 'blockquote':
case 'center':
case 'dir':
2197 case 'div':
case 'dl':
case 'fieldset':
case 'listing':
2198 case 'menu':
case 'ol':
case 'pre':
case 'ul':
2214 for(
$n = count($this->stack) - 1;
$n >= 0;
$n--) {
2215 if($this->stack[
$n]->nodeName === $token[
'name']) {
2219 array_pop($this->stack);
2234 if(end($this->stack)->nodeName !== $token[
'name']) {
2244 array_pop($this->stack);
2248 $this->form_pointer = null;
2265 for(
$n = count($this->stack) - 1;
$n >= 0;
$n--) {
2267 array_pop($this->stack);
2277 case 'dd':
case 'dt':
case 'li':
2293 for(
$n = count($this->stack) - 1;
$n >= 0;
$n--) {
2294 if($this->stack[
$n]->nodeName === $token[
'name']) {
2298 array_pop($this->stack);
2305 case 'h1':
case 'h2':
case 'h3':
case 'h4':
case 'h5':
case 'h6':
2306 $elements = array(
'h1',
'h2',
'h3',
'h4',
'h5',
'h6');
2323 array_pop($this->stack);
2330 case 'a':
case 'b':
case 'big':
case 'em':
case 'font':
2331 case 'i':
case 'nobr':
case 's':
case 'small':
case 'strike':
2332 case 'strong':
case 'tt':
case 'u':
2341 for($a = count($this->a_formatting) - 1; $a >= 0; $a--) {
2342 if($this->a_formatting[$a] === self::MARKER) {
2345 } elseif($this->a_formatting[$a]->tagName === $token[
'name']) {
2346 $formatting_element = $this->a_formatting[$a];
2347 $in_stack = in_array($formatting_element, $this->stack,
true);
2357 if(!isset($formatting_element) || ($in_stack &&
2365 } elseif(isset($formatting_element) && !$in_stack) {
2366 unset($this->a_formatting[$fe_af_pos]);
2367 $this->a_formatting = array_merge($this->a_formatting);
2376 $fe_s_pos = array_search($formatting_element, $this->stack,
true);
2377 $length = count($this->stack);
2379 for($s = $fe_s_pos + 1; $s < $length; $s++) {
2382 if($category !== self::PHRASING && $category !== self::FORMATTING) {
2383 $furthest_block = $this->stack[$s];
2393 if(!isset($furthest_block)) {
2394 for(
$n = $length - 1;
$n >= $fe_s_pos;
$n--) {
2395 array_pop($this->stack);
2398 unset($this->a_formatting[$fe_af_pos]);
2399 $this->a_formatting = array_merge($this->a_formatting);
2406 $common_ancestor = $this->stack[$fe_s_pos - 1];
2410 if($furthest_block->parentNode !== null) {
2411 $furthest_block->parentNode->removeChild($furthest_block);
2418 $bookmark = $fe_af_pos;
2422 $node = $furthest_block;
2423 $last_node = $furthest_block;
2426 for(
$n = array_search($node, $this->stack,
true) - 1;
$n >= 0;
$n--) {
2429 $node = $this->stack[
$n];
2435 if(!in_array($node, $this->a_formatting,
true)) {
2436 unset($this->stack[
$n]);
2437 $this->stack = array_merge($this->stack);
2447 if($node === $formatting_element) {
2454 } elseif($last_node === $furthest_block) {
2455 $bookmark = array_search($node, $this->a_formatting,
true) + 1;
2464 if($node->hasChildNodes()) {
2465 $clone = $node->cloneNode();
2466 $s_pos = array_search($node, $this->stack,
true);
2467 $a_pos = array_search($node, $this->a_formatting,
true);
2469 $this->stack[$s_pos] = $clone;
2470 $this->a_formatting[$a_pos] = $clone;
2476 if($last_node->parentNode !== null) {
2477 $last_node->parentNode->removeChild($last_node);
2480 $node->appendChild($last_node);
2490 if($last_node->parentNode !== null) {
2491 $last_node->parentNode->removeChild($last_node);
2494 $common_ancestor->appendChild($last_node);
2498 $clone = $formatting_element->cloneNode();
2503 while($furthest_block->hasChildNodes()) {
2504 $child = $furthest_block->firstChild;
2505 $furthest_block->removeChild($child);
2506 $clone->appendChild($child);
2510 $furthest_block->appendChild($clone);
2516 $fe_af_pos = array_search($formatting_element, $this->a_formatting,
true);
2517 unset($this->a_formatting[$fe_af_pos]);
2518 $this->a_formatting = array_merge($this->a_formatting);
2520 $af_part1 = array_slice($this->a_formatting, 0, $bookmark - 1);
2521 $af_part2 = array_slice($this->a_formatting, $bookmark, count($this->a_formatting));
2522 $this->a_formatting = array_merge($af_part1, array($clone), $af_part2);
2529 $fe_s_pos = array_search($formatting_element, $this->stack,
true);
2530 $fb_s_pos = array_search($furthest_block, $this->stack,
true);
2531 unset($this->stack[$fe_s_pos]);
2533 $s_part1 = array_slice($this->stack, 0, $fb_s_pos);
2534 $s_part2 = array_slice($this->stack, $fb_s_pos + 1, count($this->stack));
2535 $this->stack = array_merge($s_part1, array($clone), $s_part2);
2538 unset($formatting_element, $fe_af_pos, $fe_s_pos, $furthest_block);
2544 case 'button':
case 'marquee':
case 'object':
2560 for(
$n = count($this->stack) - 1;
$n >= 0;
$n--) {
2561 if($this->stack[
$n]->nodeName === $token[
'name']) {
2565 array_pop($this->stack);
2568 $marker = end(array_keys($this->a_formatting, self::MARKER,
true));
2570 for(
$n = count($this->a_formatting) - 1;
$n > $marker;
$n--) {
2571 array_pop($this->a_formatting);
2580 case 'area':
case 'basefont':
case 'bgsound':
case 'br':
2581 case 'embed':
case 'hr':
case 'iframe':
case 'image':
2582 case 'img':
case 'input':
case 'isindex':
case 'noembed':
2583 case 'noframes':
case 'param':
case 'select':
case 'spacer':
2584 case 'table':
case 'textarea':
case 'wbr':
2590 for(
$n = count($this->stack) - 1;
$n >= 0;
$n--) {
2593 $node = end($this->stack);
2597 if($token[
'name'] === $node->nodeName) {
2608 for($x = count($this->stack) -
$n; $x >=
$n; $x--) {
2609 array_pop($this->stack);
2615 if($category !== self::SPECIAL && $category !== self::SCOPING) {
getElementCategory($node)
generateImpliedEndTags($exclude=array())
elementInScope($el, $table=false)
insertElement($token, $append=true, $check=false)
reconstructActiveFormattingElements()