Lines Matching refs:token

77     private $token;  variable in HTML5
683 $this->token = array(
775 $this->token = array(
826 $this->emitToken($this->token);
833 $this->emitToken($this->token);
848 $this->token['name'] .= strtolower($char);
871 $this->emitToken($this->token);
884 $this->emitToken($this->token);
894 $this->token['attr'][] = array(
926 $this->emitToken($this->token);
939 $this->emitToken($this->token);
948 $last = count($this->token['attr']) - 1;
949 $this->token['attr'][$last]['name'] .= strtolower($char);
978 $this->emitToken($this->token);
991 $this->emitToken($this->token);
1001 $this->token['attr'][] = array(
1045 $this->emitToken($this->token);
1052 $last = count($this->token['attr']) - 1;
1053 $this->token['attr'][$last]['value'] .= $char;
1079 $this->emitToken($this->token);
1088 $last = count($this->token['attr']) - 1;
1089 $this->token['attr'][$last]['value'] .= $char;
1115 $this->emitToken($this->token);
1124 $last = count($this->token['attr']) - 1;
1125 $this->token['attr'][$last]['value'] .= $char;
1154 $this->emitToken($this->token);
1161 $last = count($this->token['attr']) - 1;
1162 $this->token['attr'][$last]['value'] .= $char;
1180 $last = count($this->token['attr']) - 1;
1181 $this->token['attr'][$last]['value'] .= $char;
1221 $this->token = array(
1257 $this->emitToken($this->token);
1265 $this->token['data'] .= $char;
1284 $this->emitToken($this->token);
1292 $this->token['data'] .= '-' . $char;
1304 $this->emitToken($this->token);
1308 $this->token['data'] .= '-';
1311 $this->emitToken($this->token);
1316 $this->token['data'] .= '--' . $char;
1346 $this->token = array(
1378 $this->token = array(
1398 $this->emitToken($this->token);
1402 $this->token['name'] .= strtoupper($char);
1405 $this->emitToken($this->token);
1410 $this->token['name'] .= $char;
1413 $this->token['error'] = ($this->token['name'] === 'HTML')
1428 $this->emitToken($this->token);
1432 $this->emitToken($this->token);
1437 $this->token['error'] = true;
1449 $this->emitToken($this->token);
1453 $this->emitToken($this->token);
1554 private function emitToken($token) argument
1556 $emit = $this->tree->emitToken($token);
1561 } elseif ($token['type'] === self::ENDTAG) {
1713 public function emitToken($token) argument
1717 return $this->initPhase($token);
1720 return $this->rootElementPhase($token);
1723 return $this->mainPhase($token);
1726 return $this->trailingEndPhase($token);
1731 private function initPhase($token) argument
1744 if ((isset($token['error']) && $token['error']) ||
1745 $token['type'] === HTML5::COMMENT ||
1746 $token['type'] === HTML5::STARTTAG ||
1747 $token['type'] === HTML5::ENDTAG ||
1748 $token['type'] === HTML5::EOF ||
1749 ($token['type'] === HTML5::CHARACTR && isset($token['data']) &&
1750 !preg_match('/^[\t\n\x0b\x0c ]+$/', $token['data']))
1758 return $this->rootElementPhase($token);
1761 } elseif (isset($token['error']) && !$token['error']) {
1775 } elseif (isset($token['data']) && preg_match(
1777 $token['data']
1781 $text = $this->dom->createTextNode($token['data']);
1786 private function rootElementPhase($token) argument
1792 if ($token['type'] === HTML5::DOCTYPE) {
1796 } elseif ($token['type'] === HTML5::COMMENT) {
1799 $comment = $this->dom->createComment($token['data']);
1805 } elseif ($token['type'] === HTML5::CHARACTR &&
1806 preg_match('/^[\t\n\x0b\x0c ]+$/', $token['data'])
1809 $text = $this->dom->createTextNode($token['data']);
1818 } elseif (($token['type'] === HTML5::CHARACTR &&
1819 !preg_match('/^[\t\n\x0b\x0c ]+$/', $token['data'])) ||
1820 $token['type'] === HTML5::STARTTAG ||
1821 $token['type'] === HTML5::ENDTAG ||
1822 $token['type'] === HTML5::EOF
1832 return $this->mainPhase($token);
1836 private function mainPhase($token) argument
1841 if ($token['type'] === HTML5::DOCTYPE) {
1845 } elseif ($token['type'] === HTML5::STARTTAG && $token['name'] === 'html') {
1853 foreach ($token['attr'] as $attr) {
1860 } elseif ($token['type'] === HTML5::EOF) {
1869 return $this->beforeHead($token);
1872 return $this->inHead($token);
1875 return $this->afterHead($token);
1878 return $this->inBody($token);
1881 return $this->inTable($token);
1884 return $this->inCaption($token);
1887 return $this->inColumnGroup($token);
1890 return $this->inTableBody($token);
1893 return $this->inRow($token);
1896 return $this->inCell($token);
1899 return $this->inSelect($token);
1902 return $this->afterBody($token);
1905 return $this->inFrameset($token);
1908 return $this->afterFrameset($token);
1911 return $this->trailingEndPhase($token);
1917 private function beforeHead($token) argument
1924 if ($token['type'] === HTML5::CHARACTR &&
1925 preg_match('/^[\t\n\x0b\x0c ]+$/', $token['data'])
1928 $this->insertText($token['data']);
1931 } elseif ($token['type'] === HTML5::COMMENT) {
1934 $this->insertComment($token['data']);
1937 } elseif ($token['type'] === HTML5::STARTTAG && $token['name'] === 'head') {
1940 $element = $this->insertElement($token);
1953 } elseif ($token['type'] === HTML5::STARTTAG ||
1954 ($token['type'] === HTML5::ENDTAG && $token['name'] === 'html') ||
1955 ($token['type'] === HTML5::CHARACTR && !preg_match(
1957 $token['data']
1970 return $this->inHead($token);
1973 } elseif ($token['type'] === HTML5::ENDTAG) {
1978 private function inHead($token) argument
1989 if (($token['type'] === HTML5::CHARACTR &&
1990 preg_match('/^[\t\n\x0b\x0c ]+$/', $token['data'])) || (
1991 $token['type'] === HTML5::CHARACTR && in_array(
1997 $this->insertText($token['data']);
2000 } elseif ($token['type'] === HTML5::COMMENT) {
2003 $this->insertComment($token['data']);
2005 } elseif ($token['type'] === HTML5::ENDTAG &&
2006 in_array($token['name'], array('title', 'style', 'script'))
2012 } elseif ($token['type'] === HTML5::STARTTAG && $token['name'] === 'title') {
2017 $element = $this->insertElement($token, false);
2021 $element = $this->insertElement($token);
2028 } elseif ($token['type'] === HTML5::STARTTAG && $token['name'] === 'style') {
2033 $element = $this->insertElement($token, false);
2037 $this->insertElement($token);
2044 } elseif ($token['type'] === HTML5::STARTTAG && $token['name'] === 'script') {
2046 $element = $this->insertElement($token, false);
2053 } elseif ($token['type'] === HTML5::STARTTAG && in_array(
2054 $token['name'],
2062 $element = $this->insertElement($token, false);
2067 $this->insertElement($token);
2071 } elseif ($token['type'] === HTML5::ENDTAG && $token['name'] === 'head') {
2086 } elseif (($token['type'] === HTML5::STARTTAG && $token['name'] === 'head') ||
2087 ($token['type'] === HTML5::ENDTAG && $token['name'] !== 'html')
2109 return $this->afterHead($token);
2113 private function afterHead($token) argument
2120 if ($token['type'] === HTML5::CHARACTR &&
2121 preg_match('/^[\t\n\x0b\x0c ]+$/', $token['data'])
2124 $this->insertText($token['data']);
2127 } elseif ($token['type'] === HTML5::COMMENT) {
2130 $this->insertComment($token['data']);
2133 } elseif ($token['type'] === HTML5::STARTTAG && $token['name'] === 'body') {
2135 $this->insertElement($token);
2141 } elseif ($token['type'] === HTML5::STARTTAG && $token['name'] === 'frameset') {
2143 $this->insertElement($token);
2150 } elseif ($token['type'] === HTML5::STARTTAG && in_array(
2151 $token['name'],
2158 return $this->inHead($token);
2172 return $this->inBody($token);
2176 private function inBody($token) argument
2180 switch ($token['type']) {
2187 $this->insertText($token['data']);
2194 $this->insertComment($token['data']);
2198 switch ($token['name']) {
2205 return $this->inHead($token);
2216 return $this->inHead($token);
2234 foreach ($token['attr'] as $attr) {
2270 $this->insertElement($token);
2296 $element = $this->insertElement($token);
2329 if ($token['name'] === $node->tagName || ($token['name'] !== 'li'
2351 $this->insertElement($token);
2369 $this->insertElement($token);
2403 $this->insertElement($token);
2438 $el = $this->insertElement($token);
2463 $el = $this->insertElement($token);
2489 $this->insertElement($token);
2503 $this->insertElement($token);
2516 $this->insertElement($token);
2536 $this->insertElement($token);
2557 $this->insertElement($token);
2577 $this->insertElement($token);
2587 $token['name'] = 'img';
2588 return $this->inBody($token);
2597 $element = $this->insertElement($token, false);
2668 $attr = $token['attr'];
2726 $this->insertElement($token);
2738 $this->insertElement($token);
2750 $this->insertElement($token);
2796 $this->insertElement($token, true, true);
2802 switch ($token['name']) {
2833 return $this->afterBody($token);
2854 if ($this->elementInScope($token['name'])) {
2867 if ($this->stack[$n]->nodeName === $token['name']) {
2881 if ($this->elementInScope($token['name'])) {
2886 if (end($this->stack)->nodeName !== $token['name']) {
2936 if ($this->elementInScope($token['name'])) {
2937 $this->generateImpliedEndTags(array($token['name']));
2948 if ($this->stack[$n]->nodeName === $token['name']) {
3014 } elseif ($this->a_formatting[$a]->tagName === $token['name']) {
3027 !$this->elementInScope($token['name']))
3220 if ($this->elementInScope($token['name'])) {
3233 if ($this->stack[$n]->nodeName === $token['name']) {
3283 if ($token['name'] === $node->nodeName) {
3316 private function inTable($token) argument
3323 if ($token['type'] === HTML5::CHARACTR &&
3324 preg_match('/^[\t\n\x0b\x0c ]+$/', $token['data'])
3327 $text = $this->dom->createTextNode($token['data']);
3331 } elseif ($token['type'] === HTML5::COMMENT) {
3334 $comment = $this->dom->createComment($token['data']);
3338 } elseif ($token['type'] === HTML5::STARTTAG &&
3339 $token['name'] === 'caption'
3350 $this->insertElement($token);
3354 } elseif ($token['type'] === HTML5::STARTTAG &&
3355 $token['name'] === 'colgroup'
3362 $this->insertElement($token);
3366 } elseif ($token['type'] === HTML5::STARTTAG &&
3367 $token['name'] === 'col'
3377 $this->inColumnGroup($token);
3380 } elseif ($token['type'] === HTML5::STARTTAG && in_array(
3381 $token['name'],
3390 $this->insertElement($token);
3394 } elseif ($token['type'] === HTML5::STARTTAG &&
3395 in_array($token['name'], array('td', 'th', 'tr'))
3407 return $this->inTableBody($token);
3410 } elseif ($token['type'] === HTML5::STARTTAG &&
3411 $token['name'] === 'table'
3423 return $this->mainPhase($token);
3426 } elseif ($token['type'] === HTML5::ENDTAG &&
3427 $token['name'] === 'table'
3432 if (!$this->elementInScope($token['name'], true)) {
3461 } elseif ($token['type'] === HTML5::ENDTAG && in_array(
3462 $token['name'],
3524 $this->inBody($token);
3528 private function inCaption($token) argument
3531 if ($token['type'] === HTML5::ENDTAG && $token['name'] === 'caption') {
3535 if (!$this->elementInScope($token['name'], true)) {
3569 } elseif (($token['type'] === HTML5::STARTTAG && in_array(
3570 $token['name'],
3582 )) || ($token['type'] === HTML5::ENDTAG &&
3583 $token['name'] === 'table')
3595 return $this->inTable($token);
3599 } elseif ($token['type'] === HTML5::ENDTAG && in_array(
3600 $token['name'],
3619 $this->inBody($token);
3623 private function inColumnGroup($token) argument
3628 if ($token['type'] === HTML5::CHARACTR &&
3629 preg_match('/^[\t\n\x0b\x0c ]+$/', $token['data'])
3632 $text = $this->dom->createTextNode($token['data']);
3636 } elseif ($token['type'] === HTML5::COMMENT) {
3639 $comment = $this->dom->createComment($token['data']);
3643 } elseif ($token['type'] === HTML5::STARTTAG && $token['name'] === 'col') {
3646 $this->insertElement($token);
3650 } elseif ($token['type'] === HTML5::ENDTAG &&
3651 $token['name'] === 'colgroup'
3667 } elseif ($token['type'] === HTML5::ENDTAG && $token['name'] === 'col') {
3681 return $this->inTable($token);
3685 private function inTableBody($token) argument
3690 if ($token['type'] === HTML5::STARTTAG && $token['name'] === 'tr') {
3696 $this->insertElement($token);
3700 } elseif ($token['type'] === HTML5::STARTTAG &&
3701 ($token['name'] === 'th' || $token['name'] === 'td')
3713 return $this->inRow($token);
3716 } elseif ($token['type'] === HTML5::ENDTAG &&
3717 in_array($token['name'], array('tbody', 'tfoot', 'thead'))
3722 if (!$this->elementInScope($token['name'], true)) {
3738 } elseif (($token['type'] === HTML5::STARTTAG && in_array(
3739 $token['name'],
3742 ($token['type'] === HTML5::STARTTAG && $token['name'] === 'table')
3765 return $this->mainPhase($token);
3770 } elseif ($token['type'] === HTML5::ENDTAG && in_array(
3771 $token['name'],
3780 $this->inTable($token);
3784 private function inRow($token) argument
3789 if ($token['type'] === HTML5::STARTTAG &&
3790 ($token['name'] === 'th' || $token['name'] === 'td')
3797 $this->insertElement($token);
3805 } elseif ($token['type'] === HTML5::ENDTAG && $token['name'] === 'tr') {
3809 if (!$this->elementInScope($token['name'], true)) {
3826 } elseif ($token['type'] === HTML5::STARTTAG && in_array(
3827 $token['name'],
3840 return $this->inCell($token);
3843 } elseif ($token['type'] === HTML5::ENDTAG &&
3844 in_array($token['name'], array('tbody', 'tfoot', 'thead'))
3849 if (!$this->elementInScope($token['name'], true)) {
3863 return $this->inCell($token);
3868 } elseif ($token['type'] === HTML5::ENDTAG && in_array(
3869 $token['name'],
3878 $this->inTable($token);
3882 private function inCell($token) argument
3885 if ($token['type'] === HTML5::ENDTAG &&
3886 ($token['name'] === 'td' || $token['name'] === 'th')
3891 if (!$this->elementInScope($token['name'], true)) {
3898 $this->generateImpliedEndTags(array($token['name']));
3910 if ($node === $token['name']) {
3926 } elseif ($token['type'] === HTML5::STARTTAG && in_array(
3927 $token['name'],
3951 return $this->inRow($token);
3956 } elseif ($token['type'] === HTML5::STARTTAG && in_array(
3957 $token['name'],
3981 return $this->inRow($token);
3986 } elseif ($token['type'] === HTML5::ENDTAG && in_array(
3987 $token['name'],
3995 } elseif ($token['type'] === HTML5::ENDTAG && in_array(
3996 $token['name'],
4004 if (!$this->elementInScope($token['name'], true)) {
4011 return $this->inRow($token);
4017 $this->inBody($token);
4021 private function inSelect($token) argument
4026 if ($token['type'] === HTML5::CHARACTR) {
4028 $this->insertText($token['data']);
4031 } elseif ($token['type'] === HTML5::COMMENT) {
4034 $this->insertComment($token['data']);
4037 } elseif ($token['type'] === HTML5::STARTTAG &&
4038 $token['name'] === 'option'
4052 $this->insertElement($token);
4055 } elseif ($token['type'] === HTML5::STARTTAG &&
4056 $token['name'] === 'optgroup'
4081 $this->insertElement($token);
4084 } elseif ($token['type'] === HTML5::ENDTAG &&
4085 $token['name'] === 'optgroup'
4112 } elseif ($token['type'] === HTML5::ENDTAG &&
4113 $token['name'] === 'option'
4123 } elseif ($token['type'] === HTML5::ENDTAG &&
4124 $token['name'] === 'select'
4129 if (!$this->elementInScope($token['name'], true)) {
4150 } elseif ($token['name'] === 'select' &&
4151 $token['type'] === HTML5::STARTTAG
4165 $token['name'],
4176 ) && $token['type'] === HTML5::ENDTAG
4185 if ($this->elementInScope($token['name'], true)) {
4193 $this->mainPhase($token);
4202 private function afterBody($token) argument
4209 if ($token['type'] === HTML5::CHARACTR &&
4210 preg_match('/^[\t\n\x0b\x0c ]+$/', $token['data'])
4214 $this->inBody($token);
4217 } elseif ($token['type'] === HTML5::COMMENT) {
4221 $comment = $this->dom->createComment($token['data']);
4225 } elseif ($token['type'] === HTML5::ENDTAG && $token['name'] === 'html') {
4239 return $this->inBody($token);
4243 private function inFrameset($token) argument
4250 if ($token['type'] === HTML5::CHARACTR &&
4251 preg_match('/^[\t\n\x0b\x0c ]+$/', $token['data'])
4254 $this->insertText($token['data']);
4257 } elseif ($token['type'] === HTML5::COMMENT) {
4260 $this->insertComment($token['data']);
4263 } elseif ($token['name'] === 'frameset' &&
4264 $token['type'] === HTML5::STARTTAG
4266 $this->insertElement($token);
4269 } elseif ($token['name'] === 'frameset' &&
4270 $token['type'] === HTML5::ENDTAG
4290 } elseif ($token['name'] === 'frame' &&
4291 $token['type'] === HTML5::STARTTAG
4294 $this->insertElement($token);
4300 } elseif ($token['name'] === 'noframes' &&
4301 $token['type'] === HTML5::STARTTAG
4304 $this->inBody($token);
4312 private function afterFrameset($token) argument
4319 if ($token['type'] === HTML5::CHARACTR &&
4320 preg_match('/^[\t\n\x0b\x0c ]+$/', $token['data'])
4323 $this->insertText($token['data']);
4326 } elseif ($token['type'] === HTML5::COMMENT) {
4329 $this->insertComment($token['data']);
4332 } elseif ($token['name'] === 'html' &&
4333 $token['type'] === HTML5::ENDTAG
4339 } elseif ($token['name'] === 'noframes' &&
4340 $token['type'] === HTML5::STARTTAG
4343 $this->inBody($token);
4351 private function trailingEndPhase($token) argument
4357 if ($token['type'] === HTML5::DOCTYPE) {
4361 } elseif ($token['type'] === HTML5::COMMENT) {
4364 $comment = $this->dom->createComment($token['data']);
4370 } elseif ($token['type'] === HTML5::CHARACTR &&
4371 preg_match('/^[\t\n\x0b\x0c ]+$/', $token['data'])
4374 $this->mainPhase($token);
4379 } elseif (($token['type'] === HTML5::CHARACTR &&
4380 preg_match('/^[\t\n\x0b\x0c ]+$/', $token['data'])) ||
4381 $token['type'] === HTML5::STARTTAG || $token['type'] === HTML5::ENDTAG
4386 return $this->mainPhase($token);
4389 } elseif ($token['type'] === HTML5::EOF) {
4394 private function insertElement($token, $append = true, $check = false) argument
4400 $token['name'] = preg_replace('/[^a-z0-9-]/i', '', $token['name']);
4402 $token['name'] = ltrim($token['name'], '-0..9');
4404 if ($token['name'] === '') {
4405 $token['name'] = 'span';
4409 $el = $this->dom->createElement($token['name']);
4411 foreach ($token['attr'] as $attr) {