@@ -1,3 +1,3 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -define('HTML5LIB_PATH', dirname(__FILE__).'/thirdparty/html5lib'); |
|
| 3 | +define('HTML5LIB_PATH', dirname(__FILE__) . '/thirdparty/html5lib'); |
|
@@ -93,7 +93,7 @@ discard block |
||
| 93 | 93 | $y = (($code & 0x7FF) >> 6) | 0xC0; |
| 94 | 94 | } else { |
| 95 | 95 | $y = (($code & 0xFC0) >> 6) | 0x80; |
| 96 | - if($code < 0x10000) { |
|
| 96 | + if ($code < 0x10000) { |
|
| 97 | 97 | $z = (($code >> 12) & 0x0F) | 0xE0; |
| 98 | 98 | } else { |
| 99 | 99 | $z = (($code >> 12) & 0x3F) | 0x80; |
@@ -103,9 +103,9 @@ discard block |
||
| 103 | 103 | } |
| 104 | 104 | // set up the actual character |
| 105 | 105 | $ret = ''; |
| 106 | - if($w) $ret .= chr($w); |
|
| 107 | - if($z) $ret .= chr($z); |
|
| 108 | - if($y) $ret .= chr($y); |
|
| 106 | + if ($w) $ret .= chr($w); |
|
| 107 | + if ($z) $ret .= chr($z); |
|
| 108 | + if ($y) $ret .= chr($y); |
|
| 109 | 109 | $ret .= chr($x); |
| 110 | 110 | |
| 111 | 111 | return $ret; |
@@ -56,8 +56,11 @@ discard block |
||
| 56 | 56 | * reference. |
| 57 | 57 | */ |
| 58 | 58 | public static function getRealCodepoint($ref) { |
| 59 | - if (!isset(self::$realCodepointTable[$ref])) return false; |
|
| 60 | - else return self::$realCodepointTable[$ref]; |
|
| 59 | + if (!isset(self::$realCodepointTable[$ref])) { |
|
| 60 | + return false; |
|
| 61 | + } else { |
|
| 62 | + return self::$realCodepointTable[$ref]; |
|
| 63 | + } |
|
| 61 | 64 | } |
| 62 | 65 | |
| 63 | 66 | public static function getNamedCharacterReferences() { |
@@ -103,9 +106,15 @@ discard block |
||
| 103 | 106 | } |
| 104 | 107 | // set up the actual character |
| 105 | 108 | $ret = ''; |
| 106 | - if($w) $ret .= chr($w); |
|
| 107 | - if($z) $ret .= chr($z); |
|
| 108 | - if($y) $ret .= chr($y); |
|
| 109 | + if($w) { |
|
| 110 | + $ret .= chr($w); |
|
| 111 | + } |
|
| 112 | + if($z) { |
|
| 113 | + $ret .= chr($z); |
|
| 114 | + } |
|
| 115 | + if($y) { |
|
| 116 | + $ret .= chr($y); |
|
| 117 | + } |
|
| 109 | 118 | $ret .= chr($x); |
| 110 | 119 | |
| 111 | 120 | return $ret; |
@@ -164,7 +164,7 @@ discard block |
||
| 164 | 164 | */ |
| 165 | 165 | public function getCurrentLine() { |
| 166 | 166 | // Check the string isn't empty |
| 167 | - if($this->EOF) { |
|
| 167 | + if ($this->EOF) { |
|
| 168 | 168 | // Add one to $this->char because we want the number for the next |
| 169 | 169 | // byte to be processed. |
| 170 | 170 | return substr_count($this->data, "\n", 0, min($this->char, $this->EOF)) + 1; |
@@ -187,18 +187,18 @@ discard block |
||
| 187 | 187 | |
| 188 | 188 | // However, for here we want the length up until the next byte to be |
| 189 | 189 | // processed, so add one to the current byte ($this->char). |
| 190 | - if($lastLine !== false) { |
|
| 190 | + if ($lastLine !== false) { |
|
| 191 | 191 | $findLengthOf = substr($this->data, $lastLine + 1, $this->char - 1 - $lastLine); |
| 192 | 192 | } else { |
| 193 | 193 | $findLengthOf = substr($this->data, 0, $this->char); |
| 194 | 194 | } |
| 195 | 195 | |
| 196 | 196 | // Get the length for the string we need. |
| 197 | - if(extension_loaded('iconv')) { |
|
| 197 | + if (extension_loaded('iconv')) { |
|
| 198 | 198 | return iconv_strlen($findLengthOf, 'utf-8'); |
| 199 | - } elseif(extension_loaded('mbstring')) { |
|
| 199 | + } elseif (extension_loaded('mbstring')) { |
|
| 200 | 200 | return mb_strlen($findLengthOf, 'utf-8'); |
| 201 | - } elseif(extension_loaded('xml')) { |
|
| 201 | + } elseif (extension_loaded('xml')) { |
|
| 202 | 202 | return strlen(utf8_decode($findLengthOf)); |
| 203 | 203 | } else { |
| 204 | 204 | $count = count_chars($findLengthOf); |
@@ -224,7 +224,7 @@ discard block |
||
| 224 | 224 | * @note This performs bounds checking |
| 225 | 225 | */ |
| 226 | 226 | public function remainingChars() { |
| 227 | - if($this->char < $this->EOF) { |
|
| 227 | + if ($this->char < $this->EOF) { |
|
| 228 | 228 | $data = substr($this->data, $this->char); |
| 229 | 229 | $this->char = $this->EOF; |
| 230 | 230 | return $data; |
@@ -117,7 +117,7 @@ discard block |
||
| 117 | 117 | */ |
| 118 | 118 | $escape = false; |
| 119 | 119 | //echo "\n\n"; |
| 120 | - while($state !== null) { |
|
| 120 | + while ($state !== null) { |
|
| 121 | 121 | |
| 122 | 122 | /*echo $state . ' '; |
| 123 | 123 | switch ($this->content_model) { |
@@ -129,7 +129,7 @@ discard block |
||
| 129 | 129 | if ($escape) echo " escape"; |
| 130 | 130 | echo "\n";*/ |
| 131 | 131 | |
| 132 | - switch($state) { |
|
| 132 | + switch ($state) { |
|
| 133 | 133 | case 'data': |
| 134 | 134 | |
| 135 | 135 | /* Consume the next input character */ |
@@ -166,7 +166,7 @@ discard block |
||
| 166 | 166 | $this->content_model === self::CDATA |
| 167 | 167 | ); |
| 168 | 168 | |
| 169 | - if($char === '&' && $amp_cond) { |
|
| 169 | + if ($char === '&' && $amp_cond) { |
|
| 170 | 170 | /* U+0026 AMPERSAND (&) |
| 171 | 171 | When the content model flag is set to one of the PCDATA or RCDATA |
| 172 | 172 | states and the escape flag is false: switch to the |
@@ -174,7 +174,7 @@ discard block |
||
| 174 | 174 | the "anything else" entry below. */ |
| 175 | 175 | $state = 'character reference data'; |
| 176 | 176 | |
| 177 | - } elseif( |
|
| 177 | + } elseif ( |
|
| 178 | 178 | $char === '-' && |
| 179 | 179 | $hyp_cond && |
| 180 | 180 | $lastFourChars === '<!--' |
@@ -198,7 +198,7 @@ discard block |
||
| 198 | 198 | // We do the "any case" part as part of "anything else". |
| 199 | 199 | |
| 200 | 200 | /* U+003C LESS-THAN SIGN (<) */ |
| 201 | - } elseif($char === '<' && $lt_cond) { |
|
| 201 | + } elseif ($char === '<' && $lt_cond) { |
|
| 202 | 202 | /* When the content model flag is set to the PCDATA state: switch |
| 203 | 203 | to the tag open state. |
| 204 | 204 | |
@@ -210,7 +210,7 @@ discard block |
||
| 210 | 210 | $state = 'tag open'; |
| 211 | 211 | |
| 212 | 212 | /* U+003E GREATER-THAN SIGN (>) */ |
| 213 | - } elseif( |
|
| 213 | + } elseif ( |
|
| 214 | 214 | $char === '>' && |
| 215 | 215 | $gt_cond && |
| 216 | 216 | substr($lastFourChars, 1) === '-->' |
@@ -230,7 +230,7 @@ discard block |
||
| 230 | 230 | )); |
| 231 | 231 | // We do the "any case" part as part of "anything else". |
| 232 | 232 | |
| 233 | - } elseif($char === false) { |
|
| 233 | + } elseif ($char === false) { |
|
| 234 | 234 | /* EOF |
| 235 | 235 | Emit an end-of-file token. */ |
| 236 | 236 | $state = null; |
@@ -238,7 +238,7 @@ discard block |
||
| 238 | 238 | 'type' => self::EOF |
| 239 | 239 | )); |
| 240 | 240 | |
| 241 | - } elseif($char === "\t" || $char === "\n" || $char === "\x0c" || $char === ' ') { |
|
| 241 | + } elseif ($char === "\t" || $char === "\n" || $char === "\x0c" || $char === ' ') { |
|
| 242 | 242 | // Directly after emitting a token you switch back to the "data |
| 243 | 243 | // state". At that point spaceCharacters are important so they are |
| 244 | 244 | // emitted separately. |
@@ -304,7 +304,7 @@ discard block |
||
| 304 | 304 | case 'tag open': |
| 305 | 305 | $char = $this->stream->char(); |
| 306 | 306 | |
| 307 | - switch($this->content_model) { |
|
| 307 | + switch ($this->content_model) { |
|
| 308 | 308 | case self::RCDATA: |
| 309 | 309 | case self::CDATA: |
| 310 | 310 | /* Consume the next input character. If it is a |
@@ -314,7 +314,7 @@ discard block |
||
| 314 | 314 | character in the data state. */ |
| 315 | 315 | // We consumed above. |
| 316 | 316 | |
| 317 | - if($char === '/') { |
|
| 317 | + if ($char === '/') { |
|
| 318 | 318 | $state = 'close tag open'; |
| 319 | 319 | |
| 320 | 320 | } else { |
@@ -334,17 +334,17 @@ discard block |
||
| 334 | 334 | Consume the next input character: */ |
| 335 | 335 | // We consumed above. |
| 336 | 336 | |
| 337 | - if($char === '!') { |
|
| 337 | + if ($char === '!') { |
|
| 338 | 338 | /* U+0021 EXCLAMATION MARK (!) |
| 339 | 339 | Switch to the markup declaration open state. */ |
| 340 | 340 | $state = 'markup declaration open'; |
| 341 | 341 | |
| 342 | - } elseif($char === '/') { |
|
| 342 | + } elseif ($char === '/') { |
|
| 343 | 343 | /* U+002F SOLIDUS (/) |
| 344 | 344 | Switch to the close tag open state. */ |
| 345 | 345 | $state = 'close tag open'; |
| 346 | 346 | |
| 347 | - } elseif('A' <= $char && $char <= 'Z') { |
|
| 347 | + } elseif ('A' <= $char && $char <= 'Z') { |
|
| 348 | 348 | /* U+0041 LATIN LETTER A through to U+005A LATIN LETTER Z |
| 349 | 349 | Create a new start tag token, set its tag name to the lowercase |
| 350 | 350 | version of the input character (add 0x0020 to the character's code |
@@ -358,7 +358,7 @@ discard block |
||
| 358 | 358 | |
| 359 | 359 | $state = 'tag name'; |
| 360 | 360 | |
| 361 | - } elseif('a' <= $char && $char <= 'z') { |
|
| 361 | + } elseif ('a' <= $char && $char <= 'z') { |
|
| 362 | 362 | /* U+0061 LATIN SMALL LETTER A through to U+007A LATIN SMALL LETTER Z |
| 363 | 363 | Create a new start tag token, set its tag name to the input |
| 364 | 364 | character, then switch to the tag name state. (Don't emit |
@@ -372,7 +372,7 @@ discard block |
||
| 372 | 372 | |
| 373 | 373 | $state = 'tag name'; |
| 374 | 374 | |
| 375 | - } elseif($char === '>') { |
|
| 375 | + } elseif ($char === '>') { |
|
| 376 | 376 | /* U+003E GREATER-THAN SIGN (>) |
| 377 | 377 | Parse error. Emit a U+003C LESS-THAN SIGN character token and a |
| 378 | 378 | U+003E GREATER-THAN SIGN character token. Switch to the data state. */ |
@@ -387,7 +387,7 @@ discard block |
||
| 387 | 387 | |
| 388 | 388 | $state = 'data'; |
| 389 | 389 | |
| 390 | - } elseif($char === '?') { |
|
| 390 | + } elseif ($char === '?') { |
|
| 391 | 391 | /* U+003F QUESTION MARK (?) |
| 392 | 392 | Parse error. Switch to the bogus comment state. */ |
| 393 | 393 | $this->emitToken(array( |
@@ -508,7 +508,7 @@ discard block |
||
| 508 | 508 | |
| 509 | 509 | $state = 'tag name'; |
| 510 | 510 | |
| 511 | - } elseif($char === '>') { |
|
| 511 | + } elseif ($char === '>') { |
|
| 512 | 512 | /* U+003E GREATER-THAN SIGN (>) |
| 513 | 513 | Parse error. Switch to the data state. */ |
| 514 | 514 | $this->emitToken(array( |
@@ -517,7 +517,7 @@ discard block |
||
| 517 | 517 | )); |
| 518 | 518 | $state = 'data'; |
| 519 | 519 | |
| 520 | - } elseif($char === false) { |
|
| 520 | + } elseif ($char === false) { |
|
| 521 | 521 | /* EOF |
| 522 | 522 | Parse error. Emit a U+003C LESS-THAN SIGN character token and a U+002F |
| 523 | 523 | SOLIDUS character token. Reconsume the EOF character in the data state. */ |
@@ -552,7 +552,7 @@ discard block |
||
| 552 | 552 | /* Consume the next input character: */ |
| 553 | 553 | $char = $this->stream->char(); |
| 554 | 554 | |
| 555 | - if($char === "\t" || $char === "\n" || $char === "\x0c" || $char === ' ') { |
|
| 555 | + if ($char === "\t" || $char === "\n" || $char === "\x0c" || $char === ' ') { |
|
| 556 | 556 | /* U+0009 CHARACTER TABULATION |
| 557 | 557 | U+000A LINE FEED (LF) |
| 558 | 558 | U+000C FORM FEED (FF) |
@@ -560,18 +560,18 @@ discard block |
||
| 560 | 560 | Switch to the before attribute name state. */ |
| 561 | 561 | $state = 'before attribute name'; |
| 562 | 562 | |
| 563 | - } elseif($char === '/') { |
|
| 563 | + } elseif ($char === '/') { |
|
| 564 | 564 | /* U+002F SOLIDUS (/) |
| 565 | 565 | Switch to the self-closing start tag state. */ |
| 566 | 566 | $state = 'self-closing start tag'; |
| 567 | 567 | |
| 568 | - } elseif($char === '>') { |
|
| 568 | + } elseif ($char === '>') { |
|
| 569 | 569 | /* U+003E GREATER-THAN SIGN (>) |
| 570 | 570 | Emit the current tag token. Switch to the data state. */ |
| 571 | 571 | $this->emitToken($this->token); |
| 572 | 572 | $state = 'data'; |
| 573 | 573 | |
| 574 | - } elseif('A' <= $char && $char <= 'Z') { |
|
| 574 | + } elseif ('A' <= $char && $char <= 'Z') { |
|
| 575 | 575 | /* U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z |
| 576 | 576 | Append the lowercase version of the current input |
| 577 | 577 | character (add 0x0020 to the character's code point) to |
@@ -581,7 +581,7 @@ discard block |
||
| 581 | 581 | $this->token['name'] .= strtolower($char . $chars); |
| 582 | 582 | $state = 'tag name'; |
| 583 | 583 | |
| 584 | - } elseif($char === false) { |
|
| 584 | + } elseif ($char === false) { |
|
| 585 | 585 | /* EOF |
| 586 | 586 | Parse error. Reconsume the EOF character in the data state. */ |
| 587 | 587 | $this->emitToken(array( |
@@ -608,7 +608,7 @@ discard block |
||
| 608 | 608 | $char = $this->stream->char(); |
| 609 | 609 | |
| 610 | 610 | // this conditional is optimized, check bottom |
| 611 | - if($char === "\t" || $char === "\n" || $char === "\x0c" || $char === ' ') { |
|
| 611 | + if ($char === "\t" || $char === "\n" || $char === "\x0c" || $char === ' ') { |
|
| 612 | 612 | /* U+0009 CHARACTER TABULATION |
| 613 | 613 | U+000A LINE FEED (LF) |
| 614 | 614 | U+000C FORM FEED (FF) |
@@ -616,18 +616,18 @@ discard block |
||
| 616 | 616 | Stay in the before attribute name state. */ |
| 617 | 617 | $state = 'before attribute name'; |
| 618 | 618 | |
| 619 | - } elseif($char === '/') { |
|
| 619 | + } elseif ($char === '/') { |
|
| 620 | 620 | /* U+002F SOLIDUS (/) |
| 621 | 621 | Switch to the self-closing start tag state. */ |
| 622 | 622 | $state = 'self-closing start tag'; |
| 623 | 623 | |
| 624 | - } elseif($char === '>') { |
|
| 624 | + } elseif ($char === '>') { |
|
| 625 | 625 | /* U+003E GREATER-THAN SIGN (>) |
| 626 | 626 | Emit the current tag token. Switch to the data state. */ |
| 627 | 627 | $this->emitToken($this->token); |
| 628 | 628 | $state = 'data'; |
| 629 | 629 | |
| 630 | - } elseif('A' <= $char && $char <= 'Z') { |
|
| 630 | + } elseif ('A' <= $char && $char <= 'Z') { |
|
| 631 | 631 | /* U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z |
| 632 | 632 | Start a new attribute in the current tag token. Set that |
| 633 | 633 | attribute's name to the lowercase version of the current |
@@ -641,7 +641,7 @@ discard block |
||
| 641 | 641 | |
| 642 | 642 | $state = 'attribute name'; |
| 643 | 643 | |
| 644 | - } elseif($char === false) { |
|
| 644 | + } elseif ($char === false) { |
|
| 645 | 645 | /* EOF |
| 646 | 646 | Parse error. Reconsume the EOF character in the data state. */ |
| 647 | 647 | $this->emitToken(array( |
@@ -659,7 +659,7 @@ discard block |
||
| 659 | 659 | U+003D EQUALS SIGN (=) |
| 660 | 660 | Parse error. Treat it as per the "anything else" entry |
| 661 | 661 | below. */ |
| 662 | - if($char === '"' || $char === "'" || $char === '<' || $char === '=') { |
|
| 662 | + if ($char === '"' || $char === "'" || $char === '<' || $char === '=') { |
|
| 663 | 663 | $this->emitToken(array( |
| 664 | 664 | 'type' => self::PARSEERROR, |
| 665 | 665 | 'data' => 'invalid-character-in-attribute-name' |
@@ -684,7 +684,7 @@ discard block |
||
| 684 | 684 | $char = $this->stream->char(); |
| 685 | 685 | |
| 686 | 686 | // this conditional is optimized, check bottom |
| 687 | - if($char === "\t" || $char === "\n" || $char === "\x0c" || $char === ' ') { |
|
| 687 | + if ($char === "\t" || $char === "\n" || $char === "\x0c" || $char === ' ') { |
|
| 688 | 688 | /* U+0009 CHARACTER TABULATION |
| 689 | 689 | U+000A LINE FEED (LF) |
| 690 | 690 | U+000C FORM FEED (FF) |
@@ -692,23 +692,23 @@ discard block |
||
| 692 | 692 | Switch to the after attribute name state. */ |
| 693 | 693 | $state = 'after attribute name'; |
| 694 | 694 | |
| 695 | - } elseif($char === '/') { |
|
| 695 | + } elseif ($char === '/') { |
|
| 696 | 696 | /* U+002F SOLIDUS (/) |
| 697 | 697 | Switch to the self-closing start tag state. */ |
| 698 | 698 | $state = 'self-closing start tag'; |
| 699 | 699 | |
| 700 | - } elseif($char === '=') { |
|
| 700 | + } elseif ($char === '=') { |
|
| 701 | 701 | /* U+003D EQUALS SIGN (=) |
| 702 | 702 | Switch to the before attribute value state. */ |
| 703 | 703 | $state = 'before attribute value'; |
| 704 | 704 | |
| 705 | - } elseif($char === '>') { |
|
| 705 | + } elseif ($char === '>') { |
|
| 706 | 706 | /* U+003E GREATER-THAN SIGN (>) |
| 707 | 707 | Emit the current tag token. Switch to the data state. */ |
| 708 | 708 | $this->emitToken($this->token); |
| 709 | 709 | $state = 'data'; |
| 710 | 710 | |
| 711 | - } elseif('A' <= $char && $char <= 'Z') { |
|
| 711 | + } elseif ('A' <= $char && $char <= 'Z') { |
|
| 712 | 712 | /* U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z |
| 713 | 713 | Append the lowercase version of the current input |
| 714 | 714 | character (add 0x0020 to the character's code point) to |
@@ -721,7 +721,7 @@ discard block |
||
| 721 | 721 | |
| 722 | 722 | $state = 'attribute name'; |
| 723 | 723 | |
| 724 | - } elseif($char === false) { |
|
| 724 | + } elseif ($char === false) { |
|
| 725 | 725 | /* EOF |
| 726 | 726 | Parse error. Reconsume the EOF character in the data state. */ |
| 727 | 727 | $this->emitToken(array( |
@@ -738,7 +738,7 @@ discard block |
||
| 738 | 738 | U+003C LESS-THAN SIGN (<) |
| 739 | 739 | Parse error. Treat it as per the "anything else" |
| 740 | 740 | entry below. */ |
| 741 | - if($char === '"' || $char === "'" || $char === '<') { |
|
| 741 | + if ($char === '"' || $char === "'" || $char === '<') { |
|
| 742 | 742 | $this->emitToken(array( |
| 743 | 743 | 'type' => self::PARSEERROR, |
| 744 | 744 | 'data' => 'invalid-character-in-attribute-name' |
@@ -771,7 +771,7 @@ discard block |
||
| 771 | 771 | $char = $this->stream->char(); |
| 772 | 772 | |
| 773 | 773 | // this is an optimized conditional, check the bottom |
| 774 | - if($char === "\t" || $char === "\n" || $char === "\x0c" || $char === ' ') { |
|
| 774 | + if ($char === "\t" || $char === "\n" || $char === "\x0c" || $char === ' ') { |
|
| 775 | 775 | /* U+0009 CHARACTER TABULATION |
| 776 | 776 | U+000A LINE FEED (LF) |
| 777 | 777 | U+000C FORM FEED (FF) |
@@ -779,23 +779,23 @@ discard block |
||
| 779 | 779 | Stay in the after attribute name state. */ |
| 780 | 780 | $state = 'after attribute name'; |
| 781 | 781 | |
| 782 | - } elseif($char === '/') { |
|
| 782 | + } elseif ($char === '/') { |
|
| 783 | 783 | /* U+002F SOLIDUS (/) |
| 784 | 784 | Switch to the self-closing start tag state. */ |
| 785 | 785 | $state = 'self-closing start tag'; |
| 786 | 786 | |
| 787 | - } elseif($char === '=') { |
|
| 787 | + } elseif ($char === '=') { |
|
| 788 | 788 | /* U+003D EQUALS SIGN (=) |
| 789 | 789 | Switch to the before attribute value state. */ |
| 790 | 790 | $state = 'before attribute value'; |
| 791 | 791 | |
| 792 | - } elseif($char === '>') { |
|
| 792 | + } elseif ($char === '>') { |
|
| 793 | 793 | /* U+003E GREATER-THAN SIGN (>) |
| 794 | 794 | Emit the current tag token. Switch to the data state. */ |
| 795 | 795 | $this->emitToken($this->token); |
| 796 | 796 | $state = 'data'; |
| 797 | 797 | |
| 798 | - } elseif('A' <= $char && $char <= 'Z') { |
|
| 798 | + } elseif ('A' <= $char && $char <= 'Z') { |
|
| 799 | 799 | /* U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z |
| 800 | 800 | Start a new attribute in the current tag token. Set that |
| 801 | 801 | attribute's name to the lowercase version of the current |
@@ -809,7 +809,7 @@ discard block |
||
| 809 | 809 | |
| 810 | 810 | $state = 'attribute name'; |
| 811 | 811 | |
| 812 | - } elseif($char === false) { |
|
| 812 | + } elseif ($char === false) { |
|
| 813 | 813 | /* EOF |
| 814 | 814 | Parse error. Reconsume the EOF character in the data state. */ |
| 815 | 815 | $this->emitToken(array( |
@@ -826,7 +826,7 @@ discard block |
||
| 826 | 826 | U+003C LESS-THAN SIGN(<) |
| 827 | 827 | Parse error. Treat it as per the "anything else" |
| 828 | 828 | entry below. */ |
| 829 | - if($char === '"' || $char === "'" || $char === "<") { |
|
| 829 | + if ($char === '"' || $char === "'" || $char === "<") { |
|
| 830 | 830 | $this->emitToken(array( |
| 831 | 831 | 'type' => self::PARSEERROR, |
| 832 | 832 | 'data' => 'invalid-character-after-attribute-name' |
@@ -851,7 +851,7 @@ discard block |
||
| 851 | 851 | $char = $this->stream->char(); |
| 852 | 852 | |
| 853 | 853 | // this is an optimized conditional |
| 854 | - if($char === "\t" || $char === "\n" || $char === "\x0c" || $char === ' ') { |
|
| 854 | + if ($char === "\t" || $char === "\n" || $char === "\x0c" || $char === ' ') { |
|
| 855 | 855 | /* U+0009 CHARACTER TABULATION |
| 856 | 856 | U+000A LINE FEED (LF) |
| 857 | 857 | U+000C FORM FEED (FF) |
@@ -859,24 +859,24 @@ discard block |
||
| 859 | 859 | Stay in the before attribute value state. */ |
| 860 | 860 | $state = 'before attribute value'; |
| 861 | 861 | |
| 862 | - } elseif($char === '"') { |
|
| 862 | + } elseif ($char === '"') { |
|
| 863 | 863 | /* U+0022 QUOTATION MARK (") |
| 864 | 864 | Switch to the attribute value (double-quoted) state. */ |
| 865 | 865 | $state = 'attribute value (double-quoted)'; |
| 866 | 866 | |
| 867 | - } elseif($char === '&') { |
|
| 867 | + } elseif ($char === '&') { |
|
| 868 | 868 | /* U+0026 AMPERSAND (&) |
| 869 | 869 | Switch to the attribute value (unquoted) state and reconsume |
| 870 | 870 | this input character. */ |
| 871 | 871 | $this->stream->unget(); |
| 872 | 872 | $state = 'attribute value (unquoted)'; |
| 873 | 873 | |
| 874 | - } elseif($char === '\'') { |
|
| 874 | + } elseif ($char === '\'') { |
|
| 875 | 875 | /* U+0027 APOSTROPHE (') |
| 876 | 876 | Switch to the attribute value (single-quoted) state. */ |
| 877 | 877 | $state = 'attribute value (single-quoted)'; |
| 878 | 878 | |
| 879 | - } elseif($char === '>') { |
|
| 879 | + } elseif ($char === '>') { |
|
| 880 | 880 | /* U+003E GREATER-THAN SIGN (>) |
| 881 | 881 | Parse error. Emit the current tag token. Switch to the data state. */ |
| 882 | 882 | $this->emitToken(array( |
@@ -886,7 +886,7 @@ discard block |
||
| 886 | 886 | $this->emitToken($this->token); |
| 887 | 887 | $state = 'data'; |
| 888 | 888 | |
| 889 | - } elseif($char === false) { |
|
| 889 | + } elseif ($char === false) { |
|
| 890 | 890 | /* EOF |
| 891 | 891 | Parse error. Reconsume the EOF character in the data state. */ |
| 892 | 892 | $this->emitToken(array( |
@@ -900,7 +900,7 @@ discard block |
||
| 900 | 900 | /* U+003D EQUALS SIGN (=) |
| 901 | 901 | * U+003C LESS-THAN SIGN (<) |
| 902 | 902 | Parse error. Treat it as per the "anything else" entry below. */ |
| 903 | - if($char === '=' || $char === '<') { |
|
| 903 | + if ($char === '=' || $char === '<') { |
|
| 904 | 904 | $this->emitToken(array( |
| 905 | 905 | 'type' => self::PARSEERROR, |
| 906 | 906 | 'data' => 'equals-in-unquoted-attribute-value' |
@@ -921,19 +921,19 @@ discard block |
||
| 921 | 921 | // Consume the next input character: |
| 922 | 922 | $char = $this->stream->char(); |
| 923 | 923 | |
| 924 | - if($char === '"') { |
|
| 924 | + if ($char === '"') { |
|
| 925 | 925 | /* U+0022 QUOTATION MARK (") |
| 926 | 926 | Switch to the after attribute value (quoted) state. */ |
| 927 | 927 | $state = 'after attribute value (quoted)'; |
| 928 | 928 | |
| 929 | - } elseif($char === '&') { |
|
| 929 | + } elseif ($char === '&') { |
|
| 930 | 930 | /* U+0026 AMPERSAND (&) |
| 931 | 931 | Switch to the character reference in attribute value |
| 932 | 932 | state, with the additional allowed character |
| 933 | 933 | being U+0022 QUOTATION MARK ("). */ |
| 934 | 934 | $this->characterReferenceInAttributeValue('"'); |
| 935 | 935 | |
| 936 | - } elseif($char === false) { |
|
| 936 | + } elseif ($char === false) { |
|
| 937 | 937 | /* EOF |
| 938 | 938 | Parse error. Reconsume the EOF character in the data state. */ |
| 939 | 939 | $this->emitToken(array( |
@@ -961,17 +961,17 @@ discard block |
||
| 961 | 961 | // Consume the next input character: |
| 962 | 962 | $char = $this->stream->char(); |
| 963 | 963 | |
| 964 | - if($char === "'") { |
|
| 964 | + if ($char === "'") { |
|
| 965 | 965 | /* U+0022 QUOTATION MARK (') |
| 966 | 966 | Switch to the after attribute value state. */ |
| 967 | 967 | $state = 'after attribute value (quoted)'; |
| 968 | 968 | |
| 969 | - } elseif($char === '&') { |
|
| 969 | + } elseif ($char === '&') { |
|
| 970 | 970 | /* U+0026 AMPERSAND (&) |
| 971 | 971 | Switch to the entity in attribute value state. */ |
| 972 | 972 | $this->characterReferenceInAttributeValue("'"); |
| 973 | 973 | |
| 974 | - } elseif($char === false) { |
|
| 974 | + } elseif ($char === false) { |
|
| 975 | 975 | /* EOF |
| 976 | 976 | Parse error. Reconsume the EOF character in the data state. */ |
| 977 | 977 | $this->emitToken(array( |
@@ -999,7 +999,7 @@ discard block |
||
| 999 | 999 | // Consume the next input character: |
| 1000 | 1000 | $char = $this->stream->char(); |
| 1001 | 1001 | |
| 1002 | - if($char === "\t" || $char === "\n" || $char === "\x0c" || $char === ' ') { |
|
| 1002 | + if ($char === "\t" || $char === "\n" || $char === "\x0c" || $char === ' ') { |
|
| 1003 | 1003 | /* U+0009 CHARACTER TABULATION |
| 1004 | 1004 | U+000A LINE FEED (LF) |
| 1005 | 1005 | U+000C FORM FEED (FF) |
@@ -1007,14 +1007,14 @@ discard block |
||
| 1007 | 1007 | Switch to the before attribute name state. */ |
| 1008 | 1008 | $state = 'before attribute name'; |
| 1009 | 1009 | |
| 1010 | - } elseif($char === '&') { |
|
| 1010 | + } elseif ($char === '&') { |
|
| 1011 | 1011 | /* U+0026 AMPERSAND (&) |
| 1012 | 1012 | Switch to the entity in attribute value state, with the |
| 1013 | 1013 | additional allowed character being U+003E |
| 1014 | 1014 | GREATER-THAN SIGN (>). */ |
| 1015 | 1015 | $this->characterReferenceInAttributeValue('>'); |
| 1016 | 1016 | |
| 1017 | - } elseif($char === '>') { |
|
| 1017 | + } elseif ($char === '>') { |
|
| 1018 | 1018 | /* U+003E GREATER-THAN SIGN (>) |
| 1019 | 1019 | Emit the current tag token. Switch to the data state. */ |
| 1020 | 1020 | $this->emitToken($this->token); |
@@ -1037,7 +1037,7 @@ discard block |
||
| 1037 | 1037 | U+003D EQUALS SIGN (=) |
| 1038 | 1038 | Parse error. Treat it as per the "anything else" |
| 1039 | 1039 | entry below. */ |
| 1040 | - if($char === '"' || $char === "'" || $char === '=' || $char == '<') { |
|
| 1040 | + if ($char === '"' || $char === "'" || $char === '=' || $char == '<') { |
|
| 1041 | 1041 | $this->emitToken(array( |
| 1042 | 1042 | 'type' => self::PARSEERROR, |
| 1043 | 1043 | 'data' => 'unexpected-character-in-unquoted-attribute-value' |
@@ -1060,7 +1060,7 @@ discard block |
||
| 1060 | 1060 | /* Consume the next input character: */ |
| 1061 | 1061 | $char = $this->stream->char(); |
| 1062 | 1062 | |
| 1063 | - if($char === "\t" || $char === "\n" || $char === "\x0c" || $char === ' ') { |
|
| 1063 | + if ($char === "\t" || $char === "\n" || $char === "\x0c" || $char === ' ') { |
|
| 1064 | 1064 | /* U+0009 CHARACTER TABULATION |
| 1065 | 1065 | U+000A LINE FEED (LF) |
| 1066 | 1066 | U+000C FORM FEED (FF) |
@@ -1169,7 +1169,7 @@ discard block |
||
| 1169 | 1169 | /* If the next two characters are both U+002D HYPHEN-MINUS (-) |
| 1170 | 1170 | characters, consume those two characters, create a comment token whose |
| 1171 | 1171 | data is the empty string, and switch to the comment state. */ |
| 1172 | - if($hyphens === '--') { |
|
| 1172 | + if ($hyphens === '--') { |
|
| 1173 | 1173 | $state = 'comment start'; |
| 1174 | 1174 | $this->token = array( |
| 1175 | 1175 | 'data' => '', |
@@ -1179,7 +1179,7 @@ discard block |
||
| 1179 | 1179 | /* Otherwise if the next seven characters are a case-insensitive match |
| 1180 | 1180 | for the word "DOCTYPE", then consume those characters and switch to the |
| 1181 | 1181 | DOCTYPE state. */ |
| 1182 | - } elseif(strtoupper($alpha) === 'DOCTYPE') { |
|
| 1182 | + } elseif (strtoupper($alpha) === 'DOCTYPE') { |
|
| 1183 | 1183 | $state = 'DOCTYPE'; |
| 1184 | 1184 | |
| 1185 | 1185 | // XXX not implemented |
@@ -1283,12 +1283,12 @@ discard block |
||
| 1283 | 1283 | /* Consume the next input character: */ |
| 1284 | 1284 | $char = $this->stream->char(); |
| 1285 | 1285 | |
| 1286 | - if($char === '-') { |
|
| 1286 | + if ($char === '-') { |
|
| 1287 | 1287 | /* U+002D HYPHEN-MINUS (-) |
| 1288 | 1288 | Switch to the comment end dash state */ |
| 1289 | 1289 | $state = 'comment end dash'; |
| 1290 | 1290 | |
| 1291 | - } elseif($char === false) { |
|
| 1291 | + } elseif ($char === false) { |
|
| 1292 | 1292 | /* EOF |
| 1293 | 1293 | Parse error. Emit the comment token. Reconsume the EOF character |
| 1294 | 1294 | in the data state. */ |
@@ -1314,12 +1314,12 @@ discard block |
||
| 1314 | 1314 | /* Consume the next input character: */ |
| 1315 | 1315 | $char = $this->stream->char(); |
| 1316 | 1316 | |
| 1317 | - if($char === '-') { |
|
| 1317 | + if ($char === '-') { |
|
| 1318 | 1318 | /* U+002D HYPHEN-MINUS (-) |
| 1319 | 1319 | Switch to the comment end state */ |
| 1320 | 1320 | $state = 'comment end'; |
| 1321 | 1321 | |
| 1322 | - } elseif($char === false) { |
|
| 1322 | + } elseif ($char === false) { |
|
| 1323 | 1323 | /* EOF |
| 1324 | 1324 | Parse error. Emit the comment token. Reconsume the EOF character |
| 1325 | 1325 | in the data state. */ |
@@ -1335,7 +1335,7 @@ discard block |
||
| 1335 | 1335 | /* Anything else |
| 1336 | 1336 | Append a U+002D HYPHEN-MINUS (-) character and the input |
| 1337 | 1337 | character to the comment token's data. Switch to the comment state. */ |
| 1338 | - $this->token['data'] .= '-'.$char; |
|
| 1338 | + $this->token['data'] .= '-' . $char; |
|
| 1339 | 1339 | $state = 'comment'; |
| 1340 | 1340 | } |
| 1341 | 1341 | break; |
@@ -1344,13 +1344,13 @@ discard block |
||
| 1344 | 1344 | /* Consume the next input character: */ |
| 1345 | 1345 | $char = $this->stream->char(); |
| 1346 | 1346 | |
| 1347 | - if($char === '>') { |
|
| 1347 | + if ($char === '>') { |
|
| 1348 | 1348 | /* U+003E GREATER-THAN SIGN (>) |
| 1349 | 1349 | Emit the comment token. Switch to the data state. */ |
| 1350 | 1350 | $this->emitToken($this->token); |
| 1351 | 1351 | $state = 'data'; |
| 1352 | 1352 | |
| 1353 | - } elseif($char === '-') { |
|
| 1353 | + } elseif ($char === '-') { |
|
| 1354 | 1354 | /* U+002D HYPHEN-MINUS (-) |
| 1355 | 1355 | Parse error. Append a U+002D HYPHEN-MINUS (-) character |
| 1356 | 1356 | to the comment token's data. Stay in the comment end |
@@ -1361,7 +1361,7 @@ discard block |
||
| 1361 | 1361 | )); |
| 1362 | 1362 | $this->token['data'] .= '-'; |
| 1363 | 1363 | |
| 1364 | - } elseif($char === "\t" || $char === "\n" || $char === "\x0a" || $char === ' ') { |
|
| 1364 | + } elseif ($char === "\t" || $char === "\n" || $char === "\x0a" || $char === ' ') { |
|
| 1365 | 1365 | $this->emitToken(array( |
| 1366 | 1366 | 'type' => self::PARSEERROR, |
| 1367 | 1367 | 'data' => 'unexpected-space-after-double-dash-in-comment' |
@@ -1369,14 +1369,14 @@ discard block |
||
| 1369 | 1369 | $this->token['data'] .= '--' . $char; |
| 1370 | 1370 | $state = 'comment end space'; |
| 1371 | 1371 | |
| 1372 | - } elseif($char === '!') { |
|
| 1372 | + } elseif ($char === '!') { |
|
| 1373 | 1373 | $this->emitToken(array( |
| 1374 | 1374 | 'type' => self::PARSEERROR, |
| 1375 | 1375 | 'data' => 'unexpected-bang-after-double-dash-in-comment' |
| 1376 | 1376 | )); |
| 1377 | 1377 | $state = 'comment end bang'; |
| 1378 | 1378 | |
| 1379 | - } elseif($char === false) { |
|
| 1379 | + } elseif ($char === false) { |
|
| 1380 | 1380 | /* EOF |
| 1381 | 1381 | Parse error. Emit the comment token. Reconsume the |
| 1382 | 1382 | EOF character in the data state. */ |
@@ -1397,7 +1397,7 @@ discard block |
||
| 1397 | 1397 | 'type' => self::PARSEERROR, |
| 1398 | 1398 | 'data' => 'unexpected-char-in-comment' |
| 1399 | 1399 | )); |
| 1400 | - $this->token['data'] .= '--'.$char; |
|
| 1400 | + $this->token['data'] .= '--' . $char; |
|
| 1401 | 1401 | $state = 'comment'; |
| 1402 | 1402 | } |
| 1403 | 1403 | break; |
@@ -1451,7 +1451,7 @@ discard block |
||
| 1451 | 1451 | /* Consume the next input character: */ |
| 1452 | 1452 | $char = $this->stream->char(); |
| 1453 | 1453 | |
| 1454 | - if($char === "\t" || $char === "\n" || $char === "\x0c" || $char === ' ') { |
|
| 1454 | + if ($char === "\t" || $char === "\n" || $char === "\x0c" || $char === ' ') { |
|
| 1455 | 1455 | /* U+0009 CHARACTER TABULATION |
| 1456 | 1456 | U+000A LINE FEED (LF) |
| 1457 | 1457 | U+000C FORM FEED (FF) |
@@ -1459,7 +1459,7 @@ discard block |
||
| 1459 | 1459 | Switch to the before DOCTYPE name state. */ |
| 1460 | 1460 | $state = 'before DOCTYPE name'; |
| 1461 | 1461 | |
| 1462 | - } elseif($char === false) { |
|
| 1462 | + } elseif ($char === false) { |
|
| 1463 | 1463 | /* EOF |
| 1464 | 1464 | Parse error. Create a new DOCTYPE token. Set its |
| 1465 | 1465 | force-quirks flag to on. Emit the token. Reconsume the |
@@ -1494,14 +1494,14 @@ discard block |
||
| 1494 | 1494 | /* Consume the next input character: */ |
| 1495 | 1495 | $char = $this->stream->char(); |
| 1496 | 1496 | |
| 1497 | - if($char === "\t" || $char === "\n" || $char === "\x0c" || $char === ' ') { |
|
| 1497 | + if ($char === "\t" || $char === "\n" || $char === "\x0c" || $char === ' ') { |
|
| 1498 | 1498 | /* U+0009 CHARACTER TABULATION |
| 1499 | 1499 | U+000A LINE FEED (LF) |
| 1500 | 1500 | U+000C FORM FEED (FF) |
| 1501 | 1501 | U+0020 SPACE |
| 1502 | 1502 | Stay in the before DOCTYPE name state. */ |
| 1503 | 1503 | |
| 1504 | - } elseif($char === '>') { |
|
| 1504 | + } elseif ($char === '>') { |
|
| 1505 | 1505 | /* U+003E GREATER-THAN SIGN (>) |
| 1506 | 1506 | Parse error. Create a new DOCTYPE token. Set its |
| 1507 | 1507 | force-quirks flag to on. Emit the token. Switch to the |
@@ -1519,7 +1519,7 @@ discard block |
||
| 1519 | 1519 | |
| 1520 | 1520 | $state = 'data'; |
| 1521 | 1521 | |
| 1522 | - } elseif('A' <= $char && $char <= 'Z') { |
|
| 1522 | + } elseif ('A' <= $char && $char <= 'Z') { |
|
| 1523 | 1523 | /* U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z |
| 1524 | 1524 | Create a new DOCTYPE token. Set the token's name to the |
| 1525 | 1525 | lowercase version of the input character (add 0x0020 to |
@@ -1533,7 +1533,7 @@ discard block |
||
| 1533 | 1533 | |
| 1534 | 1534 | $state = 'DOCTYPE name'; |
| 1535 | 1535 | |
| 1536 | - } elseif($char === false) { |
|
| 1536 | + } elseif ($char === false) { |
|
| 1537 | 1537 | /* EOF |
| 1538 | 1538 | Parse error. Create a new DOCTYPE token. Set its |
| 1539 | 1539 | force-quirks flag to on. Emit the token. Reconsume the |
@@ -1570,7 +1570,7 @@ discard block |
||
| 1570 | 1570 | /* Consume the next input character: */ |
| 1571 | 1571 | $char = $this->stream->char(); |
| 1572 | 1572 | |
| 1573 | - if($char === "\t" || $char === "\n" || $char === "\x0c" || $char === ' ') { |
|
| 1573 | + if ($char === "\t" || $char === "\n" || $char === "\x0c" || $char === ' ') { |
|
| 1574 | 1574 | /* U+0009 CHARACTER TABULATION |
| 1575 | 1575 | U+000A LINE FEED (LF) |
| 1576 | 1576 | U+000C FORM FEED (FF) |
@@ -1578,20 +1578,20 @@ discard block |
||
| 1578 | 1578 | Switch to the after DOCTYPE name state. */ |
| 1579 | 1579 | $state = 'after DOCTYPE name'; |
| 1580 | 1580 | |
| 1581 | - } elseif($char === '>') { |
|
| 1581 | + } elseif ($char === '>') { |
|
| 1582 | 1582 | /* U+003E GREATER-THAN SIGN (>) |
| 1583 | 1583 | Emit the current DOCTYPE token. Switch to the data state. */ |
| 1584 | 1584 | $this->emitToken($this->token); |
| 1585 | 1585 | $state = 'data'; |
| 1586 | 1586 | |
| 1587 | - } elseif('A' <= $char && $char <= 'Z') { |
|
| 1587 | + } elseif ('A' <= $char && $char <= 'Z') { |
|
| 1588 | 1588 | /* U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z |
| 1589 | 1589 | Append the lowercase version of the input character |
| 1590 | 1590 | (add 0x0020 to the character's code point) to the current |
| 1591 | 1591 | DOCTYPE token's name. Stay in the DOCTYPE name state. */ |
| 1592 | 1592 | $this->token['name'] .= strtolower($char); |
| 1593 | 1593 | |
| 1594 | - } elseif($char === false) { |
|
| 1594 | + } elseif ($char === false) { |
|
| 1595 | 1595 | /* EOF |
| 1596 | 1596 | Parse error. Set the DOCTYPE token's force-quirks flag |
| 1597 | 1597 | to on. Emit that DOCTYPE token. Reconsume the EOF |
@@ -1624,20 +1624,20 @@ discard block |
||
| 1624 | 1624 | /* Consume the next input character: */ |
| 1625 | 1625 | $char = $this->stream->char(); |
| 1626 | 1626 | |
| 1627 | - if($char === "\t" || $char === "\n" || $char === "\x0c" || $char === ' ') { |
|
| 1627 | + if ($char === "\t" || $char === "\n" || $char === "\x0c" || $char === ' ') { |
|
| 1628 | 1628 | /* U+0009 CHARACTER TABULATION |
| 1629 | 1629 | U+000A LINE FEED (LF) |
| 1630 | 1630 | U+000C FORM FEED (FF) |
| 1631 | 1631 | U+0020 SPACE |
| 1632 | 1632 | Stay in the after DOCTYPE name state. */ |
| 1633 | 1633 | |
| 1634 | - } elseif($char === '>') { |
|
| 1634 | + } elseif ($char === '>') { |
|
| 1635 | 1635 | /* U+003E GREATER-THAN SIGN (>) |
| 1636 | 1636 | Emit the current DOCTYPE token. Switch to the data state. */ |
| 1637 | 1637 | $this->emitToken($this->token); |
| 1638 | 1638 | $state = 'data'; |
| 1639 | 1639 | |
| 1640 | - } elseif($char === false) { |
|
| 1640 | + } elseif ($char === false) { |
|
| 1641 | 1641 | /* EOF |
| 1642 | 1642 | Parse error. Set the DOCTYPE token's force-quirks flag |
| 1643 | 1643 | to on. Emit that DOCTYPE token. Reconsume the EOF |
@@ -1688,7 +1688,7 @@ discard block |
||
| 1688 | 1688 | /* Consume the next input character: */ |
| 1689 | 1689 | $char = $this->stream->char(); |
| 1690 | 1690 | |
| 1691 | - if($char === "\t" || $char === "\n" || $char === "\x0c" || $char === ' ') { |
|
| 1691 | + if ($char === "\t" || $char === "\n" || $char === "\x0c" || $char === ' ') { |
|
| 1692 | 1692 | /* U+0009 CHARACTER TABULATION |
| 1693 | 1693 | U+000A LINE FEED (LF) |
| 1694 | 1694 | U+000C FORM FEED (FF) |
@@ -1828,7 +1828,7 @@ discard block |
||
| 1828 | 1828 | /* Consume the next input character: */ |
| 1829 | 1829 | $char = $this->stream->char(); |
| 1830 | 1830 | |
| 1831 | - if($char === "\t" || $char === "\n" || $char === "\x0c" || $char === ' ') { |
|
| 1831 | + if ($char === "\t" || $char === "\n" || $char === "\x0c" || $char === ' ') { |
|
| 1832 | 1832 | /* U+0009 CHARACTER TABULATION |
| 1833 | 1833 | U+000A LINE FEED (LF) |
| 1834 | 1834 | U+000C FORM FEED (FF) |
@@ -1882,7 +1882,7 @@ discard block |
||
| 1882 | 1882 | /* Consume the next input character: */ |
| 1883 | 1883 | $char = $this->stream->char(); |
| 1884 | 1884 | |
| 1885 | - if($char === "\t" || $char === "\n" || $char === "\x0c" || $char === ' ') { |
|
| 1885 | + if ($char === "\t" || $char === "\n" || $char === "\x0c" || $char === ' ') { |
|
| 1886 | 1886 | /* U+0009 CHARACTER TABULATION |
| 1887 | 1887 | U+000A LINE FEED (LF) |
| 1888 | 1888 | U+000C FORM FEED (FF) |
@@ -2022,7 +2022,7 @@ discard block |
||
| 2022 | 2022 | /* Consume the next input character: */ |
| 2023 | 2023 | $char = $this->stream->char(); |
| 2024 | 2024 | |
| 2025 | - if($char === "\t" || $char === "\n" || $char === "\x0c" || $char === ' ') { |
|
| 2025 | + if ($char === "\t" || $char === "\n" || $char === "\x0c" || $char === ' ') { |
|
| 2026 | 2026 | /* U+0009 CHARACTER TABULATION |
| 2027 | 2027 | U+000A LINE FEED (LF) |
| 2028 | 2028 | U+000C FORM FEED (FF) |
@@ -2068,7 +2068,7 @@ discard block |
||
| 2068 | 2068 | $this->emitToken($this->token); |
| 2069 | 2069 | $state = 'data'; |
| 2070 | 2070 | |
| 2071 | - } elseif($char === false) { |
|
| 2071 | + } elseif ($char === false) { |
|
| 2072 | 2072 | /* EOF |
| 2073 | 2073 | Emit the DOCTYPE token. Reconsume the EOF character in |
| 2074 | 2074 | the data state. */ |
@@ -2376,7 +2376,7 @@ discard block |
||
| 2376 | 2376 | $this->emitToken(array_shift($this->stream->errors), false); |
| 2377 | 2377 | } |
| 2378 | 2378 | } |
| 2379 | - if($token['type'] === self::ENDTAG && !empty($token['attr'])) { |
|
| 2379 | + if ($token['type'] === self::ENDTAG && !empty($token['attr'])) { |
|
| 2380 | 2380 | for ($i = 0; $i < count($token['attr']); $i++) { |
| 2381 | 2381 | $this->emitToken(array( |
| 2382 | 2382 | 'type' => self::PARSEERROR, |
@@ -2384,13 +2384,13 @@ discard block |
||
| 2384 | 2384 | )); |
| 2385 | 2385 | } |
| 2386 | 2386 | } |
| 2387 | - if($token['type'] === self::ENDTAG && !empty($token['self-closing'])) { |
|
| 2387 | + if ($token['type'] === self::ENDTAG && !empty($token['self-closing'])) { |
|
| 2388 | 2388 | $this->emitToken(array( |
| 2389 | 2389 | 'type' => self::PARSEERROR, |
| 2390 | 2390 | 'data' => 'self-closing-flag-on-end-tag', |
| 2391 | 2391 | )); |
| 2392 | 2392 | } |
| 2393 | - if($token['type'] === self::STARTTAG) { |
|
| 2393 | + if ($token['type'] === self::STARTTAG) { |
|
| 2394 | 2394 | // This could be changed to actually pass the tree-builder a hash |
| 2395 | 2395 | $hash = array(); |
| 2396 | 2396 | foreach ($token['attr'] as $keypair) { |
@@ -2405,16 +2405,16 @@ discard block |
||
| 2405 | 2405 | } |
| 2406 | 2406 | } |
| 2407 | 2407 | |
| 2408 | - if(!$dry) { |
|
| 2408 | + if (!$dry) { |
|
| 2409 | 2409 | // the current structure of attributes is not a terribly good one |
| 2410 | 2410 | $this->tree->emitToken($token); |
| 2411 | 2411 | } |
| 2412 | 2412 | |
| 2413 | - if(!$dry && is_int($this->tree->content_model)) { |
|
| 2413 | + if (!$dry && is_int($this->tree->content_model)) { |
|
| 2414 | 2414 | $this->content_model = $this->tree->content_model; |
| 2415 | 2415 | $this->tree->content_model = null; |
| 2416 | 2416 | |
| 2417 | - } elseif($token['type'] === self::ENDTAG) { |
|
| 2417 | + } elseif ($token['type'] === self::ENDTAG) { |
|
| 2418 | 2418 | $this->content_model = self::PCDATA; |
| 2419 | 2419 | } |
| 2420 | 2420 | } |
@@ -86,8 +86,11 @@ discard block |
||
| 86 | 86 | */ |
| 87 | 87 | public function __construct($data, $builder = null) { |
| 88 | 88 | $this->stream = new HTML5_InputStream($data); |
| 89 | - if (!$builder) $this->tree = new HTML5_TreeBuilder; |
|
| 90 | - else $this->tree = $builder; |
|
| 89 | + if (!$builder) { |
|
| 90 | + $this->tree = new HTML5_TreeBuilder; |
|
| 91 | + } else { |
|
| 92 | + $this->tree = $builder; |
|
| 93 | + } |
|
| 91 | 94 | $this->content_model = self::PCDATA; |
| 92 | 95 | } |
| 93 | 96 | |
@@ -135,7 +138,9 @@ discard block |
||
| 135 | 138 | /* Consume the next input character */ |
| 136 | 139 | $char = $this->stream->char(); |
| 137 | 140 | $lastFourChars .= $char; |
| 138 | - if (strlen($lastFourChars) > 4) $lastFourChars = substr($lastFourChars, -4); |
|
| 141 | + if (strlen($lastFourChars) > 4) { |
|
| 142 | + $lastFourChars = substr($lastFourChars, -4); |
|
| 143 | + } |
|
| 139 | 144 | |
| 140 | 145 | // see below for meaning |
| 141 | 146 | $hyp_cond = |
@@ -248,7 +253,9 @@ discard block |
||
| 248 | 253 | 'data' => $char . $chars |
| 249 | 254 | )); |
| 250 | 255 | $lastFourChars .= $chars; |
| 251 | - if (strlen($lastFourChars) > 4) $lastFourChars = substr($lastFourChars, -4); |
|
| 256 | + if (strlen($lastFourChars) > 4) { |
|
| 257 | + $lastFourChars = substr($lastFourChars, -4); |
|
| 258 | + } |
|
| 252 | 259 | |
| 253 | 260 | } else { |
| 254 | 261 | /* Anything else |
@@ -257,10 +264,18 @@ discard block |
||
| 257 | 264 | as a single character token. Stay in the data state. */ |
| 258 | 265 | |
| 259 | 266 | $mask = ''; |
| 260 | - if ($hyp_cond) $mask .= '-'; |
|
| 261 | - if ($amp_cond) $mask .= '&'; |
|
| 262 | - if ($lt_cond) $mask .= '<'; |
|
| 263 | - if ($gt_cond) $mask .= '>'; |
|
| 267 | + if ($hyp_cond) { |
|
| 268 | + $mask .= '-'; |
|
| 269 | + } |
|
| 270 | + if ($amp_cond) { |
|
| 271 | + $mask .= '&'; |
|
| 272 | + } |
|
| 273 | + if ($lt_cond) { |
|
| 274 | + $mask .= '<'; |
|
| 275 | + } |
|
| 276 | + if ($gt_cond) { |
|
| 277 | + $mask .= '>'; |
|
| 278 | + } |
|
| 264 | 279 | |
| 265 | 280 | if ($mask === '') { |
| 266 | 281 | $chars = $this->stream->remainingChars(); |
@@ -274,7 +289,9 @@ discard block |
||
| 274 | 289 | )); |
| 275 | 290 | |
| 276 | 291 | $lastFourChars .= $chars; |
| 277 | - if (strlen($lastFourChars) > 4) $lastFourChars = substr($lastFourChars, -4); |
|
| 292 | + if (strlen($lastFourChars) > 4) { |
|
| 293 | + $lastFourChars = substr($lastFourChars, -4); |
|
| 294 | + } |
|
| 278 | 295 | |
| 279 | 296 | $state = 'data'; |
| 280 | 297 | } |
@@ -63,16 +63,16 @@ discard block |
||
| 63 | 63 | private $fragment = false; |
| 64 | 64 | private $root; |
| 65 | 65 | |
| 66 | - private $scoping = array('applet','button','caption','html','marquee','object','table','td','th', 'svg:foreignObject'); |
|
| 67 | - private $formatting = array('a','b','big','code','em','font','i','nobr','s','small','strike','strong','tt','u'); |
|
| 66 | + private $scoping = array('applet', 'button', 'caption', 'html', 'marquee', 'object', 'table', 'td', 'th', 'svg:foreignObject'); |
|
| 67 | + private $formatting = array('a', 'b', 'big', 'code', 'em', 'font', 'i', 'nobr', 's', 'small', 'strike', 'strong', 'tt', 'u'); |
|
| 68 | 68 | // dl and ds are speculative |
| 69 | - private $special = array('address','area','article','aside','base','basefont','bgsound', |
|
| 70 | - 'blockquote','body','br','center','col','colgroup','command','dc','dd','details','dir','div','dl','ds', |
|
| 71 | - 'dt','embed','fieldset','figure','footer','form','frame','frameset','h1','h2','h3','h4','h5', |
|
| 72 | - 'h6','head','header','hgroup','hr','iframe','img','input','isindex','li','link', |
|
| 73 | - 'listing','menu','meta','nav','noembed','noframes','noscript','ol', |
|
| 74 | - 'p','param','plaintext','pre','script','select','spacer','style', |
|
| 75 | - 'tbody','textarea','tfoot','thead','title','tr','ul','wbr'); |
|
| 69 | + private $special = array('address', 'area', 'article', 'aside', 'base', 'basefont', 'bgsound', |
|
| 70 | + 'blockquote', 'body', 'br', 'center', 'col', 'colgroup', 'command', 'dc', 'dd', 'details', 'dir', 'div', 'dl', 'ds', |
|
| 71 | + 'dt', 'embed', 'fieldset', 'figure', 'footer', 'form', 'frame', 'frameset', 'h1', 'h2', 'h3', 'h4', 'h5', |
|
| 72 | + 'h6', 'head', 'header', 'hgroup', 'hr', 'iframe', 'img', 'input', 'isindex', 'li', 'link', |
|
| 73 | + 'listing', 'menu', 'meta', 'nav', 'noembed', 'noframes', 'noscript', 'ol', |
|
| 74 | + 'p', 'param', 'plaintext', 'pre', 'script', 'select', 'spacer', 'style', |
|
| 75 | + 'tbody', 'textarea', 'tfoot', 'thead', 'title', 'tr', 'ul', 'wbr'); |
|
| 76 | 76 | |
| 77 | 77 | private $pendingTableCharacters; |
| 78 | 78 | private $pendingTableCharactersDirty; |
@@ -94,8 +94,8 @@ discard block |
||
| 94 | 94 | const IN_ROW = 13; |
| 95 | 95 | const IN_CELL = 14; |
| 96 | 96 | const IN_SELECT = 15; |
| 97 | - const IN_SELECT_IN_TABLE= 16; |
|
| 98 | - const IN_FOREIGN_CONTENT= 17; |
|
| 97 | + const IN_SELECT_IN_TABLE = 16; |
|
| 98 | + const IN_FOREIGN_CONTENT = 17; |
|
| 99 | 99 | const AFTER_BODY = 18; |
| 100 | 100 | const IN_FRAMESET = 19; |
| 101 | 101 | const AFTER_FRAMESET = 20; |
@@ -131,7 +131,7 @@ discard block |
||
| 131 | 131 | const LIMITED_QUIRKS_MODE = 202; |
| 132 | 132 | |
| 133 | 133 | // Marker to be placed in $a_formatting |
| 134 | - const MARKER = 300; |
|
| 134 | + const MARKER = 300; |
|
| 135 | 135 | |
| 136 | 136 | // Namespaces for foreign content |
| 137 | 137 | const NS_HTML = null; // to prevent DOM from requiring NS on everything |
@@ -369,12 +369,12 @@ discard block |
||
| 369 | 369 | case self::BEFORE_HTML: |
| 370 | 370 | |
| 371 | 371 | /* A DOCTYPE token */ |
| 372 | - if($token['type'] === HTML5_Tokenizer::DOCTYPE) { |
|
| 372 | + if ($token['type'] === HTML5_Tokenizer::DOCTYPE) { |
|
| 373 | 373 | // Parse error. Ignore the token. |
| 374 | 374 | $this->ignored = true; |
| 375 | 375 | |
| 376 | 376 | /* A comment token */ |
| 377 | - } elseif($token['type'] === HTML5_Tokenizer::COMMENT) { |
|
| 377 | + } elseif ($token['type'] === HTML5_Tokenizer::COMMENT) { |
|
| 378 | 378 | /* Append a Comment node to the Document object with the data |
| 379 | 379 | attribute set to the data given in the comment token. */ |
| 380 | 380 | // XDOM |
@@ -384,12 +384,12 @@ discard block |
||
| 384 | 384 | /* A character token that is one of one of U+0009 CHARACTER TABULATION, |
| 385 | 385 | U+000A LINE FEED (LF), U+000B LINE TABULATION, U+000C FORM FEED (FF), |
| 386 | 386 | or U+0020 SPACE */ |
| 387 | - } elseif($token['type'] === HTML5_Tokenizer::SPACECHARACTER) { |
|
| 387 | + } elseif ($token['type'] === HTML5_Tokenizer::SPACECHARACTER) { |
|
| 388 | 388 | /* Ignore the token. */ |
| 389 | 389 | $this->ignored = true; |
| 390 | 390 | |
| 391 | 391 | /* A start tag whose tag name is "html" */ |
| 392 | - } elseif($token['type'] === HTML5_Tokenizer::STARTTAG && $token['name'] == 'html') { |
|
| 392 | + } elseif ($token['type'] === HTML5_Tokenizer::STARTTAG && $token['name'] == 'html') { |
|
| 393 | 393 | /* Create an element for the token in the HTML namespace. Append it |
| 394 | 394 | * to the Document object. Put this element in the stack of open |
| 395 | 395 | * elements. */ |
@@ -420,30 +420,30 @@ discard block |
||
| 420 | 420 | /* A character token that is one of one of U+0009 CHARACTER TABULATION, |
| 421 | 421 | U+000A LINE FEED (LF), U+000B LINE TABULATION, U+000C FORM FEED (FF), |
| 422 | 422 | or U+0020 SPACE */ |
| 423 | - if($token['type'] === HTML5_Tokenizer::SPACECHARACTER) { |
|
| 423 | + if ($token['type'] === HTML5_Tokenizer::SPACECHARACTER) { |
|
| 424 | 424 | /* Ignore the token. */ |
| 425 | 425 | $this->ignored = true; |
| 426 | 426 | |
| 427 | 427 | /* A comment token */ |
| 428 | - } elseif($token['type'] === HTML5_Tokenizer::COMMENT) { |
|
| 428 | + } elseif ($token['type'] === HTML5_Tokenizer::COMMENT) { |
|
| 429 | 429 | /* Append a Comment node to the current node with the data attribute |
| 430 | 430 | set to the data given in the comment token. */ |
| 431 | 431 | $this->insertComment($token['data']); |
| 432 | 432 | |
| 433 | 433 | /* A DOCTYPE token */ |
| 434 | - } elseif($token['type'] === HTML5_Tokenizer::DOCTYPE) { |
|
| 434 | + } elseif ($token['type'] === HTML5_Tokenizer::DOCTYPE) { |
|
| 435 | 435 | /* Parse error. Ignore the token */ |
| 436 | 436 | $this->ignored = true; |
| 437 | 437 | // parse error |
| 438 | 438 | |
| 439 | 439 | /* A start tag token with the tag name "html" */ |
| 440 | - } elseif($token['type'] === HTML5_Tokenizer::STARTTAG && $token['name'] === 'html') { |
|
| 440 | + } elseif ($token['type'] === HTML5_Tokenizer::STARTTAG && $token['name'] === 'html') { |
|
| 441 | 441 | /* Process the token using the rules for the "in body" |
| 442 | 442 | * insertion mode. */ |
| 443 | 443 | $this->processWithRulesFor($token, self::IN_BODY); |
| 444 | 444 | |
| 445 | 445 | /* A start tag token with the tag name "head" */ |
| 446 | - } elseif($token['type'] === HTML5_Tokenizer::STARTTAG && $token['name'] === 'head') { |
|
| 446 | + } elseif ($token['type'] === HTML5_Tokenizer::STARTTAG && $token['name'] === 'head') { |
|
| 447 | 447 | /* Insert an HTML element for the token. */ |
| 448 | 448 | $element = $this->insertElement($token); |
| 449 | 449 | |
@@ -454,7 +454,7 @@ discard block |
||
| 454 | 454 | $this->mode = self::IN_HEAD; |
| 455 | 455 | |
| 456 | 456 | /* An end tag whose tag name is one of: "head", "body", "html", "br" */ |
| 457 | - } elseif( |
|
| 457 | + } elseif ( |
|
| 458 | 458 | $token['type'] === HTML5_Tokenizer::ENDTAG && ( |
| 459 | 459 | $token['name'] === 'head' || $token['name'] === 'body' || |
| 460 | 460 | $token['name'] === 'html' || $token['name'] === 'br' |
@@ -469,7 +469,7 @@ discard block |
||
| 469 | 469 | $this->emitToken($token); |
| 470 | 470 | |
| 471 | 471 | /* Any other end tag */ |
| 472 | - } elseif($token['type'] === HTML5_Tokenizer::ENDTAG) { |
|
| 472 | + } elseif ($token['type'] === HTML5_Tokenizer::ENDTAG) { |
|
| 473 | 473 | /* Parse error. Ignore the token. */ |
| 474 | 474 | $this->ignored = true; |
| 475 | 475 | |
@@ -493,29 +493,29 @@ discard block |
||
| 493 | 493 | /* A character token that is one of one of U+0009 CHARACTER TABULATION, |
| 494 | 494 | U+000A LINE FEED (LF), U+000B LINE TABULATION, U+000C FORM FEED (FF), |
| 495 | 495 | or U+0020 SPACE. */ |
| 496 | - if($token['type'] === HTML5_Tokenizer::SPACECHARACTER) { |
|
| 496 | + if ($token['type'] === HTML5_Tokenizer::SPACECHARACTER) { |
|
| 497 | 497 | /* Insert the character into the current node. */ |
| 498 | 498 | $this->insertText($token['data']); |
| 499 | 499 | |
| 500 | 500 | /* A comment token */ |
| 501 | - } elseif($token['type'] === HTML5_Tokenizer::COMMENT) { |
|
| 501 | + } elseif ($token['type'] === HTML5_Tokenizer::COMMENT) { |
|
| 502 | 502 | /* Append a Comment node to the current node with the data attribute |
| 503 | 503 | set to the data given in the comment token. */ |
| 504 | 504 | $this->insertComment($token['data']); |
| 505 | 505 | |
| 506 | 506 | /* A DOCTYPE token */ |
| 507 | - } elseif($token['type'] === HTML5_Tokenizer::DOCTYPE) { |
|
| 507 | + } elseif ($token['type'] === HTML5_Tokenizer::DOCTYPE) { |
|
| 508 | 508 | /* Parse error. Ignore the token. */ |
| 509 | 509 | $this->ignored = true; |
| 510 | 510 | // parse error |
| 511 | 511 | |
| 512 | 512 | /* A start tag whose tag name is "html" */ |
| 513 | - } elseif($token['type'] === HTML5_Tokenizer::STARTTAG && |
|
| 513 | + } elseif ($token['type'] === HTML5_Tokenizer::STARTTAG && |
|
| 514 | 514 | $token['name'] === 'html') { |
| 515 | 515 | $this->processWithRulesFor($token, self::IN_BODY); |
| 516 | 516 | |
| 517 | 517 | /* A start tag whose tag name is one of: "base", "command", "link" */ |
| 518 | - } elseif($token['type'] === HTML5_Tokenizer::STARTTAG && |
|
| 518 | + } elseif ($token['type'] === HTML5_Tokenizer::STARTTAG && |
|
| 519 | 519 | ($token['name'] === 'base' || $token['name'] === 'command' || |
| 520 | 520 | $token['name'] === 'link')) { |
| 521 | 521 | /* Insert an HTML element for the token. Immediately pop the |
@@ -526,7 +526,7 @@ discard block |
||
| 526 | 526 | // YYY: Acknowledge the token's self-closing flag, if it is set. |
| 527 | 527 | |
| 528 | 528 | /* A start tag whose tag name is "meta" */ |
| 529 | - } elseif($token['type'] === HTML5_Tokenizer::STARTTAG && $token['name'] === 'meta') { |
|
| 529 | + } elseif ($token['type'] === HTML5_Tokenizer::STARTTAG && $token['name'] === 'meta') { |
|
| 530 | 530 | /* Insert an HTML element for the token. Immediately pop the |
| 531 | 531 | * current node off the stack of open elements. */ |
| 532 | 532 | $this->insertElement($token); |
@@ -546,12 +546,12 @@ discard block |
||
| 546 | 546 | // the encoding encoding. |
| 547 | 547 | |
| 548 | 548 | /* A start tag with the tag name "title" */ |
| 549 | - } elseif($token['type'] === HTML5_Tokenizer::STARTTAG && $token['name'] === 'title') { |
|
| 549 | + } elseif ($token['type'] === HTML5_Tokenizer::STARTTAG && $token['name'] === 'title') { |
|
| 550 | 550 | $this->insertRCDATAElement($token); |
| 551 | 551 | |
| 552 | 552 | /* A start tag whose tag name is "noscript", if the scripting flag is enabled, or |
| 553 | 553 | * A start tag whose tag name is one of: "noframes", "style" */ |
| 554 | - } elseif($token['type'] === HTML5_Tokenizer::STARTTAG && |
|
| 554 | + } elseif ($token['type'] === HTML5_Tokenizer::STARTTAG && |
|
| 555 | 555 | ($token['name'] === 'noscript' || $token['name'] === 'noframes' || $token['name'] === 'style')) { |
| 556 | 556 | // XSCRIPT: Scripting flag not respected |
| 557 | 557 | $this->insertCDATAElement($token); |
@@ -559,7 +559,7 @@ discard block |
||
| 559 | 559 | // XSCRIPT: Scripting flag disable not implemented |
| 560 | 560 | |
| 561 | 561 | /* A start tag with the tag name "script" */ |
| 562 | - } elseif($token['type'] === HTML5_Tokenizer::STARTTAG && $token['name'] === 'script') { |
|
| 562 | + } elseif ($token['type'] === HTML5_Tokenizer::STARTTAG && $token['name'] === 'script') { |
|
| 563 | 563 | /* 1. Create an element for the token in the HTML namespace. */ |
| 564 | 564 | $node = $this->insertElement($token, false); |
| 565 | 565 | |
@@ -585,7 +585,7 @@ discard block |
||
| 585 | 585 | $this->content_model = HTML5_Tokenizer::CDATA; |
| 586 | 586 | |
| 587 | 587 | /* An end tag with the tag name "head" */ |
| 588 | - } elseif($token['type'] === HTML5_Tokenizer::ENDTAG && $token['name'] === 'head') { |
|
| 588 | + } elseif ($token['type'] === HTML5_Tokenizer::ENDTAG && $token['name'] === 'head') { |
|
| 589 | 589 | /* Pop the current node (which will be the head element) off the stack of open elements. */ |
| 590 | 590 | array_pop($this->stack); |
| 591 | 591 | |
@@ -595,7 +595,7 @@ discard block |
||
| 595 | 595 | // Slight logic inversion here to minimize duplication |
| 596 | 596 | /* A start tag with the tag name "head". */ |
| 597 | 597 | /* An end tag whose tag name is not one of: "body", "html", "br" */ |
| 598 | - } elseif(($token['type'] === HTML5_Tokenizer::STARTTAG && $token['name'] === 'head') || |
|
| 598 | + } elseif (($token['type'] === HTML5_Tokenizer::STARTTAG && $token['name'] === 'head') || |
|
| 599 | 599 | ($token['type'] === HTML5_Tokenizer::ENDTAG && $token['name'] !== 'html' && |
| 600 | 600 | $token['name'] !== 'body' && $token['name'] !== 'br')) { |
| 601 | 601 | // Parse error. Ignore the token. |
@@ -656,12 +656,12 @@ discard block |
||
| 656 | 656 | /* A character token that is one of one of U+0009 CHARACTER TABULATION, |
| 657 | 657 | U+000A LINE FEED (LF), U+000B LINE TABULATION, U+000C FORM FEED (FF), |
| 658 | 658 | or U+0020 SPACE */ |
| 659 | - if($token['type'] === HTML5_Tokenizer::SPACECHARACTER) { |
|
| 659 | + if ($token['type'] === HTML5_Tokenizer::SPACECHARACTER) { |
|
| 660 | 660 | /* Append the character to the current node. */ |
| 661 | 661 | $this->insertText($token['data']); |
| 662 | 662 | |
| 663 | 663 | /* A comment token */ |
| 664 | - } elseif($token['type'] === HTML5_Tokenizer::COMMENT) { |
|
| 664 | + } elseif ($token['type'] === HTML5_Tokenizer::COMMENT) { |
|
| 665 | 665 | /* Append a Comment node to the current node with the data attribute |
| 666 | 666 | set to the data given in the comment token. */ |
| 667 | 667 | $this->insertComment($token['data']); |
@@ -673,7 +673,7 @@ discard block |
||
| 673 | 673 | $this->processWithRulesFor($token, self::IN_BODY); |
| 674 | 674 | |
| 675 | 675 | /* A start tag token with the tag name "body" */ |
| 676 | - } elseif($token['type'] === HTML5_Tokenizer::STARTTAG && $token['name'] === 'body') { |
|
| 676 | + } elseif ($token['type'] === HTML5_Tokenizer::STARTTAG && $token['name'] === 'body') { |
|
| 677 | 677 | $this->insertElement($token); |
| 678 | 678 | |
| 679 | 679 | /* Set the frameset-ok flag to "not ok". */ |
@@ -683,7 +683,7 @@ discard block |
||
| 683 | 683 | $this->mode = self::IN_BODY; |
| 684 | 684 | |
| 685 | 685 | /* A start tag token with the tag name "frameset" */ |
| 686 | - } elseif($token['type'] === HTML5_Tokenizer::STARTTAG && $token['name'] === 'frameset') { |
|
| 686 | + } elseif ($token['type'] === HTML5_Tokenizer::STARTTAG && $token['name'] === 'frameset') { |
|
| 687 | 687 | /* Insert a frameset element for the token. */ |
| 688 | 688 | $this->insertElement($token); |
| 689 | 689 | |
@@ -692,7 +692,7 @@ discard block |
||
| 692 | 692 | |
| 693 | 693 | /* A start tag token whose tag name is one of: "base", "link", "meta", |
| 694 | 694 | "script", "style", "title" */ |
| 695 | - } elseif($token['type'] === HTML5_Tokenizer::STARTTAG && in_array($token['name'], |
|
| 695 | + } elseif ($token['type'] === HTML5_Tokenizer::STARTTAG && in_array($token['name'], |
|
| 696 | 696 | array('base', 'link', 'meta', 'noframes', 'script', 'style', 'title'))) { |
| 697 | 697 | // parse error |
| 698 | 698 | /* Push the node pointed to by the head element pointer onto the |
@@ -702,7 +702,7 @@ discard block |
||
| 702 | 702 | array_splice($this->stack, array_search($this->head_pointer, $this->stack, true), 1); |
| 703 | 703 | |
| 704 | 704 | // inversion of specification |
| 705 | - } elseif( |
|
| 705 | + } elseif ( |
|
| 706 | 706 | ($token['type'] === HTML5_Tokenizer::STARTTAG && $token['name'] === 'head') || |
| 707 | 707 | ($token['type'] === HTML5_Tokenizer::ENDTAG && |
| 708 | 708 | $token['name'] !== 'body' && $token['name'] !== 'html' && |
@@ -724,7 +724,7 @@ discard block |
||
| 724 | 724 | case self::IN_BODY: |
| 725 | 725 | /* Handle the token as follows: */ |
| 726 | 726 | |
| 727 | - switch($token['type']) { |
|
| 727 | + switch ($token['type']) { |
|
| 728 | 728 | /* A character token */ |
| 729 | 729 | case HTML5_Tokenizer::CHARACTER: |
| 730 | 730 | case HTML5_Tokenizer::SPACECHARACTER: |
@@ -759,15 +759,15 @@ discard block |
||
| 759 | 759 | break; |
| 760 | 760 | |
| 761 | 761 | case HTML5_Tokenizer::STARTTAG: |
| 762 | - switch($token['name']) { |
|
| 762 | + switch ($token['name']) { |
|
| 763 | 763 | case 'html': |
| 764 | 764 | // parse error |
| 765 | 765 | /* For each attribute on the token, check to see if the |
| 766 | 766 | * attribute is already present on the top element of the |
| 767 | 767 | * stack of open elements. If it is not, add the attribute |
| 768 | 768 | * and its corresponding value to that element. */ |
| 769 | - foreach($token['attr'] as $attr) { |
|
| 770 | - if(!$this->stack[0]->hasAttribute($attr['name'])) { |
|
| 769 | + foreach ($token['attr'] as $attr) { |
|
| 770 | + if (!$this->stack[0]->hasAttribute($attr['name'])) { |
|
| 771 | 771 | $this->stack[0]->setAttribute($attr['name'], $attr['value']); |
| 772 | 772 | } |
| 773 | 773 | } |
@@ -786,7 +786,7 @@ discard block |
||
| 786 | 786 | elements is not a body element, or, if the stack of open |
| 787 | 787 | elements has only one node on it, then ignore the token. |
| 788 | 788 | (fragment case) */ |
| 789 | - if(count($this->stack) === 1 || $this->stack[1]->tagName !== 'body') { |
|
| 789 | + if (count($this->stack) === 1 || $this->stack[1]->tagName !== 'body') { |
|
| 790 | 790 | $this->ignored = true; |
| 791 | 791 | // Ignore |
| 792 | 792 | |
@@ -796,8 +796,8 @@ discard block |
||
| 796 | 796 | add the attribute and its corresponding value to that |
| 797 | 797 | element. */ |
| 798 | 798 | } else { |
| 799 | - foreach($token['attr'] as $attr) { |
|
| 800 | - if(!$this->stack[1]->hasAttribute($attr['name'])) { |
|
| 799 | + foreach ($token['attr'] as $attr) { |
|
| 800 | + if (!$this->stack[1]->hasAttribute($attr['name'])) { |
|
| 801 | 801 | $this->stack[1]->setAttribute($attr['name'], $attr['value']); |
| 802 | 802 | } |
| 803 | 803 | } |
@@ -810,7 +810,7 @@ discard block |
||
| 810 | 810 | * not a body element, or, if the stack of open elements |
| 811 | 811 | * has only one node on it, then ignore the token. |
| 812 | 812 | * (fragment case) */ |
| 813 | - if(count($this->stack) === 1 || $this->stack[1]->tagName !== 'body') { |
|
| 813 | + if (count($this->stack) === 1 || $this->stack[1]->tagName !== 'body') { |
|
| 814 | 814 | $this->ignored = true; |
| 815 | 815 | // Ignore |
| 816 | 816 | } elseif (!$this->flag_frameset_ok) { |
@@ -819,7 +819,7 @@ discard block |
||
| 819 | 819 | } else { |
| 820 | 820 | /* 1. Remove the second element on the stack of open |
| 821 | 821 | * elements from its parent node, if it has one. */ |
| 822 | - if($this->stack[1]->parentNode) { |
|
| 822 | + if ($this->stack[1]->parentNode) { |
|
| 823 | 823 | $this->stack[1]->parentNode->removeChild($this->stack[1]); |
| 824 | 824 | } |
| 825 | 825 | |
@@ -843,7 +843,7 @@ discard block |
||
| 843 | 843 | /* If the stack of open elements has a p element in scope, |
| 844 | 844 | then act as if an end tag with the tag name p had been |
| 845 | 845 | seen. */ |
| 846 | - if($this->elementInScope('p')) { |
|
| 846 | + if ($this->elementInScope('p')) { |
|
| 847 | 847 | $this->emitToken(array( |
| 848 | 848 | 'name' => 'p', |
| 849 | 849 | 'type' => HTML5_Tokenizer::ENDTAG |
@@ -859,7 +859,7 @@ discard block |
||
| 859 | 859 | case 'h1': case 'h2': case 'h3': case 'h4': case 'h5': case 'h6': |
| 860 | 860 | /* If the stack of open elements has a p element in scope, |
| 861 | 861 | then act as if an end tag with the tag name p had been seen. */ |
| 862 | - if($this->elementInScope('p')) { |
|
| 862 | + if ($this->elementInScope('p')) { |
|
| 863 | 863 | $this->emitToken(array( |
| 864 | 864 | 'name' => 'p', |
| 865 | 865 | 'type' => HTML5_Tokenizer::ENDTAG |
@@ -884,7 +884,7 @@ discard block |
||
| 884 | 884 | case 'pre': case 'listing': |
| 885 | 885 | /* If the stack of open elements has a p element in scope, |
| 886 | 886 | then act as if an end tag with the tag name p had been seen. */ |
| 887 | - if($this->elementInScope('p')) { |
|
| 887 | + if ($this->elementInScope('p')) { |
|
| 888 | 888 | $this->emitToken(array( |
| 889 | 889 | 'name' => 'p', |
| 890 | 890 | 'type' => HTML5_Tokenizer::ENDTAG |
@@ -903,7 +903,7 @@ discard block |
||
| 903 | 903 | case 'form': |
| 904 | 904 | /* If the form element pointer is not null, ignore the |
| 905 | 905 | token with a parse error. */ |
| 906 | - if($this->form_pointer !== null) { |
|
| 906 | + if ($this->form_pointer !== null) { |
|
| 907 | 907 | $this->ignored = true; |
| 908 | 908 | // Ignore. |
| 909 | 909 | |
@@ -912,7 +912,7 @@ discard block |
||
| 912 | 912 | /* If the stack of open elements has a p element in |
| 913 | 913 | scope, then act as if an end tag with the tag name p |
| 914 | 914 | had been seen. */ |
| 915 | - if($this->elementInScope('p')) { |
|
| 915 | + if ($this->elementInScope('p')) { |
|
| 916 | 916 | $this->emitToken(array( |
| 917 | 917 | 'name' => 'p', |
| 918 | 918 | 'type' => HTML5_Tokenizer::ENDTAG |
@@ -932,7 +932,7 @@ discard block |
||
| 932 | 932 | $this->flag_frameset_ok = false; |
| 933 | 933 | |
| 934 | 934 | $stack_length = count($this->stack) - 1; |
| 935 | - for($n = $stack_length; 0 <= $n; $n--) { |
|
| 935 | + for ($n = $stack_length; 0 <= $n; $n--) { |
|
| 936 | 936 | /* 2. Initialise node to be the current node (the |
| 937 | 937 | bottommost node of the stack). */ |
| 938 | 938 | $stop = false; |
@@ -947,7 +947,7 @@ discard block |
||
| 947 | 947 | /* If node is a dc, dd, ds or dt element, then act as if an end |
| 948 | 948 | * tag with the same tag name as node had been seen, then |
| 949 | 949 | * jump to the last step. */ |
| 950 | - if(($token['name'] === 'li' && $node->tagName === 'li') || |
|
| 950 | + if (($token['name'] === 'li' && $node->tagName === 'li') || |
|
| 951 | 951 | ($token['name'] !== 'li' && ($node->tagName == 'dc' || $node->tagName === 'dd' || $node->tagName == 'ds' || $node->tagName === 'dt'))) { // limited conditional |
| 952 | 952 | $this->emitToken(array( |
| 953 | 953 | 'type' => HTML5_Tokenizer::ENDTAG, |
@@ -959,7 +959,7 @@ discard block |
||
| 959 | 959 | /* 4. If node is not in the formatting category, and is |
| 960 | 960 | not in the phrasing category, and is not an address, |
| 961 | 961 | div or p element, then stop this algorithm. */ |
| 962 | - if($cat !== self::FORMATTING && $cat !== self::PHRASING && |
|
| 962 | + if ($cat !== self::FORMATTING && $cat !== self::PHRASING && |
|
| 963 | 963 | $node->tagName !== 'address' && $node->tagName !== 'div' && |
| 964 | 964 | $node->tagName !== 'p') { |
| 965 | 965 | break; |
@@ -974,7 +974,7 @@ discard block |
||
| 974 | 974 | /* If the stack of open elements has a p element in scope, |
| 975 | 975 | then act as if an end tag with the tag name p had been |
| 976 | 976 | seen. */ |
| 977 | - if($this->elementInScope('p')) { |
|
| 977 | + if ($this->elementInScope('p')) { |
|
| 978 | 978 | $this->emitToken(array( |
| 979 | 979 | 'name' => 'p', |
| 980 | 980 | 'type' => HTML5_Tokenizer::ENDTAG |
@@ -991,7 +991,7 @@ discard block |
||
| 991 | 991 | /* If the stack of open elements has a p element in scope, |
| 992 | 992 | then act as if an end tag with the tag name p had been |
| 993 | 993 | seen. */ |
| 994 | - if($this->elementInScope('p')) { |
|
| 994 | + if ($this->elementInScope('p')) { |
|
| 995 | 995 | $this->emitToken(array( |
| 996 | 996 | 'name' => 'p', |
| 997 | 997 | 'type' => HTML5_Tokenizer::ENDTAG |
@@ -1019,11 +1019,11 @@ discard block |
||
| 1019 | 1019 | might not have if the element is not in table scope). */ |
| 1020 | 1020 | $leng = count($this->a_formatting); |
| 1021 | 1021 | |
| 1022 | - for($n = $leng - 1; $n >= 0; $n--) { |
|
| 1023 | - if($this->a_formatting[$n] === self::MARKER) { |
|
| 1022 | + for ($n = $leng - 1; $n >= 0; $n--) { |
|
| 1023 | + if ($this->a_formatting[$n] === self::MARKER) { |
|
| 1024 | 1024 | break; |
| 1025 | 1025 | |
| 1026 | - } elseif($this->a_formatting[$n]->tagName === 'a') { |
|
| 1026 | + } elseif ($this->a_formatting[$n]->tagName === 'a') { |
|
| 1027 | 1027 | $a = $this->a_formatting[$n]; |
| 1028 | 1028 | $this->emitToken(array( |
| 1029 | 1029 | 'name' => 'a', |
@@ -1031,7 +1031,7 @@ discard block |
||
| 1031 | 1031 | )); |
| 1032 | 1032 | if (in_array($a, $this->a_formatting)) { |
| 1033 | 1033 | $a_i = array_search($a, $this->a_formatting, true); |
| 1034 | - if($a_i !== false) array_splice($this->a_formatting, $a_i, 1); |
|
| 1034 | + if ($a_i !== false) array_splice($this->a_formatting, $a_i, 1); |
|
| 1035 | 1035 | } |
| 1036 | 1036 | if (in_array($a, $this->stack)) { |
| 1037 | 1037 | $a_i = array_search($a, $this->stack, true); |
@@ -1098,7 +1098,7 @@ discard block |
||
| 1098 | 1098 | then this is a parse error; act as if an end tag with the tag |
| 1099 | 1099 | name "button" had been seen, then reprocess the token. (We don't |
| 1100 | 1100 | do that. Unnecessary.) (I hope you're right! -- ezyang) */ |
| 1101 | - if($this->elementInScope('button')) { |
|
| 1101 | + if ($this->elementInScope('button')) { |
|
| 1102 | 1102 | $this->emitToken(array( |
| 1103 | 1103 | 'name' => 'button', |
| 1104 | 1104 | 'type' => HTML5_Tokenizer::ENDTAG |
@@ -1140,7 +1140,7 @@ discard block |
||
| 1140 | 1140 | * stack of open elements has a p element in scope, then |
| 1141 | 1141 | * act as if an end tag with the tag name "p" had been |
| 1142 | 1142 | * seen. */ |
| 1143 | - if($this->quirks_mode !== self::QUIRKS_MODE && |
|
| 1143 | + if ($this->quirks_mode !== self::QUIRKS_MODE && |
|
| 1144 | 1144 | $this->elementInScope('p')) { |
| 1145 | 1145 | $this->emitToken(array( |
| 1146 | 1146 | 'name' => 'p', |
@@ -1190,7 +1190,7 @@ discard block |
||
| 1190 | 1190 | case 'hr': |
| 1191 | 1191 | /* If the stack of open elements has a p element in scope, |
| 1192 | 1192 | then act as if an end tag with the tag name p had been seen. */ |
| 1193 | - if($this->elementInScope('p')) { |
|
| 1193 | + if ($this->elementInScope('p')) { |
|
| 1194 | 1194 | $this->emitToken(array( |
| 1195 | 1195 | 'name' => 'p', |
| 1196 | 1196 | 'type' => HTML5_Tokenizer::ENDTAG |
@@ -1222,7 +1222,7 @@ discard block |
||
| 1222 | 1222 | |
| 1223 | 1223 | /* If the form element pointer is not null, |
| 1224 | 1224 | then ignore the token. */ |
| 1225 | - if($this->form_pointer === null) { |
|
| 1225 | + if ($this->form_pointer === null) { |
|
| 1226 | 1226 | /* Act as if a start tag token with the tag name "form" had |
| 1227 | 1227 | been seen. */ |
| 1228 | 1228 | /* If the token has an attribute called "action", set |
@@ -1259,7 +1259,7 @@ discard block |
||
| 1259 | 1259 | /* Act as if a stream of character tokens had been seen. */ |
| 1260 | 1260 | $prompt = $this->getAttr($token, 'prompt'); |
| 1261 | 1261 | if ($prompt === false) { |
| 1262 | - $prompt = 'This is a searchable index. '. |
|
| 1262 | + $prompt = 'This is a searchable index. ' . |
|
| 1263 | 1263 | 'Insert your search keywords here: '; |
| 1264 | 1264 | } |
| 1265 | 1265 | $this->emitToken(array( |
@@ -1377,7 +1377,7 @@ discard block |
||
| 1377 | 1377 | * select". */ |
| 1378 | 1378 | if ( |
| 1379 | 1379 | $this->mode === self::IN_TABLE || $this->mode === self::IN_CAPTION || |
| 1380 | - $this->mode === self::IN_COLUMN_GROUP || $this->mode ==+self::IN_TABLE_BODY || |
|
| 1380 | + $this->mode === self::IN_COLUMN_GROUP || $this->mode == +self::IN_TABLE_BODY || |
|
| 1381 | 1381 | $this->mode === self::IN_ROW || $this->mode === self::IN_CELL |
| 1382 | 1382 | ) { |
| 1383 | 1383 | $this->mode = self::IN_SELECT_IN_TABLE; |
@@ -1466,13 +1466,13 @@ discard block |
||
| 1466 | 1466 | break; |
| 1467 | 1467 | |
| 1468 | 1468 | case HTML5_Tokenizer::ENDTAG: |
| 1469 | - switch($token['name']) { |
|
| 1469 | + switch ($token['name']) { |
|
| 1470 | 1470 | /* An end tag with the tag name "body" */ |
| 1471 | 1471 | case 'body': |
| 1472 | 1472 | /* If the stack of open elements does not have a body |
| 1473 | 1473 | * element in scope, this is a parse error; ignore the |
| 1474 | 1474 | * token. */ |
| 1475 | - if(!$this->elementInScope('body')) { |
|
| 1475 | + if (!$this->elementInScope('body')) { |
|
| 1476 | 1476 | $this->ignored = true; |
| 1477 | 1477 | |
| 1478 | 1478 | /* Otherwise, if there is a node in the stack of open |
@@ -1513,7 +1513,7 @@ discard block |
||
| 1513 | 1513 | /* If the stack of open elements has an element in scope |
| 1514 | 1514 | with the same tag name as that of the token, then generate |
| 1515 | 1515 | implied end tags. */ |
| 1516 | - if($this->elementInScope($token['name'])) { |
|
| 1516 | + if ($this->elementInScope($token['name'])) { |
|
| 1517 | 1517 | $this->generateImpliedEndTags(); |
| 1518 | 1518 | |
| 1519 | 1519 | /* Now, if the current node is not an element with |
@@ -1561,7 +1561,7 @@ discard block |
||
| 1561 | 1561 | case 'p': |
| 1562 | 1562 | /* If the stack of open elements has a p element in scope, |
| 1563 | 1563 | then generate implied end tags, except for p elements. */ |
| 1564 | - if($this->elementInScope('p')) { |
|
| 1564 | + if ($this->elementInScope('p')) { |
|
| 1565 | 1565 | /* Generate implied end tags, except for elements with |
| 1566 | 1566 | * the same tag name as the token. */ |
| 1567 | 1567 | $this->generateImpliedEndTags(array('p')); |
@@ -1612,7 +1612,7 @@ discard block |
||
| 1612 | 1612 | |
| 1613 | 1613 | /* An end tag whose tag name is "dc", "dd", "ds", "dt" */ |
| 1614 | 1614 | case 'dc': case 'dd': case 'ds': case 'dt': |
| 1615 | - if($this->elementInScope($token['name'])) { |
|
| 1615 | + if ($this->elementInScope($token['name'])) { |
|
| 1616 | 1616 | $this->generateImpliedEndTags(array($token['name'])); |
| 1617 | 1617 | |
| 1618 | 1618 | /* If the current node is not an element with the same |
@@ -1639,7 +1639,7 @@ discard block |
||
| 1639 | 1639 | /* If the stack of open elements has in scope an element whose |
| 1640 | 1640 | tag name is one of "h1", "h2", "h3", "h4", "h5", or "h6", then |
| 1641 | 1641 | generate implied end tags. */ |
| 1642 | - if($this->elementInScope($elements)) { |
|
| 1642 | + if ($this->elementInScope($elements)) { |
|
| 1643 | 1643 | $this->generateImpliedEndTags(); |
| 1644 | 1644 | |
| 1645 | 1645 | /* Now, if the current node is not an element with the same |
@@ -1671,12 +1671,12 @@ discard block |
||
| 1671 | 1671 | otherwise, and |
| 1672 | 1672 | * has the same tag name as the token. |
| 1673 | 1673 | */ |
| 1674 | - while(true) { |
|
| 1675 | - for($a = count($this->a_formatting) - 1; $a >= 0; $a--) { |
|
| 1676 | - if($this->a_formatting[$a] === self::MARKER) { |
|
| 1674 | + while (true) { |
|
| 1675 | + for ($a = count($this->a_formatting) - 1; $a >= 0; $a--) { |
|
| 1676 | + if ($this->a_formatting[$a] === self::MARKER) { |
|
| 1677 | 1677 | break; |
| 1678 | 1678 | |
| 1679 | - } elseif($this->a_formatting[$a]->tagName === $token['name']) { |
|
| 1679 | + } elseif ($this->a_formatting[$a]->tagName === $token['name']) { |
|
| 1680 | 1680 | $formatting_element = $this->a_formatting[$a]; |
| 1681 | 1681 | $in_stack = in_array($formatting_element, $this->stack, true); |
| 1682 | 1682 | $fe_af_pos = $a; |
@@ -1688,7 +1688,7 @@ discard block |
||
| 1688 | 1688 | also in the stack of open elements but the element |
| 1689 | 1689 | is not in scope, then this is a parse error. Abort |
| 1690 | 1690 | these steps. The token is ignored. */ |
| 1691 | - if(!isset($formatting_element) || ($in_stack && |
|
| 1691 | + if (!isset($formatting_element) || ($in_stack && |
|
| 1692 | 1692 | !$this->elementInScope($token['name']))) { |
| 1693 | 1693 | $this->ignored = true; |
| 1694 | 1694 | break; |
@@ -1697,7 +1697,7 @@ discard block |
||
| 1697 | 1697 | is not in the stack of open elements, then this is a |
| 1698 | 1698 | parse error; remove the element from the list, and |
| 1699 | 1699 | abort these steps. */ |
| 1700 | - } elseif(isset($formatting_element) && !$in_stack) { |
|
| 1700 | + } elseif (isset($formatting_element) && !$in_stack) { |
|
| 1701 | 1701 | unset($this->a_formatting[$fe_af_pos]); |
| 1702 | 1702 | $this->a_formatting = array_merge($this->a_formatting); |
| 1703 | 1703 | break; |
@@ -1718,10 +1718,10 @@ discard block |
||
| 1718 | 1718 | $fe_s_pos = array_search($formatting_element, $this->stack, true); |
| 1719 | 1719 | $length = count($this->stack); |
| 1720 | 1720 | |
| 1721 | - for($s = $fe_s_pos + 1; $s < $length; $s++) { |
|
| 1721 | + for ($s = $fe_s_pos + 1; $s < $length; $s++) { |
|
| 1722 | 1722 | $category = $this->getElementCategory($this->stack[$s]); |
| 1723 | 1723 | |
| 1724 | - if($category !== self::PHRASING && $category !== self::FORMATTING) { |
|
| 1724 | + if ($category !== self::PHRASING && $category !== self::FORMATTING) { |
|
| 1725 | 1725 | $furthest_block = $this->stack[$s]; |
| 1726 | 1726 | break; |
| 1727 | 1727 | } |
@@ -1733,8 +1733,8 @@ discard block |
||
| 1733 | 1733 | elements, from the current node up to the formatting |
| 1734 | 1734 | element, and remove the formatting element from the |
| 1735 | 1735 | list of active formatting elements. */ |
| 1736 | - if(!isset($furthest_block)) { |
|
| 1737 | - for($n = $length - 1; $n >= $fe_s_pos; $n--) { |
|
| 1736 | + if (!isset($furthest_block)) { |
|
| 1737 | + for ($n = $length - 1; $n >= $fe_s_pos; $n--) { |
|
| 1738 | 1738 | array_pop($this->stack); |
| 1739 | 1739 | } |
| 1740 | 1740 | |
@@ -1759,8 +1759,8 @@ discard block |
||
| 1759 | 1759 | $node = $furthest_block; |
| 1760 | 1760 | $last_node = $furthest_block; |
| 1761 | 1761 | |
| 1762 | - while(true) { |
|
| 1763 | - for($n = array_search($node, $this->stack, true) - 1; $n >= 0; $n--) { |
|
| 1762 | + while (true) { |
|
| 1763 | + for ($n = array_search($node, $this->stack, true) - 1; $n >= 0; $n--) { |
|
| 1764 | 1764 | /* 6.1 Let node be the element immediately |
| 1765 | 1765 | prior to node in the stack of open elements. */ |
| 1766 | 1766 | $node = $this->stack[$n]; |
@@ -1769,7 +1769,7 @@ discard block |
||
| 1769 | 1769 | formatting elements, then remove node from |
| 1770 | 1770 | the stack of open elements and then go back |
| 1771 | 1771 | to step 1. */ |
| 1772 | - if(!in_array($node, $this->a_formatting, true)) { |
|
| 1772 | + if (!in_array($node, $this->a_formatting, true)) { |
|
| 1773 | 1773 | array_splice($this->stack, $n, 1); |
| 1774 | 1774 | |
| 1775 | 1775 | } else { |
@@ -1780,14 +1780,14 @@ discard block |
||
| 1780 | 1780 | /* 6.3 Otherwise, if node is the formatting |
| 1781 | 1781 | element, then go to the next step in the overall |
| 1782 | 1782 | algorithm. */ |
| 1783 | - if($node === $formatting_element) { |
|
| 1783 | + if ($node === $formatting_element) { |
|
| 1784 | 1784 | break; |
| 1785 | 1785 | |
| 1786 | 1786 | /* 6.4 Otherwise, if last node is the furthest |
| 1787 | 1787 | block, then move the aforementioned bookmark to |
| 1788 | 1788 | be immediately after the node in the list of |
| 1789 | 1789 | active formatting elements. */ |
| 1790 | - } elseif($last_node === $furthest_block) { |
|
| 1790 | + } elseif ($last_node === $furthest_block) { |
|
| 1791 | 1791 | $bookmark = array_search($node, $this->a_formatting, true) + 1; |
| 1792 | 1792 | } |
| 1793 | 1793 | |
@@ -1810,7 +1810,7 @@ discard block |
||
| 1810 | 1810 | /* 6.6 Insert last node into node, first removing |
| 1811 | 1811 | it from its previous parent node if any. */ |
| 1812 | 1812 | // XDOM |
| 1813 | - if($last_node->parentNode !== null) { |
|
| 1813 | + if ($last_node->parentNode !== null) { |
|
| 1814 | 1814 | $last_node->parentNode->removeChild($last_node); |
| 1815 | 1815 | } |
| 1816 | 1816 | |
@@ -1852,7 +1852,7 @@ discard block |
||
| 1852 | 1852 | block and append them to the element created in the |
| 1853 | 1853 | last step. */ |
| 1854 | 1854 | // XDOM |
| 1855 | - while($furthest_block->hasChildNodes()) { |
|
| 1855 | + while ($furthest_block->hasChildNodes()) { |
|
| 1856 | 1856 | $child = $furthest_block->firstChild; |
| 1857 | 1857 | $furthest_block->removeChild($child); |
| 1858 | 1858 | $clone->appendChild($child); |
@@ -1894,7 +1894,7 @@ discard block |
||
| 1894 | 1894 | /* If the stack of open elements has an element in scope whose |
| 1895 | 1895 | tag name matches the tag name of the token, then generate implied |
| 1896 | 1896 | tags. */ |
| 1897 | - if($this->elementInScope($token['name'])) { |
|
| 1897 | + if ($this->elementInScope($token['name'])) { |
|
| 1898 | 1898 | $this->generateImpliedEndTags(); |
| 1899 | 1899 | |
| 1900 | 1900 | /* Now, if the current node is not an element with the same |
@@ -1913,7 +1913,7 @@ discard block |
||
| 1913 | 1913 | $keys = array_keys($this->a_formatting, self::MARKER, true); |
| 1914 | 1914 | $marker = end($keys); |
| 1915 | 1915 | |
| 1916 | - for($n = count($this->a_formatting) - 1; $n > $marker; $n--) { |
|
| 1916 | + for ($n = count($this->a_formatting) - 1; $n > $marker; $n--) { |
|
| 1917 | 1917 | array_pop($this->a_formatting); |
| 1918 | 1918 | } |
| 1919 | 1919 | } else { |
@@ -1931,14 +1931,14 @@ discard block |
||
| 1931 | 1931 | |
| 1932 | 1932 | /* An end tag token not covered by the previous entries */ |
| 1933 | 1933 | default: |
| 1934 | - for($n = count($this->stack) - 1; $n >= 0; $n--) { |
|
| 1934 | + for ($n = count($this->stack) - 1; $n >= 0; $n--) { |
|
| 1935 | 1935 | /* Initialise node to be the current node (the bottommost |
| 1936 | 1936 | node of the stack). */ |
| 1937 | 1937 | $node = $this->stack[$n]; |
| 1938 | 1938 | |
| 1939 | 1939 | /* If node has the same tag name as the end tag token, |
| 1940 | 1940 | then: */ |
| 1941 | - if($token['name'] === $node->tagName) { |
|
| 1941 | + if ($token['name'] === $node->tagName) { |
|
| 1942 | 1942 | /* Generate implied end tags. */ |
| 1943 | 1943 | $this->generateImpliedEndTags(); |
| 1944 | 1944 | |
@@ -1958,7 +1958,7 @@ discard block |
||
| 1958 | 1958 | } else { |
| 1959 | 1959 | $category = $this->getElementCategory($node); |
| 1960 | 1960 | |
| 1961 | - if($category !== self::FORMATTING && $category !== self::PHRASING) { |
|
| 1961 | + if ($category !== self::FORMATTING && $category !== self::PHRASING) { |
|
| 1962 | 1962 | /* Otherwise, if node is in neither the formatting |
| 1963 | 1963 | category nor the phrasing category, then this is a |
| 1964 | 1964 | parse error. Stop this algorithm. The end tag token |
@@ -2020,16 +2020,16 @@ discard block |
||
| 2020 | 2020 | $this->emitToken($token); |
| 2021 | 2021 | |
| 2022 | 2022 | /* A comment token */ |
| 2023 | - } elseif($token['type'] === HTML5_Tokenizer::COMMENT) { |
|
| 2023 | + } elseif ($token['type'] === HTML5_Tokenizer::COMMENT) { |
|
| 2024 | 2024 | /* Append a Comment node to the current node with the data |
| 2025 | 2025 | attribute set to the data given in the comment token. */ |
| 2026 | 2026 | $this->insertComment($token['data']); |
| 2027 | 2027 | |
| 2028 | - } elseif($token['type'] === HTML5_Tokenizer::DOCTYPE) { |
|
| 2028 | + } elseif ($token['type'] === HTML5_Tokenizer::DOCTYPE) { |
|
| 2029 | 2029 | // parse error |
| 2030 | 2030 | |
| 2031 | 2031 | /* A start tag whose tag name is "caption" */ |
| 2032 | - } elseif($token['type'] === HTML5_Tokenizer::STARTTAG && |
|
| 2032 | + } elseif ($token['type'] === HTML5_Tokenizer::STARTTAG && |
|
| 2033 | 2033 | $token['name'] === 'caption') { |
| 2034 | 2034 | /* Clear the stack back to a table context. */ |
| 2035 | 2035 | $this->clearStackToTableContext($clear); |
@@ -2044,7 +2044,7 @@ discard block |
||
| 2044 | 2044 | $this->mode = self::IN_CAPTION; |
| 2045 | 2045 | |
| 2046 | 2046 | /* A start tag whose tag name is "colgroup" */ |
| 2047 | - } elseif($token['type'] === HTML5_Tokenizer::STARTTAG && |
|
| 2047 | + } elseif ($token['type'] === HTML5_Tokenizer::STARTTAG && |
|
| 2048 | 2048 | $token['name'] === 'colgroup') { |
| 2049 | 2049 | /* Clear the stack back to a table context. */ |
| 2050 | 2050 | $this->clearStackToTableContext($clear); |
@@ -2055,7 +2055,7 @@ discard block |
||
| 2055 | 2055 | $this->mode = self::IN_COLUMN_GROUP; |
| 2056 | 2056 | |
| 2057 | 2057 | /* A start tag whose tag name is "col" */ |
| 2058 | - } elseif($token['type'] === HTML5_Tokenizer::STARTTAG && |
|
| 2058 | + } elseif ($token['type'] === HTML5_Tokenizer::STARTTAG && |
|
| 2059 | 2059 | $token['name'] === 'col') { |
| 2060 | 2060 | $this->emitToken(array( |
| 2061 | 2061 | 'name' => 'colgroup', |
@@ -2066,7 +2066,7 @@ discard block |
||
| 2066 | 2066 | $this->emitToken($token); |
| 2067 | 2067 | |
| 2068 | 2068 | /* A start tag whose tag name is one of: "tbody", "tfoot", "thead" */ |
| 2069 | - } elseif($token['type'] === HTML5_Tokenizer::STARTTAG && in_array($token['name'], |
|
| 2069 | + } elseif ($token['type'] === HTML5_Tokenizer::STARTTAG && in_array($token['name'], |
|
| 2070 | 2070 | array('tbody', 'tfoot', 'thead'))) { |
| 2071 | 2071 | /* Clear the stack back to a table context. */ |
| 2072 | 2072 | $this->clearStackToTableContext($clear); |
@@ -2077,7 +2077,7 @@ discard block |
||
| 2077 | 2077 | $this->mode = self::IN_TABLE_BODY; |
| 2078 | 2078 | |
| 2079 | 2079 | /* A start tag whose tag name is one of: "td", "th", "tr" */ |
| 2080 | - } elseif($token['type'] === HTML5_Tokenizer::STARTTAG && |
|
| 2080 | + } elseif ($token['type'] === HTML5_Tokenizer::STARTTAG && |
|
| 2081 | 2081 | in_array($token['name'], array('td', 'th', 'tr'))) { |
| 2082 | 2082 | /* Act as if a start tag token with the tag name "tbody" had been |
| 2083 | 2083 | seen, then reprocess the current token. */ |
@@ -2090,7 +2090,7 @@ discard block |
||
| 2090 | 2090 | $this->emitToken($token); |
| 2091 | 2091 | |
| 2092 | 2092 | /* A start tag whose tag name is "table" */ |
| 2093 | - } elseif($token['type'] === HTML5_Tokenizer::STARTTAG && |
|
| 2093 | + } elseif ($token['type'] === HTML5_Tokenizer::STARTTAG && |
|
| 2094 | 2094 | $token['name'] === 'table') { |
| 2095 | 2095 | /* Parse error. Act as if an end tag token with the tag name "table" |
| 2096 | 2096 | had been seen, then, if that token wasn't ignored, reprocess the |
@@ -2103,12 +2103,12 @@ discard block |
||
| 2103 | 2103 | if (!$this->ignored) $this->emitToken($token); |
| 2104 | 2104 | |
| 2105 | 2105 | /* An end tag whose tag name is "table" */ |
| 2106 | - } elseif($token['type'] === HTML5_Tokenizer::ENDTAG && |
|
| 2106 | + } elseif ($token['type'] === HTML5_Tokenizer::ENDTAG && |
|
| 2107 | 2107 | $token['name'] === 'table') { |
| 2108 | 2108 | /* If the stack of open elements does not have an element in table |
| 2109 | 2109 | scope with the same tag name as the token, this is a parse error. |
| 2110 | 2110 | Ignore the token. (fragment case) */ |
| 2111 | - if(!$this->elementInScope($token['name'], self::SCOPE_TABLE)) { |
|
| 2111 | + if (!$this->elementInScope($token['name'], self::SCOPE_TABLE)) { |
|
| 2112 | 2112 | $this->ignored = true; |
| 2113 | 2113 | |
| 2114 | 2114 | /* Otherwise: */ |
@@ -2123,12 +2123,12 @@ discard block |
||
| 2123 | 2123 | |
| 2124 | 2124 | /* An end tag whose tag name is one of: "body", "caption", "col", |
| 2125 | 2125 | "colgroup", "html", "tbody", "td", "tfoot", "th", "thead", "tr" */ |
| 2126 | - } elseif($token['type'] === HTML5_Tokenizer::ENDTAG && in_array($token['name'], |
|
| 2126 | + } elseif ($token['type'] === HTML5_Tokenizer::ENDTAG && in_array($token['name'], |
|
| 2127 | 2127 | array('body', 'caption', 'col', 'colgroup', 'html', 'tbody', 'td', |
| 2128 | 2128 | 'tfoot', 'th', 'thead', 'tr'))) { |
| 2129 | 2129 | // Parse error. Ignore the token. |
| 2130 | 2130 | |
| 2131 | - } elseif($token['type'] === HTML5_Tokenizer::STARTTAG && |
|
| 2131 | + } elseif ($token['type'] === HTML5_Tokenizer::STARTTAG && |
|
| 2132 | 2132 | ($token['name'] === 'style' || $token['name'] === 'script')) { |
| 2133 | 2133 | $this->processWithRulesFor($token, self::IN_HEAD); |
| 2134 | 2134 | |
@@ -2165,7 +2165,7 @@ discard block |
||
| 2165 | 2165 | |
| 2166 | 2166 | case self::IN_TABLE_TEXT: |
| 2167 | 2167 | /* A character token */ |
| 2168 | - if($token['type'] === HTML5_Tokenizer::CHARACTER) { |
|
| 2168 | + if ($token['type'] === HTML5_Tokenizer::CHARACTER) { |
|
| 2169 | 2169 | /* Append the character token to the pending table |
| 2170 | 2170 | * character tokens list. */ |
| 2171 | 2171 | $this->pendingTableCharacters .= $token['data']; |
@@ -2216,11 +2216,11 @@ discard block |
||
| 2216 | 2216 | |
| 2217 | 2217 | case self::IN_CAPTION: |
| 2218 | 2218 | /* An end tag whose tag name is "caption" */ |
| 2219 | - if($token['type'] === HTML5_Tokenizer::ENDTAG && $token['name'] === 'caption') { |
|
| 2219 | + if ($token['type'] === HTML5_Tokenizer::ENDTAG && $token['name'] === 'caption') { |
|
| 2220 | 2220 | /* If the stack of open elements does not have an element in table |
| 2221 | 2221 | scope with the same tag name as the token, this is a parse error. |
| 2222 | 2222 | Ignore the token. (fragment case) */ |
| 2223 | - if(!$this->elementInScope($token['name'], self::SCOPE_TABLE)) { |
|
| 2223 | + if (!$this->elementInScope($token['name'], self::SCOPE_TABLE)) { |
|
| 2224 | 2224 | $this->ignored = true; |
| 2225 | 2225 | // Ignore |
| 2226 | 2226 | |
@@ -2250,7 +2250,7 @@ discard block |
||
| 2250 | 2250 | /* A start tag whose tag name is one of: "caption", "col", "colgroup", |
| 2251 | 2251 | "tbody", "td", "tfoot", "th", "thead", "tr", or an end tag whose tag |
| 2252 | 2252 | name is "table" */ |
| 2253 | - } elseif(($token['type'] === HTML5_Tokenizer::STARTTAG && in_array($token['name'], |
|
| 2253 | + } elseif (($token['type'] === HTML5_Tokenizer::STARTTAG && in_array($token['name'], |
|
| 2254 | 2254 | array('caption', 'col', 'colgroup', 'tbody', 'td', 'tfoot', 'th', |
| 2255 | 2255 | 'thead', 'tr'))) || ($token['type'] === HTML5_Tokenizer::ENDTAG && |
| 2256 | 2256 | $token['name'] === 'table')) { |
@@ -2266,7 +2266,7 @@ discard block |
||
| 2266 | 2266 | |
| 2267 | 2267 | /* An end tag whose tag name is one of: "body", "col", "colgroup", |
| 2268 | 2268 | "html", "tbody", "td", "tfoot", "th", "thead", "tr" */ |
| 2269 | - } elseif($token['type'] === HTML5_Tokenizer::ENDTAG && in_array($token['name'], |
|
| 2269 | + } elseif ($token['type'] === HTML5_Tokenizer::ENDTAG && in_array($token['name'], |
|
| 2270 | 2270 | array('body', 'col', 'colgroup', 'html', 'tbody', 'tfoot', 'th', |
| 2271 | 2271 | 'thead', 'tr'))) { |
| 2272 | 2272 | // Parse error. Ignore the token. |
@@ -2283,24 +2283,24 @@ discard block |
||
| 2283 | 2283 | /* A character token that is one of one of U+0009 CHARACTER TABULATION, |
| 2284 | 2284 | U+000A LINE FEED (LF), U+000B LINE TABULATION, U+000C FORM FEED (FF), |
| 2285 | 2285 | or U+0020 SPACE */ |
| 2286 | - if($token['type'] === HTML5_Tokenizer::SPACECHARACTER) { |
|
| 2286 | + if ($token['type'] === HTML5_Tokenizer::SPACECHARACTER) { |
|
| 2287 | 2287 | /* Append the character to the current node. */ |
| 2288 | 2288 | $this->insertText($token['data']); |
| 2289 | 2289 | |
| 2290 | 2290 | /* A comment token */ |
| 2291 | - } elseif($token['type'] === HTML5_Tokenizer::COMMENT) { |
|
| 2291 | + } elseif ($token['type'] === HTML5_Tokenizer::COMMENT) { |
|
| 2292 | 2292 | /* Append a Comment node to the current node with the data |
| 2293 | 2293 | attribute set to the data given in the comment token. */ |
| 2294 | 2294 | $this->insertToken($token['data']); |
| 2295 | 2295 | |
| 2296 | - } elseif($token['type'] === HTML5_Tokenizer::DOCTYPE) { |
|
| 2296 | + } elseif ($token['type'] === HTML5_Tokenizer::DOCTYPE) { |
|
| 2297 | 2297 | // parse error |
| 2298 | 2298 | |
| 2299 | - } elseif($token['type'] === HTML5_Tokenizer::STARTTAG && $token['name'] === 'html') { |
|
| 2299 | + } elseif ($token['type'] === HTML5_Tokenizer::STARTTAG && $token['name'] === 'html') { |
|
| 2300 | 2300 | $this->processWithRulesFor($token, self::IN_BODY); |
| 2301 | 2301 | |
| 2302 | 2302 | /* A start tag whose tag name is "col" */ |
| 2303 | - } elseif($token['type'] === HTML5_Tokenizer::STARTTAG && $token['name'] === 'col') { |
|
| 2303 | + } elseif ($token['type'] === HTML5_Tokenizer::STARTTAG && $token['name'] === 'col') { |
|
| 2304 | 2304 | /* Insert a col element for the token. Immediately pop the current |
| 2305 | 2305 | node off the stack of open elements. */ |
| 2306 | 2306 | $this->insertElement($token); |
@@ -2308,11 +2308,11 @@ discard block |
||
| 2308 | 2308 | // XERROR: Acknowledge the token's self-closing flag, if it is set. |
| 2309 | 2309 | |
| 2310 | 2310 | /* An end tag whose tag name is "colgroup" */ |
| 2311 | - } elseif($token['type'] === HTML5_Tokenizer::ENDTAG && |
|
| 2311 | + } elseif ($token['type'] === HTML5_Tokenizer::ENDTAG && |
|
| 2312 | 2312 | $token['name'] === 'colgroup') { |
| 2313 | 2313 | /* If the current node is the root html element, then this is a |
| 2314 | 2314 | parse error, ignore the token. (fragment case) */ |
| 2315 | - if(end($this->stack)->tagName === 'html') { |
|
| 2315 | + if (end($this->stack)->tagName === 'html') { |
|
| 2316 | 2316 | $this->ignored = true; |
| 2317 | 2317 | |
| 2318 | 2318 | /* Otherwise, pop the current node (which will be a colgroup |
@@ -2324,13 +2324,13 @@ discard block |
||
| 2324 | 2324 | } |
| 2325 | 2325 | |
| 2326 | 2326 | /* An end tag whose tag name is "col" */ |
| 2327 | - } elseif($token['type'] === HTML5_Tokenizer::ENDTAG && $token['name'] === 'col') { |
|
| 2327 | + } elseif ($token['type'] === HTML5_Tokenizer::ENDTAG && $token['name'] === 'col') { |
|
| 2328 | 2328 | /* Parse error. Ignore the token. */ |
| 2329 | 2329 | $this->ignored = true; |
| 2330 | 2330 | |
| 2331 | 2331 | /* An end-of-file token */ |
| 2332 | 2332 | /* If the current node is the root html element */ |
| 2333 | - } elseif($token['type'] === HTML5_Tokenizer::EOF && end($this->stack)->tagName === 'html') { |
|
| 2333 | + } elseif ($token['type'] === HTML5_Tokenizer::EOF && end($this->stack)->tagName === 'html') { |
|
| 2334 | 2334 | /* Stop parsing */ |
| 2335 | 2335 | |
| 2336 | 2336 | /* Anything else */ |
@@ -2350,7 +2350,7 @@ discard block |
||
| 2350 | 2350 | $clear = array('tbody', 'tfoot', 'thead', 'html'); |
| 2351 | 2351 | |
| 2352 | 2352 | /* A start tag whose tag name is "tr" */ |
| 2353 | - if($token['type'] === HTML5_Tokenizer::STARTTAG && $token['name'] === 'tr') { |
|
| 2353 | + if ($token['type'] === HTML5_Tokenizer::STARTTAG && $token['name'] === 'tr') { |
|
| 2354 | 2354 | /* Clear the stack back to a table body context. */ |
| 2355 | 2355 | $this->clearStackToTableContext($clear); |
| 2356 | 2356 | |
@@ -2360,8 +2360,8 @@ discard block |
||
| 2360 | 2360 | $this->mode = self::IN_ROW; |
| 2361 | 2361 | |
| 2362 | 2362 | /* A start tag whose tag name is one of: "th", "td" */ |
| 2363 | - } elseif($token['type'] === HTML5_Tokenizer::STARTTAG && |
|
| 2364 | - ($token['name'] === 'th' || $token['name'] === 'td')) { |
|
| 2363 | + } elseif ($token['type'] === HTML5_Tokenizer::STARTTAG && |
|
| 2364 | + ($token['name'] === 'th' || $token['name'] === 'td')) { |
|
| 2365 | 2365 | /* Parse error. Act as if a start tag with the tag name "tr" had |
| 2366 | 2366 | been seen, then reprocess the current token. */ |
| 2367 | 2367 | $this->emitToken(array( |
@@ -2373,12 +2373,12 @@ discard block |
||
| 2373 | 2373 | $this->emitToken($token); |
| 2374 | 2374 | |
| 2375 | 2375 | /* An end tag whose tag name is one of: "tbody", "tfoot", "thead" */ |
| 2376 | - } elseif($token['type'] === HTML5_Tokenizer::ENDTAG && |
|
| 2376 | + } elseif ($token['type'] === HTML5_Tokenizer::ENDTAG && |
|
| 2377 | 2377 | in_array($token['name'], array('tbody', 'tfoot', 'thead'))) { |
| 2378 | 2378 | /* If the stack of open elements does not have an element in table |
| 2379 | 2379 | scope with the same tag name as the token, this is a parse error. |
| 2380 | 2380 | Ignore the token. */ |
| 2381 | - if(!$this->elementInScope($token['name'], self::SCOPE_TABLE)) { |
|
| 2381 | + if (!$this->elementInScope($token['name'], self::SCOPE_TABLE)) { |
|
| 2382 | 2382 | // Parse error |
| 2383 | 2383 | $this->ignored = true; |
| 2384 | 2384 | |
@@ -2395,13 +2395,13 @@ discard block |
||
| 2395 | 2395 | |
| 2396 | 2396 | /* A start tag whose tag name is one of: "caption", "col", "colgroup", |
| 2397 | 2397 | "tbody", "tfoot", "thead", or an end tag whose tag name is "table" */ |
| 2398 | - } elseif(($token['type'] === HTML5_Tokenizer::STARTTAG && in_array($token['name'], |
|
| 2398 | + } elseif (($token['type'] === HTML5_Tokenizer::STARTTAG && in_array($token['name'], |
|
| 2399 | 2399 | array('caption', 'col', 'colgroup', 'tbody', 'tfoot', 'thead'))) || |
| 2400 | 2400 | ($token['type'] === HTML5_Tokenizer::ENDTAG && $token['name'] === 'table')) { |
| 2401 | 2401 | /* If the stack of open elements does not have a tbody, thead, or |
| 2402 | 2402 | tfoot element in table scope, this is a parse error. Ignore the |
| 2403 | 2403 | token. (fragment case) */ |
| 2404 | - if(!$this->elementInScope(array('tbody', 'thead', 'tfoot'), self::SCOPE_TABLE)) { |
|
| 2404 | + if (!$this->elementInScope(array('tbody', 'thead', 'tfoot'), self::SCOPE_TABLE)) { |
|
| 2405 | 2405 | // parse error |
| 2406 | 2406 | $this->ignored = true; |
| 2407 | 2407 | |
@@ -2423,7 +2423,7 @@ discard block |
||
| 2423 | 2423 | |
| 2424 | 2424 | /* An end tag whose tag name is one of: "body", "caption", "col", |
| 2425 | 2425 | "colgroup", "html", "td", "th", "tr" */ |
| 2426 | - } elseif($token['type'] === HTML5_Tokenizer::ENDTAG && in_array($token['name'], |
|
| 2426 | + } elseif ($token['type'] === HTML5_Tokenizer::ENDTAG && in_array($token['name'], |
|
| 2427 | 2427 | array('body', 'caption', 'col', 'colgroup', 'html', 'td', 'th', 'tr'))) { |
| 2428 | 2428 | /* Parse error. Ignore the token. */ |
| 2429 | 2429 | $this->ignored = true; |
@@ -2439,7 +2439,7 @@ discard block |
||
| 2439 | 2439 | $clear = array('tr', 'html'); |
| 2440 | 2440 | |
| 2441 | 2441 | /* A start tag whose tag name is one of: "th", "td" */ |
| 2442 | - if($token['type'] === HTML5_Tokenizer::STARTTAG && |
|
| 2442 | + if ($token['type'] === HTML5_Tokenizer::STARTTAG && |
|
| 2443 | 2443 | ($token['name'] === 'th' || $token['name'] === 'td')) { |
| 2444 | 2444 | /* Clear the stack back to a table row context. */ |
| 2445 | 2445 | $this->clearStackToTableContext($clear); |
@@ -2454,11 +2454,11 @@ discard block |
||
| 2454 | 2454 | $this->a_formatting[] = self::MARKER; |
| 2455 | 2455 | |
| 2456 | 2456 | /* An end tag whose tag name is "tr" */ |
| 2457 | - } elseif($token['type'] === HTML5_Tokenizer::ENDTAG && $token['name'] === 'tr') { |
|
| 2457 | + } elseif ($token['type'] === HTML5_Tokenizer::ENDTAG && $token['name'] === 'tr') { |
|
| 2458 | 2458 | /* If the stack of open elements does not have an element in table |
| 2459 | 2459 | scope with the same tag name as the token, this is a parse error. |
| 2460 | 2460 | Ignore the token. (fragment case) */ |
| 2461 | - if(!$this->elementInScope($token['name'], self::SCOPE_TABLE)) { |
|
| 2461 | + if (!$this->elementInScope($token['name'], self::SCOPE_TABLE)) { |
|
| 2462 | 2462 | // Ignore. |
| 2463 | 2463 | $this->ignored = true; |
| 2464 | 2464 | |
@@ -2476,7 +2476,7 @@ discard block |
||
| 2476 | 2476 | |
| 2477 | 2477 | /* A start tag whose tag name is one of: "caption", "col", "colgroup", |
| 2478 | 2478 | "tbody", "tfoot", "thead", "tr" or an end tag whose tag name is "table" */ |
| 2479 | - } elseif(($token['type'] === HTML5_Tokenizer::STARTTAG && in_array($token['name'], |
|
| 2479 | + } elseif (($token['type'] === HTML5_Tokenizer::STARTTAG && in_array($token['name'], |
|
| 2480 | 2480 | array('caption', 'col', 'colgroup', 'tbody', 'tfoot', 'thead', 'tr'))) || |
| 2481 | 2481 | ($token['type'] === HTML5_Tokenizer::ENDTAG && $token['name'] === 'table')) { |
| 2482 | 2482 | /* Act as if an end tag with the tag name "tr" had been seen, then, |
@@ -2488,12 +2488,12 @@ discard block |
||
| 2488 | 2488 | if (!$this->ignored) $this->emitToken($token); |
| 2489 | 2489 | |
| 2490 | 2490 | /* An end tag whose tag name is one of: "tbody", "tfoot", "thead" */ |
| 2491 | - } elseif($token['type'] === HTML5_Tokenizer::ENDTAG && |
|
| 2491 | + } elseif ($token['type'] === HTML5_Tokenizer::ENDTAG && |
|
| 2492 | 2492 | in_array($token['name'], array('tbody', 'tfoot', 'thead'))) { |
| 2493 | 2493 | /* If the stack of open elements does not have an element in table |
| 2494 | 2494 | scope with the same tag name as the token, this is a parse error. |
| 2495 | 2495 | Ignore the token. */ |
| 2496 | - if(!$this->elementInScope($token['name'], self::SCOPE_TABLE)) { |
|
| 2496 | + if (!$this->elementInScope($token['name'], self::SCOPE_TABLE)) { |
|
| 2497 | 2497 | $this->ignored = true; |
| 2498 | 2498 | |
| 2499 | 2499 | /* Otherwise: */ |
@@ -2510,7 +2510,7 @@ discard block |
||
| 2510 | 2510 | |
| 2511 | 2511 | /* An end tag whose tag name is one of: "body", "caption", "col", |
| 2512 | 2512 | "colgroup", "html", "td", "th" */ |
| 2513 | - } elseif($token['type'] === HTML5_Tokenizer::ENDTAG && in_array($token['name'], |
|
| 2513 | + } elseif ($token['type'] === HTML5_Tokenizer::ENDTAG && in_array($token['name'], |
|
| 2514 | 2514 | array('body', 'caption', 'col', 'colgroup', 'html', 'td', 'th'))) { |
| 2515 | 2515 | /* Parse error. Ignore the token. */ |
| 2516 | 2516 | $this->ignored = true; |
@@ -2524,12 +2524,12 @@ discard block |
||
| 2524 | 2524 | |
| 2525 | 2525 | case self::IN_CELL: |
| 2526 | 2526 | /* An end tag whose tag name is one of: "td", "th" */ |
| 2527 | - if($token['type'] === HTML5_Tokenizer::ENDTAG && |
|
| 2527 | + if ($token['type'] === HTML5_Tokenizer::ENDTAG && |
|
| 2528 | 2528 | ($token['name'] === 'td' || $token['name'] === 'th')) { |
| 2529 | 2529 | /* If the stack of open elements does not have an element in table |
| 2530 | 2530 | scope with the same tag name as that of the token, then this is a |
| 2531 | 2531 | parse error and the token must be ignored. */ |
| 2532 | - if(!$this->elementInScope($token['name'], self::SCOPE_TABLE)) { |
|
| 2532 | + if (!$this->elementInScope($token['name'], self::SCOPE_TABLE)) { |
|
| 2533 | 2533 | $this->ignored = true; |
| 2534 | 2534 | |
| 2535 | 2535 | /* Otherwise: */ |
@@ -2559,13 +2559,13 @@ discard block |
||
| 2559 | 2559 | |
| 2560 | 2560 | /* A start tag whose tag name is one of: "caption", "col", "colgroup", |
| 2561 | 2561 | "tbody", "td", "tfoot", "th", "thead", "tr" */ |
| 2562 | - } elseif($token['type'] === HTML5_Tokenizer::STARTTAG && in_array($token['name'], |
|
| 2562 | + } elseif ($token['type'] === HTML5_Tokenizer::STARTTAG && in_array($token['name'], |
|
| 2563 | 2563 | array('caption', 'col', 'colgroup', 'tbody', 'td', 'tfoot', 'th', |
| 2564 | 2564 | 'thead', 'tr'))) { |
| 2565 | 2565 | /* If the stack of open elements does not have a td or th element |
| 2566 | 2566 | in table scope, then this is a parse error; ignore the token. |
| 2567 | 2567 | (fragment case) */ |
| 2568 | - if(!$this->elementInScope(array('td', 'th'), self::SCOPE_TABLE)) { |
|
| 2568 | + if (!$this->elementInScope(array('td', 'th'), self::SCOPE_TABLE)) { |
|
| 2569 | 2569 | // parse error |
| 2570 | 2570 | $this->ignored = true; |
| 2571 | 2571 | |
@@ -2578,19 +2578,19 @@ discard block |
||
| 2578 | 2578 | |
| 2579 | 2579 | /* An end tag whose tag name is one of: "body", "caption", "col", |
| 2580 | 2580 | "colgroup", "html" */ |
| 2581 | - } elseif($token['type'] === HTML5_Tokenizer::ENDTAG && in_array($token['name'], |
|
| 2581 | + } elseif ($token['type'] === HTML5_Tokenizer::ENDTAG && in_array($token['name'], |
|
| 2582 | 2582 | array('body', 'caption', 'col', 'colgroup', 'html'))) { |
| 2583 | 2583 | /* Parse error. Ignore the token. */ |
| 2584 | 2584 | $this->ignored = true; |
| 2585 | 2585 | |
| 2586 | 2586 | /* An end tag whose tag name is one of: "table", "tbody", "tfoot", |
| 2587 | 2587 | "thead", "tr" */ |
| 2588 | - } elseif($token['type'] === HTML5_Tokenizer::ENDTAG && in_array($token['name'], |
|
| 2588 | + } elseif ($token['type'] === HTML5_Tokenizer::ENDTAG && in_array($token['name'], |
|
| 2589 | 2589 | array('table', 'tbody', 'tfoot', 'thead', 'tr'))) { |
| 2590 | 2590 | /* If the stack of open elements does not have a td or th element |
| 2591 | 2591 | in table scope, then this is a parse error; ignore the token. |
| 2592 | 2592 | (innerHTML case) */ |
| 2593 | - if(!$this->elementInScope(array('td', 'th'), self::SCOPE_TABLE)) { |
|
| 2593 | + if (!$this->elementInScope(array('td', 'th'), self::SCOPE_TABLE)) { |
|
| 2594 | 2594 | // Parse error |
| 2595 | 2595 | $this->ignored = true; |
| 2596 | 2596 | |
@@ -2612,7 +2612,7 @@ discard block |
||
| 2612 | 2612 | /* Handle the token as follows: */ |
| 2613 | 2613 | |
| 2614 | 2614 | /* A character token */ |
| 2615 | - if( |
|
| 2615 | + if ( |
|
| 2616 | 2616 | $token['type'] === HTML5_Tokenizer::CHARACTER || |
| 2617 | 2617 | $token['type'] === HTML5_Tokenizer::SPACECHARACTER |
| 2618 | 2618 | ) { |
@@ -2620,23 +2620,23 @@ discard block |
||
| 2620 | 2620 | $this->insertText($token['data']); |
| 2621 | 2621 | |
| 2622 | 2622 | /* A comment token */ |
| 2623 | - } elseif($token['type'] === HTML5_Tokenizer::COMMENT) { |
|
| 2623 | + } elseif ($token['type'] === HTML5_Tokenizer::COMMENT) { |
|
| 2624 | 2624 | /* Append a Comment node to the current node with the data |
| 2625 | 2625 | attribute set to the data given in the comment token. */ |
| 2626 | 2626 | $this->insertComment($token['data']); |
| 2627 | 2627 | |
| 2628 | - } elseif($token['type'] === HTML5_Tokenizer::DOCTYPE) { |
|
| 2628 | + } elseif ($token['type'] === HTML5_Tokenizer::DOCTYPE) { |
|
| 2629 | 2629 | // parse error |
| 2630 | 2630 | |
| 2631 | - } elseif($token['type'] === HTML5_Tokenizer::STARTTAG && $token['name'] === 'html') { |
|
| 2631 | + } elseif ($token['type'] === HTML5_Tokenizer::STARTTAG && $token['name'] === 'html') { |
|
| 2632 | 2632 | $this->processWithRulesFor($token, self::INBODY); |
| 2633 | 2633 | |
| 2634 | 2634 | /* A start tag token whose tag name is "option" */ |
| 2635 | - } elseif($token['type'] === HTML5_Tokenizer::STARTTAG && |
|
| 2635 | + } elseif ($token['type'] === HTML5_Tokenizer::STARTTAG && |
|
| 2636 | 2636 | $token['name'] === 'option') { |
| 2637 | 2637 | /* If the current node is an option element, act as if an end tag |
| 2638 | 2638 | with the tag name "option" had been seen. */ |
| 2639 | - if(end($this->stack)->tagName === 'option') { |
|
| 2639 | + if (end($this->stack)->tagName === 'option') { |
|
| 2640 | 2640 | $this->emitToken(array( |
| 2641 | 2641 | 'name' => 'option', |
| 2642 | 2642 | 'type' => HTML5_Tokenizer::ENDTAG |
@@ -2647,11 +2647,11 @@ discard block |
||
| 2647 | 2647 | $this->insertElement($token); |
| 2648 | 2648 | |
| 2649 | 2649 | /* A start tag token whose tag name is "optgroup" */ |
| 2650 | - } elseif($token['type'] === HTML5_Tokenizer::STARTTAG && |
|
| 2650 | + } elseif ($token['type'] === HTML5_Tokenizer::STARTTAG && |
|
| 2651 | 2651 | $token['name'] === 'optgroup') { |
| 2652 | 2652 | /* If the current node is an option element, act as if an end tag |
| 2653 | 2653 | with the tag name "option" had been seen. */ |
| 2654 | - if(end($this->stack)->tagName === 'option') { |
|
| 2654 | + if (end($this->stack)->tagName === 'option') { |
|
| 2655 | 2655 | $this->emitToken(array( |
| 2656 | 2656 | 'name' => 'option', |
| 2657 | 2657 | 'type' => HTML5_Tokenizer::ENDTAG |
@@ -2660,7 +2660,7 @@ discard block |
||
| 2660 | 2660 | |
| 2661 | 2661 | /* If the current node is an optgroup element, act as if an end tag |
| 2662 | 2662 | with the tag name "optgroup" had been seen. */ |
| 2663 | - if(end($this->stack)->tagName === 'optgroup') { |
|
| 2663 | + if (end($this->stack)->tagName === 'optgroup') { |
|
| 2664 | 2664 | $this->emitToken(array( |
| 2665 | 2665 | 'name' => 'optgroup', |
| 2666 | 2666 | 'type' => HTML5_Tokenizer::ENDTAG |
@@ -2671,7 +2671,7 @@ discard block |
||
| 2671 | 2671 | $this->insertElement($token); |
| 2672 | 2672 | |
| 2673 | 2673 | /* An end tag token whose tag name is "optgroup" */ |
| 2674 | - } elseif($token['type'] === HTML5_Tokenizer::ENDTAG && |
|
| 2674 | + } elseif ($token['type'] === HTML5_Tokenizer::ENDTAG && |
|
| 2675 | 2675 | $token['name'] === 'optgroup') { |
| 2676 | 2676 | /* First, if the current node is an option element, and the node |
| 2677 | 2677 | immediately before it in the stack of open elements is an optgroup |
@@ -2679,7 +2679,7 @@ discard block |
||
| 2679 | 2679 | been seen. */ |
| 2680 | 2680 | $elements_in_stack = count($this->stack); |
| 2681 | 2681 | |
| 2682 | - if($this->stack[$elements_in_stack - 1]->tagName === 'option' && |
|
| 2682 | + if ($this->stack[$elements_in_stack - 1]->tagName === 'option' && |
|
| 2683 | 2683 | $this->stack[$elements_in_stack - 2]->tagName === 'optgroup') { |
| 2684 | 2684 | $this->emitToken(array( |
| 2685 | 2685 | 'name' => 'option', |
@@ -2690,7 +2690,7 @@ discard block |
||
| 2690 | 2690 | /* If the current node is an optgroup element, then pop that node |
| 2691 | 2691 | from the stack of open elements. Otherwise, this is a parse error, |
| 2692 | 2692 | ignore the token. */ |
| 2693 | - if(end($this->stack)->tagName === 'optgroup') { |
|
| 2693 | + if (end($this->stack)->tagName === 'optgroup') { |
|
| 2694 | 2694 | array_pop($this->stack); |
| 2695 | 2695 | } else { |
| 2696 | 2696 | // parse error |
@@ -2698,12 +2698,12 @@ discard block |
||
| 2698 | 2698 | } |
| 2699 | 2699 | |
| 2700 | 2700 | /* An end tag token whose tag name is "option" */ |
| 2701 | - } elseif($token['type'] === HTML5_Tokenizer::ENDTAG && |
|
| 2701 | + } elseif ($token['type'] === HTML5_Tokenizer::ENDTAG && |
|
| 2702 | 2702 | $token['name'] === 'option') { |
| 2703 | 2703 | /* If the current node is an option element, then pop that node |
| 2704 | 2704 | from the stack of open elements. Otherwise, this is a parse error, |
| 2705 | 2705 | ignore the token. */ |
| 2706 | - if(end($this->stack)->tagName === 'option') { |
|
| 2706 | + if (end($this->stack)->tagName === 'option') { |
|
| 2707 | 2707 | array_pop($this->stack); |
| 2708 | 2708 | } else { |
| 2709 | 2709 | // parse error |
@@ -2711,12 +2711,12 @@ discard block |
||
| 2711 | 2711 | } |
| 2712 | 2712 | |
| 2713 | 2713 | /* An end tag whose tag name is "select" */ |
| 2714 | - } elseif($token['type'] === HTML5_Tokenizer::ENDTAG && |
|
| 2714 | + } elseif ($token['type'] === HTML5_Tokenizer::ENDTAG && |
|
| 2715 | 2715 | $token['name'] === 'select') { |
| 2716 | 2716 | /* If the stack of open elements does not have an element in table |
| 2717 | 2717 | scope with the same tag name as the token, this is a parse error. |
| 2718 | 2718 | Ignore the token. (fragment case) */ |
| 2719 | - if(!$this->elementInScope($token['name'], self::SCOPE_TABLE)) { |
|
| 2719 | + if (!$this->elementInScope($token['name'], self::SCOPE_TABLE)) { |
|
| 2720 | 2720 | $this->ignored = true; |
| 2721 | 2721 | // parse error |
| 2722 | 2722 | |
@@ -2733,7 +2733,7 @@ discard block |
||
| 2733 | 2733 | } |
| 2734 | 2734 | |
| 2735 | 2735 | /* A start tag whose tag name is "select" */ |
| 2736 | - } elseif($token['type'] === HTML5_Tokenizer::STARTTAG && $token['name'] === 'select') { |
|
| 2736 | + } elseif ($token['type'] === HTML5_Tokenizer::STARTTAG && $token['name'] === 'select') { |
|
| 2737 | 2737 | /* Parse error. Act as if the token had been an end tag with the |
| 2738 | 2738 | tag name "select" instead. */ |
| 2739 | 2739 | $this->emitToken(array( |
@@ -2741,8 +2741,8 @@ discard block |
||
| 2741 | 2741 | 'type' => HTML5_Tokenizer::ENDTAG |
| 2742 | 2742 | )); |
| 2743 | 2743 | |
| 2744 | - } elseif($token['type'] === HTML5_Tokenizer::STARTTAG && |
|
| 2745 | - ($token['name'] === 'input' || $token['name'] === 'keygen' || $token['name'] === 'textarea')) { |
|
| 2744 | + } elseif ($token['type'] === HTML5_Tokenizer::STARTTAG && |
|
| 2745 | + ($token['name'] === 'input' || $token['name'] === 'keygen' || $token['name'] === 'textarea')) { |
|
| 2746 | 2746 | // parse error |
| 2747 | 2747 | $this->emitToken(array( |
| 2748 | 2748 | 'name' => 'select', |
@@ -2750,10 +2750,10 @@ discard block |
||
| 2750 | 2750 | )); |
| 2751 | 2751 | $this->emitToken($token); |
| 2752 | 2752 | |
| 2753 | - } elseif($token['type'] === HTML5_Tokenizer::STARTTAG && $token['name'] === 'script') { |
|
| 2753 | + } elseif ($token['type'] === HTML5_Tokenizer::STARTTAG && $token['name'] === 'script') { |
|
| 2754 | 2754 | $this->processWithRulesFor($token, self::IN_HEAD); |
| 2755 | 2755 | |
| 2756 | - } elseif($token['type'] === HTML5_Tokenizer::EOF) { |
|
| 2756 | + } elseif ($token['type'] === HTML5_Tokenizer::EOF) { |
|
| 2757 | 2757 | // XERROR: If the current node is not the root html element, then this is a parse error. |
| 2758 | 2758 | /* Stop parsing */ |
| 2759 | 2759 | |
@@ -2766,7 +2766,7 @@ discard block |
||
| 2766 | 2766 | |
| 2767 | 2767 | case self::IN_SELECT_IN_TABLE: |
| 2768 | 2768 | |
| 2769 | - if($token['type'] === HTML5_Tokenizer::STARTTAG && |
|
| 2769 | + if ($token['type'] === HTML5_Tokenizer::STARTTAG && |
|
| 2770 | 2770 | in_array($token['name'], array('caption', 'table', 'tbody', |
| 2771 | 2771 | 'tfoot', 'thead', 'tr', 'td', 'th'))) { |
| 2772 | 2772 | // parse error |
@@ -2778,8 +2778,8 @@ discard block |
||
| 2778 | 2778 | |
| 2779 | 2779 | /* An end tag whose tag name is one of: "caption", "table", "tbody", |
| 2780 | 2780 | "tfoot", "thead", "tr", "td", "th" */ |
| 2781 | - } elseif($token['type'] === HTML5_Tokenizer::ENDTAG && |
|
| 2782 | - in_array($token['name'], array('caption', 'table', 'tbody', 'tfoot', 'thead', 'tr', 'td', 'th'))) { |
|
| 2781 | + } elseif ($token['type'] === HTML5_Tokenizer::ENDTAG && |
|
| 2782 | + in_array($token['name'], array('caption', 'table', 'tbody', 'tfoot', 'thead', 'tr', 'td', 'th'))) { |
|
| 2783 | 2783 | /* Parse error. */ |
| 2784 | 2784 | // parse error |
| 2785 | 2785 | |
@@ -2787,7 +2787,7 @@ discard block |
||
| 2787 | 2787 | the same tag name as that of the token, then act as if an end tag |
| 2788 | 2788 | with the tag name "select" had been seen, and reprocess the token. |
| 2789 | 2789 | Otherwise, ignore the token. */ |
| 2790 | - if($this->elementInScope($token['name'], self::SCOPE_TABLE)) { |
|
| 2790 | + if ($this->elementInScope($token['name'], self::SCOPE_TABLE)) { |
|
| 2791 | 2791 | $this->emitToken(array( |
| 2792 | 2792 | 'name' => 'select', |
| 2793 | 2793 | 'type' => HTML5_Tokenizer::ENDTAG |
@@ -2872,8 +2872,8 @@ discard block |
||
| 2872 | 2872 | (in_array($token['name'], array('b', "big", "blockquote", "body", "br", |
| 2873 | 2873 | "center", "code", "dc", "dd", "div", "dl", "ds", "dt", "em", "embed", "h1", "h2", |
| 2874 | 2874 | "h3", "h4", "h5", "h6", "head", "hr", "i", "img", "li", "listing", |
| 2875 | - "menu", "meta", "nobr", "ol", "p", "pre", "ruby", "s", "small", |
|
| 2876 | - "span", "strong", "strike", "sub", "sup", "table", "tt", "u", "ul", |
|
| 2875 | + "menu", "meta", "nobr", "ol", "p", "pre", "ruby", "s", "small", |
|
| 2876 | + "span", "strong", "strike", "sub", "sup", "table", "tt", "u", "ul", |
|
| 2877 | 2877 | "var")) || ($token['name'] === 'font' && ($this->getAttr($token, 'color') || |
| 2878 | 2878 | $this->getAttr($token, 'face') || $this->getAttr($token, 'size')))))) { |
| 2879 | 2879 | // XERROR: parse error |
@@ -2950,13 +2950,13 @@ discard block |
||
| 2950 | 2950 | /* A character token that is one of one of U+0009 CHARACTER TABULATION, |
| 2951 | 2951 | U+000A LINE FEED (LF), U+000B LINE TABULATION, U+000C FORM FEED (FF), |
| 2952 | 2952 | or U+0020 SPACE */ |
| 2953 | - if($token['type'] === HTML5_Tokenizer::SPACECHARACTER) { |
|
| 2953 | + if ($token['type'] === HTML5_Tokenizer::SPACECHARACTER) { |
|
| 2954 | 2954 | /* Process the token as it would be processed if the insertion mode |
| 2955 | 2955 | was "in body". */ |
| 2956 | 2956 | $this->processWithRulesFor($token, self::IN_BODY); |
| 2957 | 2957 | |
| 2958 | 2958 | /* A comment token */ |
| 2959 | - } elseif($token['type'] === HTML5_Tokenizer::COMMENT) { |
|
| 2959 | + } elseif ($token['type'] === HTML5_Tokenizer::COMMENT) { |
|
| 2960 | 2960 | /* Append a Comment node to the first element in the stack of open |
| 2961 | 2961 | elements (the html element), with the data attribute set to the |
| 2962 | 2962 | data given in the comment token. */ |
@@ -2964,14 +2964,14 @@ discard block |
||
| 2964 | 2964 | $comment = $this->dom->createComment($token['data']); |
| 2965 | 2965 | $this->stack[0]->appendChild($comment); |
| 2966 | 2966 | |
| 2967 | - } elseif($token['type'] === HTML5_Tokenizer::DOCTYPE) { |
|
| 2967 | + } elseif ($token['type'] === HTML5_Tokenizer::DOCTYPE) { |
|
| 2968 | 2968 | // parse error |
| 2969 | 2969 | |
| 2970 | - } elseif($token['type'] === HTML5_Tokenizer::STARTTAG && $token['name'] === 'html') { |
|
| 2970 | + } elseif ($token['type'] === HTML5_Tokenizer::STARTTAG && $token['name'] === 'html') { |
|
| 2971 | 2971 | $this->processWithRulesFor($token, self::IN_BODY); |
| 2972 | 2972 | |
| 2973 | 2973 | /* An end tag with the tag name "html" */ |
| 2974 | - } elseif($token['type'] === HTML5_Tokenizer::ENDTAG && $token['name'] === 'html') { |
|
| 2974 | + } elseif ($token['type'] === HTML5_Tokenizer::ENDTAG && $token['name'] === 'html') { |
|
| 2975 | 2975 | /* If the parser was originally created as part of the HTML |
| 2976 | 2976 | * fragment parsing algorithm, this is a parse error; ignore |
| 2977 | 2977 | * the token. (fragment case) */ |
@@ -2980,7 +2980,7 @@ discard block |
||
| 2980 | 2980 | |
| 2981 | 2981 | $this->mode = self::AFTER_AFTER_BODY; |
| 2982 | 2982 | |
| 2983 | - } elseif($token['type'] === HTML5_Tokenizer::EOF) { |
|
| 2983 | + } elseif ($token['type'] === HTML5_Tokenizer::EOF) { |
|
| 2984 | 2984 | /* Stop parsing */ |
| 2985 | 2985 | |
| 2986 | 2986 | /* Anything else */ |
@@ -2998,30 +2998,30 @@ discard block |
||
| 2998 | 2998 | /* A character token that is one of one of U+0009 CHARACTER TABULATION, |
| 2999 | 2999 | U+000A LINE FEED (LF), U+000B LINE TABULATION, U+000C FORM FEED (FF), |
| 3000 | 3000 | U+000D CARRIAGE RETURN (CR), or U+0020 SPACE */ |
| 3001 | - if($token['type'] === HTML5_Tokenizer::SPACECHARACTER) { |
|
| 3001 | + if ($token['type'] === HTML5_Tokenizer::SPACECHARACTER) { |
|
| 3002 | 3002 | /* Append the character to the current node. */ |
| 3003 | 3003 | $this->insertText($token['data']); |
| 3004 | 3004 | |
| 3005 | 3005 | /* A comment token */ |
| 3006 | - } elseif($token['type'] === HTML5_Tokenizer::COMMENT) { |
|
| 3006 | + } elseif ($token['type'] === HTML5_Tokenizer::COMMENT) { |
|
| 3007 | 3007 | /* Append a Comment node to the current node with the data |
| 3008 | 3008 | attribute set to the data given in the comment token. */ |
| 3009 | 3009 | $this->insertComment($token['data']); |
| 3010 | 3010 | |
| 3011 | - } elseif($token['type'] === HTML5_Tokenizer::DOCTYPE) { |
|
| 3011 | + } elseif ($token['type'] === HTML5_Tokenizer::DOCTYPE) { |
|
| 3012 | 3012 | // parse error |
| 3013 | 3013 | |
| 3014 | 3014 | /* A start tag with the tag name "frameset" */ |
| 3015 | - } elseif($token['type'] === HTML5_Tokenizer::STARTTAG && |
|
| 3015 | + } elseif ($token['type'] === HTML5_Tokenizer::STARTTAG && |
|
| 3016 | 3016 | $token['name'] === 'frameset') { |
| 3017 | 3017 | $this->insertElement($token); |
| 3018 | 3018 | |
| 3019 | 3019 | /* An end tag with the tag name "frameset" */ |
| 3020 | - } elseif($token['type'] === HTML5_Tokenizer::ENDTAG && |
|
| 3020 | + } elseif ($token['type'] === HTML5_Tokenizer::ENDTAG && |
|
| 3021 | 3021 | $token['name'] === 'frameset') { |
| 3022 | 3022 | /* If the current node is the root html element, then this is a |
| 3023 | 3023 | parse error; ignore the token. (fragment case) */ |
| 3024 | - if(end($this->stack)->tagName === 'html') { |
|
| 3024 | + if (end($this->stack)->tagName === 'html') { |
|
| 3025 | 3025 | $this->ignored = true; |
| 3026 | 3026 | // Parse error |
| 3027 | 3027 | |
@@ -3038,7 +3038,7 @@ discard block |
||
| 3038 | 3038 | } |
| 3039 | 3039 | |
| 3040 | 3040 | /* A start tag with the tag name "frame" */ |
| 3041 | - } elseif($token['type'] === HTML5_Tokenizer::STARTTAG && |
|
| 3041 | + } elseif ($token['type'] === HTML5_Tokenizer::STARTTAG && |
|
| 3042 | 3042 | $token['name'] === 'frame') { |
| 3043 | 3043 | /* Insert an HTML element for the token. */ |
| 3044 | 3044 | $this->insertElement($token); |
@@ -3049,12 +3049,12 @@ discard block |
||
| 3049 | 3049 | // XERROR: Acknowledge the token's self-closing flag, if it is set. |
| 3050 | 3050 | |
| 3051 | 3051 | /* A start tag with the tag name "noframes" */ |
| 3052 | - } elseif($token['type'] === HTML5_Tokenizer::STARTTAG && |
|
| 3052 | + } elseif ($token['type'] === HTML5_Tokenizer::STARTTAG && |
|
| 3053 | 3053 | $token['name'] === 'noframes') { |
| 3054 | 3054 | /* Process the token using the rules for the "in head" insertion mode. */ |
| 3055 | 3055 | $this->processwithRulesFor($token, self::IN_HEAD); |
| 3056 | 3056 | |
| 3057 | - } elseif($token['type'] === HTML5_Tokenizer::EOF) { |
|
| 3057 | + } elseif ($token['type'] === HTML5_Tokenizer::EOF) { |
|
| 3058 | 3058 | // XERROR: If the current node is not the root html element, then this is a parse error. |
| 3059 | 3059 | /* Stop parsing */ |
| 3060 | 3060 | /* Anything else */ |
@@ -3070,33 +3070,33 @@ discard block |
||
| 3070 | 3070 | /* A character token that is one of one of U+0009 CHARACTER TABULATION, |
| 3071 | 3071 | U+000A LINE FEED (LF), U+000B LINE TABULATION, U+000C FORM FEED (FF), |
| 3072 | 3072 | U+000D CARRIAGE RETURN (CR), or U+0020 SPACE */ |
| 3073 | - if($token['type'] === HTML5_Tokenizer::SPACECHARACTER) { |
|
| 3073 | + if ($token['type'] === HTML5_Tokenizer::SPACECHARACTER) { |
|
| 3074 | 3074 | /* Append the character to the current node. */ |
| 3075 | 3075 | $this->insertText($token['data']); |
| 3076 | 3076 | |
| 3077 | 3077 | /* A comment token */ |
| 3078 | - } elseif($token['type'] === HTML5_Tokenizer::COMMENT) { |
|
| 3078 | + } elseif ($token['type'] === HTML5_Tokenizer::COMMENT) { |
|
| 3079 | 3079 | /* Append a Comment node to the current node with the data |
| 3080 | 3080 | attribute set to the data given in the comment token. */ |
| 3081 | 3081 | $this->insertComment($token['data']); |
| 3082 | 3082 | |
| 3083 | - } elseif($token['type'] === HTML5_Tokenizer::DOCTYPE) { |
|
| 3083 | + } elseif ($token['type'] === HTML5_Tokenizer::DOCTYPE) { |
|
| 3084 | 3084 | // parse error |
| 3085 | 3085 | |
| 3086 | - } elseif($token['type'] === HTML5_Tokenizer::STARTTAG && $token['name'] === 'html') { |
|
| 3086 | + } elseif ($token['type'] === HTML5_Tokenizer::STARTTAG && $token['name'] === 'html') { |
|
| 3087 | 3087 | $this->processWithRulesFor($token, self::IN_BODY); |
| 3088 | 3088 | |
| 3089 | 3089 | /* An end tag with the tag name "html" */ |
| 3090 | - } elseif($token['type'] === HTML5_Tokenizer::ENDTAG && |
|
| 3090 | + } elseif ($token['type'] === HTML5_Tokenizer::ENDTAG && |
|
| 3091 | 3091 | $token['name'] === 'html') { |
| 3092 | 3092 | $this->mode = self::AFTER_AFTER_FRAMESET; |
| 3093 | 3093 | |
| 3094 | 3094 | /* A start tag with the tag name "noframes" */ |
| 3095 | - } elseif($token['type'] === HTML5_Tokenizer::STARTTAG && |
|
| 3095 | + } elseif ($token['type'] === HTML5_Tokenizer::STARTTAG && |
|
| 3096 | 3096 | $token['name'] === 'noframes') { |
| 3097 | 3097 | $this->processWithRulesFor($token, self::IN_HEAD); |
| 3098 | 3098 | |
| 3099 | - } elseif($token['type'] === HTML5_Tokenizer::EOF) { |
|
| 3099 | + } elseif ($token['type'] === HTML5_Tokenizer::EOF) { |
|
| 3100 | 3100 | /* Stop parsing */ |
| 3101 | 3101 | |
| 3102 | 3102 | /* Anything else */ |
@@ -3108,20 +3108,20 @@ discard block |
||
| 3108 | 3108 | |
| 3109 | 3109 | case self::AFTER_AFTER_BODY: |
| 3110 | 3110 | /* A comment token */ |
| 3111 | - if($token['type'] === HTML5_Tokenizer::COMMENT) { |
|
| 3111 | + if ($token['type'] === HTML5_Tokenizer::COMMENT) { |
|
| 3112 | 3112 | /* Append a Comment node to the Document object with the data |
| 3113 | 3113 | attribute set to the data given in the comment token. */ |
| 3114 | 3114 | // XDOM |
| 3115 | 3115 | $comment = $this->dom->createComment($token['data']); |
| 3116 | 3116 | $this->dom->appendChild($comment); |
| 3117 | 3117 | |
| 3118 | - } elseif($token['type'] === HTML5_Tokenizer::DOCTYPE || |
|
| 3118 | + } elseif ($token['type'] === HTML5_Tokenizer::DOCTYPE || |
|
| 3119 | 3119 | $token['type'] === HTML5_Tokenizer::SPACECHARACTER || |
| 3120 | 3120 | ($token['type'] === HTML5_Tokenizer::STARTTAG && $token['name'] === 'html')) { |
| 3121 | 3121 | $this->processWithRulesFor($token, self::IN_BODY); |
| 3122 | 3122 | |
| 3123 | 3123 | /* An end-of-file token */ |
| 3124 | - } elseif($token['type'] === HTML5_Tokenizer::EOF) { |
|
| 3124 | + } elseif ($token['type'] === HTML5_Tokenizer::EOF) { |
|
| 3125 | 3125 | /* OMG DONE!! */ |
| 3126 | 3126 | } else { |
| 3127 | 3127 | // parse error |
@@ -3132,22 +3132,22 @@ discard block |
||
| 3132 | 3132 | |
| 3133 | 3133 | case self::AFTER_AFTER_FRAMESET: |
| 3134 | 3134 | /* A comment token */ |
| 3135 | - if($token['type'] === HTML5_Tokenizer::COMMENT) { |
|
| 3135 | + if ($token['type'] === HTML5_Tokenizer::COMMENT) { |
|
| 3136 | 3136 | /* Append a Comment node to the Document object with the data |
| 3137 | 3137 | attribute set to the data given in the comment token. */ |
| 3138 | 3138 | // XDOM |
| 3139 | 3139 | $comment = $this->dom->createComment($token['data']); |
| 3140 | 3140 | $this->dom->appendChild($comment); |
| 3141 | 3141 | |
| 3142 | - } elseif($token['type'] === HTML5_Tokenizer::DOCTYPE || |
|
| 3142 | + } elseif ($token['type'] === HTML5_Tokenizer::DOCTYPE || |
|
| 3143 | 3143 | $token['type'] === HTML5_Tokenizer::SPACECHARACTER || |
| 3144 | 3144 | ($token['type'] === HTML5_Tokenizer::STARTTAG && $token['name'] === 'html')) { |
| 3145 | 3145 | $this->processWithRulesFor($token, self::IN_BODY); |
| 3146 | 3146 | |
| 3147 | 3147 | /* An end-of-file token */ |
| 3148 | - } elseif($token['type'] === HTML5_Tokenizer::EOF) { |
|
| 3148 | + } elseif ($token['type'] === HTML5_Tokenizer::EOF) { |
|
| 3149 | 3149 | /* OMG DONE!! */ |
| 3150 | - } elseif($token['type'] === HTML5_Tokenizer::STARTTAG && $token['name'] === 'nofrmaes') { |
|
| 3150 | + } elseif ($token['type'] === HTML5_Tokenizer::STARTTAG && $token['name'] === 'nofrmaes') { |
|
| 3151 | 3151 | $this->processWithRulesFor($token, self::IN_HEAD); |
| 3152 | 3152 | } else { |
| 3153 | 3153 | // parse error |
@@ -3161,8 +3161,8 @@ discard block |
||
| 3161 | 3161 | $el = $this->dom->createElementNS(self::NS_HTML, $token['name']); |
| 3162 | 3162 | |
| 3163 | 3163 | if (!empty($token['attr'])) { |
| 3164 | - foreach($token['attr'] as $attr) { |
|
| 3165 | - if(!$el->hasAttribute($attr['name'])) { |
|
| 3164 | + foreach ($token['attr'] as $attr) { |
|
| 3165 | + if (!$el->hasAttribute($attr['name'])) { |
|
| 3166 | 3166 | $el->setAttribute($attr['name'], $attr['value']); |
| 3167 | 3167 | } |
| 3168 | 3168 | } |
@@ -3197,7 +3197,7 @@ discard block |
||
| 3197 | 3197 | /* If the current node is a table, tbody, tfoot, thead, or tr |
| 3198 | 3198 | element, then, whenever a node would be inserted into the current |
| 3199 | 3199 | node, it must instead be inserted into the foster parent element. */ |
| 3200 | - if(!$this->foster_parent || !in_array(end($this->stack)->tagName, |
|
| 3200 | + if (!$this->foster_parent || !in_array(end($this->stack)->tagName, |
|
| 3201 | 3201 | array('table', 'tbody', 'tfoot', 'thead', 'tr'))) { |
| 3202 | 3202 | end($this->stack)->appendChild($node); |
| 3203 | 3203 | } else { |
@@ -3206,9 +3206,9 @@ discard block |
||
| 3206 | 3206 | } |
| 3207 | 3207 | |
| 3208 | 3208 | private function elementInScope($el, $scope = self::SCOPE) { |
| 3209 | - if(is_array($el)) { |
|
| 3210 | - foreach($el as $element) { |
|
| 3211 | - if($this->elementInScope($element, $scope)) { |
|
| 3209 | + if (is_array($el)) { |
|
| 3210 | + foreach ($el as $element) { |
|
| 3211 | + if ($this->elementInScope($element, $scope)) { |
|
| 3212 | 3212 | return true; |
| 3213 | 3213 | } |
| 3214 | 3214 | } |
@@ -3218,12 +3218,12 @@ discard block |
||
| 3218 | 3218 | |
| 3219 | 3219 | $leng = count($this->stack); |
| 3220 | 3220 | |
| 3221 | - for($n = 0; $n < $leng; $n++) { |
|
| 3221 | + for ($n = 0; $n < $leng; $n++) { |
|
| 3222 | 3222 | /* 1. Initialise node to be the current node (the bottommost node of |
| 3223 | 3223 | the stack). */ |
| 3224 | 3224 | $node = $this->stack[$leng - 1 - $n]; |
| 3225 | 3225 | |
| 3226 | - if($node->tagName === $el) { |
|
| 3226 | + if ($node->tagName === $el) { |
|
| 3227 | 3227 | /* 2. If node is the target node, terminate in a match state. */ |
| 3228 | 3228 | return true; |
| 3229 | 3229 | |
@@ -3232,11 +3232,11 @@ discard block |
||
| 3232 | 3232 | // this "gets the job done" |
| 3233 | 3233 | |
| 3234 | 3234 | // these are the common states for all scopes |
| 3235 | - } elseif($node->tagName === 'table' || $node->tagName === 'html') { |
|
| 3235 | + } elseif ($node->tagName === 'table' || $node->tagName === 'html') { |
|
| 3236 | 3236 | return false; |
| 3237 | 3237 | |
| 3238 | 3238 | // these are valid for "in scope" and "in list item scope" |
| 3239 | - } elseif($scope !== self::SCOPE_TABLE && |
|
| 3239 | + } elseif ($scope !== self::SCOPE_TABLE && |
|
| 3240 | 3240 | (in_array($node->tagName, array('applet', 'caption', 'td', |
| 3241 | 3241 | 'th', 'button', 'marquee', 'object')) || |
| 3242 | 3242 | $node->tagName === 'foreignObject' && $node->namespaceURI === self::NS_SVG)) { |
@@ -3244,7 +3244,7 @@ discard block |
||
| 3244 | 3244 | |
| 3245 | 3245 | |
| 3246 | 3246 | // these are valid for "in list item scope" |
| 3247 | - } elseif($scope === self::SCOPE_LISTITEM && in_array($node->tagName, array('ol', 'ul'))) { |
|
| 3247 | + } elseif ($scope === self::SCOPE_LISTITEM && in_array($node->tagName, array('ol', 'ul'))) { |
|
| 3248 | 3248 | return false; |
| 3249 | 3249 | } |
| 3250 | 3250 | |
@@ -3260,7 +3260,7 @@ discard block |
||
| 3260 | 3260 | then there is nothing to reconstruct; stop this algorithm. */ |
| 3261 | 3261 | $formatting_elements = count($this->a_formatting); |
| 3262 | 3262 | |
| 3263 | - if($formatting_elements === 0) { |
|
| 3263 | + if ($formatting_elements === 0) { |
|
| 3264 | 3264 | return false; |
| 3265 | 3265 | } |
| 3266 | 3266 | |
@@ -3272,14 +3272,14 @@ discard block |
||
| 3272 | 3272 | formatting elements is a marker, or if it is an element that is in the |
| 3273 | 3273 | stack of open elements, then there is nothing to reconstruct; stop this |
| 3274 | 3274 | algorithm. */ |
| 3275 | - if($entry === self::MARKER || in_array($entry, $this->stack, true)) { |
|
| 3275 | + if ($entry === self::MARKER || in_array($entry, $this->stack, true)) { |
|
| 3276 | 3276 | return false; |
| 3277 | 3277 | } |
| 3278 | 3278 | |
| 3279 | - for($a = $formatting_elements - 1; $a >= 0; true) { |
|
| 3279 | + for ($a = $formatting_elements - 1; $a >= 0; true) { |
|
| 3280 | 3280 | /* 4. If there are no entries before entry in the list of active |
| 3281 | 3281 | formatting elements, then jump to step 8. */ |
| 3282 | - if($a === 0) { |
|
| 3282 | + if ($a === 0) { |
|
| 3283 | 3283 | $step_seven = false; |
| 3284 | 3284 | break; |
| 3285 | 3285 | } |
@@ -3291,15 +3291,15 @@ discard block |
||
| 3291 | 3291 | |
| 3292 | 3292 | /* 6. If entry is neither a marker nor an element that is also in |
| 3293 | 3293 | thetack of open elements, go to step 4. */ |
| 3294 | - if($entry === self::MARKER || in_array($entry, $this->stack, true)) { |
|
| 3294 | + if ($entry === self::MARKER || in_array($entry, $this->stack, true)) { |
|
| 3295 | 3295 | break; |
| 3296 | 3296 | } |
| 3297 | 3297 | } |
| 3298 | 3298 | |
| 3299 | - while(true) { |
|
| 3299 | + while (true) { |
|
| 3300 | 3300 | /* 7. Let entry be the element one later than entry in the list of |
| 3301 | 3301 | active formatting elements. */ |
| 3302 | - if(isset($step_seven) && $step_seven === true) { |
|
| 3302 | + if (isset($step_seven) && $step_seven === true) { |
|
| 3303 | 3303 | $a++; |
| 3304 | 3304 | $entry = $this->a_formatting[$a]; |
| 3305 | 3305 | } |
@@ -3318,7 +3318,7 @@ discard block |
||
| 3318 | 3318 | |
| 3319 | 3319 | /* 11. If the entry for clone in the list of active formatting |
| 3320 | 3320 | elements is not the last entry in the list, return to step 7. */ |
| 3321 | - if(end($this->a_formatting) !== $clone) { |
|
| 3321 | + if (end($this->a_formatting) !== $clone) { |
|
| 3322 | 3322 | $step_seven = true; |
| 3323 | 3323 | } else { |
| 3324 | 3324 | break; |
@@ -3331,7 +3331,7 @@ discard block |
||
| 3331 | 3331 | formatting elements up to the last marker, the UA must perform the |
| 3332 | 3332 | following steps: */ |
| 3333 | 3333 | |
| 3334 | - while(true) { |
|
| 3334 | + while (true) { |
|
| 3335 | 3335 | /* 1. Let entry be the last (most recently added) entry in the list |
| 3336 | 3336 | of active formatting elements. */ |
| 3337 | 3337 | $entry = end($this->a_formatting); |
@@ -3341,7 +3341,7 @@ discard block |
||
| 3341 | 3341 | |
| 3342 | 3342 | /* 3. If entry was a marker, then stop the algorithm at this point. |
| 3343 | 3343 | The list has been cleared up to the last marker. */ |
| 3344 | - if($entry === self::MARKER) { |
|
| 3344 | + if ($entry === self::MARKER) { |
|
| 3345 | 3345 | break; |
| 3346 | 3346 | } |
| 3347 | 3347 | } |
@@ -3356,7 +3356,7 @@ discard block |
||
| 3356 | 3356 | $node = end($this->stack); |
| 3357 | 3357 | $elements = array_diff(array('dc', 'dd', 'ds', 'dt', 'li', 'p', 'td', 'th', 'tr'), $exclude); |
| 3358 | 3358 | |
| 3359 | - while(in_array(end($this->stack)->tagName, $elements)) { |
|
| 3359 | + while (in_array(end($this->stack)->tagName, $elements)) { |
|
| 3360 | 3360 | array_pop($this->stack); |
| 3361 | 3361 | } |
| 3362 | 3362 | } |
@@ -3364,13 +3364,13 @@ discard block |
||
| 3364 | 3364 | private function getElementCategory($node) { |
| 3365 | 3365 | if (!is_object($node)) debug_print_backtrace(); |
| 3366 | 3366 | $name = $node->tagName; |
| 3367 | - if(in_array($name, $this->special)) |
|
| 3367 | + if (in_array($name, $this->special)) |
|
| 3368 | 3368 | return self::SPECIAL; |
| 3369 | 3369 | |
| 3370 | - elseif(in_array($name, $this->scoping)) |
|
| 3370 | + elseif (in_array($name, $this->scoping)) |
|
| 3371 | 3371 | return self::SCOPING; |
| 3372 | 3372 | |
| 3373 | - elseif(in_array($name, $this->formatting)) |
|
| 3373 | + elseif (in_array($name, $this->formatting)) |
|
| 3374 | 3374 | return self::FORMATTING; |
| 3375 | 3375 | |
| 3376 | 3376 | else |
@@ -3382,10 +3382,10 @@ discard block |
||
| 3382 | 3382 | table context, it means that the UA must, while the current node is not |
| 3383 | 3383 | a table element or an html element, pop elements from the stack of open |
| 3384 | 3384 | elements. */ |
| 3385 | - while(true) { |
|
| 3385 | + while (true) { |
|
| 3386 | 3386 | $name = end($this->stack)->tagName; |
| 3387 | 3387 | |
| 3388 | - if(in_array($name, $elements)) { |
|
| 3388 | + if (in_array($name, $elements)) { |
|
| 3389 | 3389 | break; |
| 3390 | 3390 | } else { |
| 3391 | 3391 | array_pop($this->stack); |
@@ -3398,57 +3398,57 @@ discard block |
||
| 3398 | 3398 | $last = false; |
| 3399 | 3399 | $leng = count($this->stack); |
| 3400 | 3400 | |
| 3401 | - for($n = $leng - 1; $n >= 0; $n--) { |
|
| 3401 | + for ($n = $leng - 1; $n >= 0; $n--) { |
|
| 3402 | 3402 | /* 2. Let node be the last node in the stack of open elements. */ |
| 3403 | 3403 | $node = $this->stack[$n]; |
| 3404 | 3404 | |
| 3405 | 3405 | /* 3. If node is the first node in the stack of open elements, then |
| 3406 | 3406 | * set last to true and set node to the context element. (fragment |
| 3407 | 3407 | * case) */ |
| 3408 | - if($this->stack[0]->isSameNode($node)) { |
|
| 3408 | + if ($this->stack[0]->isSameNode($node)) { |
|
| 3409 | 3409 | $last = true; |
| 3410 | 3410 | $node = $this->context; |
| 3411 | 3411 | } |
| 3412 | 3412 | |
| 3413 | 3413 | /* 4. If node is a select element, then switch the insertion mode to |
| 3414 | 3414 | "in select" and abort these steps. (fragment case) */ |
| 3415 | - if($node->tagName === 'select') { |
|
| 3415 | + if ($node->tagName === 'select') { |
|
| 3416 | 3416 | $this->mode = self::IN_SELECT; |
| 3417 | 3417 | break; |
| 3418 | 3418 | |
| 3419 | 3419 | /* 5. If node is a td or th element, then switch the insertion mode |
| 3420 | 3420 | to "in cell" and abort these steps. */ |
| 3421 | - } elseif($node->tagName === 'td' || $node->nodeName === 'th') { |
|
| 3421 | + } elseif ($node->tagName === 'td' || $node->nodeName === 'th') { |
|
| 3422 | 3422 | $this->mode = self::IN_CELL; |
| 3423 | 3423 | break; |
| 3424 | 3424 | |
| 3425 | 3425 | /* 6. If node is a tr element, then switch the insertion mode to |
| 3426 | 3426 | "in row" and abort these steps. */ |
| 3427 | - } elseif($node->tagName === 'tr') { |
|
| 3427 | + } elseif ($node->tagName === 'tr') { |
|
| 3428 | 3428 | $this->mode = self::IN_ROW; |
| 3429 | 3429 | break; |
| 3430 | 3430 | |
| 3431 | 3431 | /* 7. If node is a tbody, thead, or tfoot element, then switch the |
| 3432 | 3432 | insertion mode to "in table body" and abort these steps. */ |
| 3433 | - } elseif(in_array($node->tagName, array('tbody', 'thead', 'tfoot'))) { |
|
| 3433 | + } elseif (in_array($node->tagName, array('tbody', 'thead', 'tfoot'))) { |
|
| 3434 | 3434 | $this->mode = self::IN_TABLE_BODY; |
| 3435 | 3435 | break; |
| 3436 | 3436 | |
| 3437 | 3437 | /* 8. If node is a caption element, then switch the insertion mode |
| 3438 | 3438 | to "in caption" and abort these steps. */ |
| 3439 | - } elseif($node->tagName === 'caption') { |
|
| 3439 | + } elseif ($node->tagName === 'caption') { |
|
| 3440 | 3440 | $this->mode = self::IN_CAPTION; |
| 3441 | 3441 | break; |
| 3442 | 3442 | |
| 3443 | 3443 | /* 9. If node is a colgroup element, then switch the insertion mode |
| 3444 | 3444 | to "in column group" and abort these steps. (innerHTML case) */ |
| 3445 | - } elseif($node->tagName === 'colgroup') { |
|
| 3445 | + } elseif ($node->tagName === 'colgroup') { |
|
| 3446 | 3446 | $this->mode = self::IN_COLUMN_GROUP; |
| 3447 | 3447 | break; |
| 3448 | 3448 | |
| 3449 | 3449 | /* 10. If node is a table element, then switch the insertion mode |
| 3450 | 3450 | to "in table" and abort these steps. */ |
| 3451 | - } elseif($node->tagName === 'table') { |
|
| 3451 | + } elseif ($node->tagName === 'table') { |
|
| 3452 | 3452 | $this->mode = self::IN_TABLE; |
| 3453 | 3453 | break; |
| 3454 | 3454 | |
@@ -3456,7 +3456,7 @@ discard block |
||
| 3456 | 3456 | * namespace, then switch the insertion mode to "in foreign |
| 3457 | 3457 | * content", let the secondary insertion mode be "in body", and |
| 3458 | 3458 | * abort these steps. */ |
| 3459 | - } elseif($node->namespaceURI === self::NS_SVG || |
|
| 3459 | + } elseif ($node->namespaceURI === self::NS_SVG || |
|
| 3460 | 3460 | $node->namespaceURI === self::NS_MATHML) { |
| 3461 | 3461 | $this->mode = self::IN_FOREIGN_CONTENT; |
| 3462 | 3462 | $this->secondary_mode = self::IN_BODY; |
@@ -3465,19 +3465,19 @@ discard block |
||
| 3465 | 3465 | /* 12. If node is a head element, then switch the insertion mode |
| 3466 | 3466 | to "in body" ("in body"! not "in head"!) and abort these steps. |
| 3467 | 3467 | (fragment case) */ |
| 3468 | - } elseif($node->tagName === 'head') { |
|
| 3468 | + } elseif ($node->tagName === 'head') { |
|
| 3469 | 3469 | $this->mode = self::IN_BODY; |
| 3470 | 3470 | break; |
| 3471 | 3471 | |
| 3472 | 3472 | /* 13. If node is a body element, then switch the insertion mode to |
| 3473 | 3473 | "in body" and abort these steps. */ |
| 3474 | - } elseif($node->tagName === 'body') { |
|
| 3474 | + } elseif ($node->tagName === 'body') { |
|
| 3475 | 3475 | $this->mode = self::IN_BODY; |
| 3476 | 3476 | break; |
| 3477 | 3477 | |
| 3478 | 3478 | /* 14. If node is a frameset element, then switch the insertion |
| 3479 | 3479 | mode to "in frameset" and abort these steps. (fragment case) */ |
| 3480 | - } elseif($node->tagName === 'frameset') { |
|
| 3480 | + } elseif ($node->tagName === 'frameset') { |
|
| 3481 | 3481 | $this->mode = self::IN_FRAMESET; |
| 3482 | 3482 | break; |
| 3483 | 3483 | |
@@ -3485,7 +3485,7 @@ discard block |
||
| 3485 | 3485 | pointer is null, switch the insertion mode to "before head", |
| 3486 | 3486 | otherwise, switch the insertion mode to "after head". In either |
| 3487 | 3487 | case, abort these steps. (fragment case) */ |
| 3488 | - } elseif($node->tagName === 'html') { |
|
| 3488 | + } elseif ($node->tagName === 'html') { |
|
| 3489 | 3489 | $this->mode = ($this->head_pointer === null) |
| 3490 | 3490 | ? self::BEFORE_HEAD |
| 3491 | 3491 | : self::AFTER_HEAD; |
@@ -3494,7 +3494,7 @@ discard block |
||
| 3494 | 3494 | |
| 3495 | 3495 | /* 16. If last is true, then set the insertion mode to "in body" |
| 3496 | 3496 | and abort these steps. (fragment case) */ |
| 3497 | - } elseif($last) { |
|
| 3497 | + } elseif ($last) { |
|
| 3498 | 3498 | $this->mode = self::IN_BODY; |
| 3499 | 3499 | break; |
| 3500 | 3500 | } |
@@ -3504,8 +3504,8 @@ discard block |
||
| 3504 | 3504 | private function closeCell() { |
| 3505 | 3505 | /* If the stack of open elements has a td or th element in table scope, |
| 3506 | 3506 | then act as if an end tag token with that tag name had been seen. */ |
| 3507 | - foreach(array('td', 'th') as $cell) { |
|
| 3508 | - if($this->elementInScope($cell, self::SCOPE_TABLE)) { |
|
| 3507 | + foreach (array('td', 'th') as $cell) { |
|
| 3508 | + if ($this->elementInScope($cell, self::SCOPE_TABLE)) { |
|
| 3509 | 3509 | $this->emitToken(array( |
| 3510 | 3510 | 'name' => $cell, |
| 3511 | 3511 | 'type' => HTML5_Tokenizer::ENDTAG |
@@ -3573,20 +3573,20 @@ discard block |
||
| 3573 | 3573 | its parent node is not an element, then the foster parent |
| 3574 | 3574 | element is the element before the last table element in the |
| 3575 | 3575 | stack of open elements. */ |
| 3576 | - for($n = count($this->stack) - 1; $n >= 0; $n--) { |
|
| 3577 | - if($this->stack[$n]->tagName === 'table') { |
|
| 3576 | + for ($n = count($this->stack) - 1; $n >= 0; $n--) { |
|
| 3577 | + if ($this->stack[$n]->tagName === 'table') { |
|
| 3578 | 3578 | $table = $this->stack[$n]; |
| 3579 | 3579 | break; |
| 3580 | 3580 | } |
| 3581 | 3581 | } |
| 3582 | 3582 | |
| 3583 | - if(isset($table) && $table->parentNode !== null) { |
|
| 3583 | + if (isset($table) && $table->parentNode !== null) { |
|
| 3584 | 3584 | return $table->parentNode; |
| 3585 | 3585 | |
| 3586 | - } elseif(!isset($table)) { |
|
| 3586 | + } elseif (!isset($table)) { |
|
| 3587 | 3587 | return $this->stack[0]; |
| 3588 | 3588 | |
| 3589 | - } elseif(isset($table) && ($table->parentNode === null || |
|
| 3589 | + } elseif (isset($table) && ($table->parentNode === null || |
|
| 3590 | 3590 | $table->parentNode->nodeType !== XML_ELEMENT_NODE)) { |
| 3591 | 3591 | return $this->stack[$n - 1]; |
| 3592 | 3592 | } |
@@ -3805,7 +3805,7 @@ discard block |
||
| 3805 | 3805 | if (!$el->hasAttributeNS($ns, $attr)) { |
| 3806 | 3806 | // XSKETCHY: work around godawful libxml bug |
| 3807 | 3807 | if ($ns === self::NS_XLINK) { |
| 3808 | - $el->setAttribute('xlink:'.$attr, $kp['value']); |
|
| 3808 | + $el->setAttribute('xlink:' . $attr, $kp['value']); |
|
| 3809 | 3809 | } elseif ($ns === self::NS_HTML) { |
| 3810 | 3810 | // Another godawful libxml bug |
| 3811 | 3811 | $el->setAttribute($attr, $kp['value']); |
@@ -112,7 +112,9 @@ discard block |
||
| 112 | 112 | $r = new ReflectionClass('HTML5_TreeBuilder'); |
| 113 | 113 | $consts = $r->getConstants(); |
| 114 | 114 | foreach ($consts as $const => $num) { |
| 115 | - if (!is_int($num)) continue; |
|
| 115 | + if (!is_int($num)) { |
|
| 116 | + continue; |
|
| 117 | + } |
|
| 116 | 118 | $lookup[$num] = $const; |
| 117 | 119 | } |
| 118 | 120 | } |
@@ -159,8 +161,12 @@ discard block |
||
| 159 | 161 | // Process tag tokens |
| 160 | 162 | public function emitToken($token, $mode = null) { |
| 161 | 163 | // XXX: ignore parse errors... why are we emitting them, again? |
| 162 | - if ($token['type'] === HTML5_Tokenizer::PARSEERROR) return; |
|
| 163 | - if ($mode === null) $mode = $this->mode; |
|
| 164 | + if ($token['type'] === HTML5_Tokenizer::PARSEERROR) { |
|
| 165 | + return; |
|
| 166 | + } |
|
| 167 | + if ($mode === null) { |
|
| 168 | + $mode = $this->mode; |
|
| 169 | + } |
|
| 164 | 170 | |
| 165 | 171 | /* |
| 166 | 172 | $backtrace = debug_backtrace(); |
@@ -175,7 +181,9 @@ discard block |
||
| 175 | 181 | if ($this->flag_frameset_ok) echo " -> frameset ok\n"; |
| 176 | 182 | */ |
| 177 | 183 | |
| 178 | - if ($this->ignore_lf_token) $this->ignore_lf_token--; |
|
| 184 | + if ($this->ignore_lf_token) { |
|
| 185 | + $this->ignore_lf_token--; |
|
| 186 | + } |
|
| 179 | 187 | $this->ignored = false; |
| 180 | 188 | // indenting is a little wonky, this can be changed later on |
| 181 | 189 | switch ($mode) { |
@@ -212,8 +220,12 @@ discard block |
||
| 212 | 220 | * appropriate. Associate the DocumentType node with the |
| 213 | 221 | * Document object so that it is returned as the value of the |
| 214 | 222 | * doctype attribute of the Document object. */ |
| 215 | - if (!isset($token['public'])) $token['public'] = null; |
|
| 216 | - if (!isset($token['system'])) $token['system'] = null; |
|
| 223 | + if (!isset($token['public'])) { |
|
| 224 | + $token['public'] = null; |
|
| 225 | + } |
|
| 226 | + if (!isset($token['system'])) { |
|
| 227 | + $token['system'] = null; |
|
| 228 | + } |
|
| 217 | 229 | // XDOM |
| 218 | 230 | // Yes this is hacky. I'm kind of annoyed that I can't appendChild |
| 219 | 231 | // a doctype to DOMDocument. Maybe I haven't chanted the right |
@@ -318,14 +330,18 @@ discard block |
||
| 318 | 330 | break; |
| 319 | 331 | } |
| 320 | 332 | } |
| 321 | - if (!is_null($this->quirks_mode)) break; |
|
| 333 | + if (!is_null($this->quirks_mode)) { |
|
| 334 | + break; |
|
| 335 | + } |
|
| 322 | 336 | foreach ($publicStartsWithAndSystemForLimitedQuirks as $x) { |
| 323 | 337 | if (strncmp($public, $x, strlen($x)) === 0) { |
| 324 | 338 | $this->quirks_mode = self::LIMITED_QUIRKS_MODE; |
| 325 | 339 | break; |
| 326 | 340 | } |
| 327 | 341 | } |
| 328 | - if (!is_null($this->quirks_mode)) break; |
|
| 342 | + if (!is_null($this->quirks_mode)) { |
|
| 343 | + break; |
|
| 344 | + } |
|
| 329 | 345 | } |
| 330 | 346 | foreach ($publicSetToForQuirks as $x) { |
| 331 | 347 | if ($public === $x) { |
@@ -333,13 +349,17 @@ discard block |
||
| 333 | 349 | break; |
| 334 | 350 | } |
| 335 | 351 | } |
| 336 | - if (!is_null($this->quirks_mode)) break; |
|
| 352 | + if (!is_null($this->quirks_mode)) { |
|
| 353 | + break; |
|
| 354 | + } |
|
| 337 | 355 | foreach ($publicStartsWithForLimitedQuirks as $x) { |
| 338 | 356 | if (strncmp($public, $x, strlen($x)) === 0) { |
| 339 | 357 | $this->quirks_mode = self::LIMITED_QUIRKS_MODE; |
| 340 | 358 | } |
| 341 | 359 | } |
| 342 | - if (!is_null($this->quirks_mode)) break; |
|
| 360 | + if (!is_null($this->quirks_mode)) { |
|
| 361 | + break; |
|
| 362 | + } |
|
| 343 | 363 | if ($system === "http://www.ibm.com/data/dtd/v11/ibmxhtml1-transitional.dtd") { |
| 344 | 364 | $this->quirks_mode = self::QUIRKS_MODE; |
| 345 | 365 | break; |
@@ -1031,11 +1051,15 @@ discard block |
||
| 1031 | 1051 | )); |
| 1032 | 1052 | if (in_array($a, $this->a_formatting)) { |
| 1033 | 1053 | $a_i = array_search($a, $this->a_formatting, true); |
| 1034 | - if($a_i !== false) array_splice($this->a_formatting, $a_i, 1); |
|
| 1054 | + if($a_i !== false) { |
|
| 1055 | + array_splice($this->a_formatting, $a_i, 1); |
|
| 1056 | + } |
|
| 1035 | 1057 | } |
| 1036 | 1058 | if (in_array($a, $this->stack)) { |
| 1037 | 1059 | $a_i = array_search($a, $this->stack, true); |
| 1038 | - if ($a_i !== false) array_splice($this->stack, $a_i, 1); |
|
| 1060 | + if ($a_i !== false) { |
|
| 1061 | + array_splice($this->stack, $a_i, 1); |
|
| 1062 | + } |
|
| 1039 | 1063 | } |
| 1040 | 1064 | break; |
| 1041 | 1065 | } |
@@ -1274,7 +1298,9 @@ discard block |
||
| 1274 | 1298 | $attr = array(); |
| 1275 | 1299 | foreach ($token['attr'] as $keypair) { |
| 1276 | 1300 | if ($keypair['name'] === 'name' || $keypair['name'] === 'action' || |
| 1277 | - $keypair['name'] === 'prompt') continue; |
|
| 1301 | + $keypair['name'] === 'prompt') { |
|
| 1302 | + continue; |
|
| 1303 | + } |
|
| 1278 | 1304 | $attr[] = $keypair; |
| 1279 | 1305 | } |
| 1280 | 1306 | $attr[] = array('name' => 'name', 'value' => 'isindex'); |
@@ -1502,7 +1528,9 @@ discard block |
||
| 1502 | 1528 | 'type' => HTML5_Tokenizer::ENDTAG |
| 1503 | 1529 | )); |
| 1504 | 1530 | |
| 1505 | - if (!$this->ignored) $this->emitToken($token); |
|
| 1531 | + if (!$this->ignored) { |
|
| 1532 | + $this->emitToken($token); |
|
| 1533 | + } |
|
| 1506 | 1534 | break; |
| 1507 | 1535 | |
| 1508 | 1536 | case 'address': case 'article': case 'aside': case 'blockquote': |
@@ -2100,7 +2128,9 @@ discard block |
||
| 2100 | 2128 | 'type' => HTML5_Tokenizer::ENDTAG |
| 2101 | 2129 | )); |
| 2102 | 2130 | |
| 2103 | - if (!$this->ignored) $this->emitToken($token); |
|
| 2131 | + if (!$this->ignored) { |
|
| 2132 | + $this->emitToken($token); |
|
| 2133 | + } |
|
| 2104 | 2134 | |
| 2105 | 2135 | /* An end tag whose tag name is "table" */ |
| 2106 | 2136 | } elseif($token['type'] === HTML5_Tokenizer::ENDTAG && |
@@ -2262,7 +2292,9 @@ discard block |
||
| 2262 | 2292 | 'type' => HTML5_Tokenizer::ENDTAG |
| 2263 | 2293 | )); |
| 2264 | 2294 | |
| 2265 | - if (!$this->ignored) $this->emitToken($token); |
|
| 2295 | + if (!$this->ignored) { |
|
| 2296 | + $this->emitToken($token); |
|
| 2297 | + } |
|
| 2266 | 2298 | |
| 2267 | 2299 | /* An end tag whose tag name is one of: "body", "col", "colgroup", |
| 2268 | 2300 | "html", "tbody", "td", "tfoot", "th", "thead", "tr" */ |
@@ -2342,7 +2374,9 @@ discard block |
||
| 2342 | 2374 | 'type' => HTML5_Tokenizer::ENDTAG |
| 2343 | 2375 | )); |
| 2344 | 2376 | |
| 2345 | - if (!$this->ignored) $this->emitToken($token); |
|
| 2377 | + if (!$this->ignored) { |
|
| 2378 | + $this->emitToken($token); |
|
| 2379 | + } |
|
| 2346 | 2380 | } |
| 2347 | 2381 | break; |
| 2348 | 2382 | |
@@ -2485,7 +2519,9 @@ discard block |
||
| 2485 | 2519 | 'name' => 'tr', |
| 2486 | 2520 | 'type' => HTML5_Tokenizer::ENDTAG |
| 2487 | 2521 | )); |
| 2488 | - if (!$this->ignored) $this->emitToken($token); |
|
| 2522 | + if (!$this->ignored) { |
|
| 2523 | + $this->emitToken($token); |
|
| 2524 | + } |
|
| 2489 | 2525 | |
| 2490 | 2526 | /* An end tag whose tag name is one of: "tbody", "tfoot", "thead" */ |
| 2491 | 2527 | } elseif($token['type'] === HTML5_Tokenizer::ENDTAG && |
@@ -3176,11 +3212,15 @@ discard block |
||
| 3176 | 3212 | } |
| 3177 | 3213 | |
| 3178 | 3214 | private function insertText($data) { |
| 3179 | - if ($data === '') return; |
|
| 3215 | + if ($data === '') { |
|
| 3216 | + return; |
|
| 3217 | + } |
|
| 3180 | 3218 | if ($this->ignore_lf_token) { |
| 3181 | 3219 | if ($data[0] === "\n") { |
| 3182 | 3220 | $data = substr($data, 1); |
| 3183 | - if ($data === false) return; |
|
| 3221 | + if ($data === false) { |
|
| 3222 | + return; |
|
| 3223 | + } |
|
| 3184 | 3224 | } |
| 3185 | 3225 | } |
| 3186 | 3226 | $text = $this->dom->createTextNode($data); |
@@ -3362,19 +3402,19 @@ discard block |
||
| 3362 | 3402 | } |
| 3363 | 3403 | |
| 3364 | 3404 | private function getElementCategory($node) { |
| 3365 | - if (!is_object($node)) debug_print_backtrace(); |
|
| 3405 | + if (!is_object($node)) { |
|
| 3406 | + debug_print_backtrace(); |
|
| 3407 | + } |
|
| 3366 | 3408 | $name = $node->tagName; |
| 3367 | - if(in_array($name, $this->special)) |
|
| 3368 | - return self::SPECIAL; |
|
| 3369 | - |
|
| 3370 | - elseif(in_array($name, $this->scoping)) |
|
| 3371 | - return self::SCOPING; |
|
| 3372 | - |
|
| 3373 | - elseif(in_array($name, $this->formatting)) |
|
| 3374 | - return self::FORMATTING; |
|
| 3375 | - |
|
| 3376 | - else |
|
| 3377 | - return self::PHRASING; |
|
| 3409 | + if(in_array($name, $this->special)) { |
|
| 3410 | + return self::SPECIAL; |
|
| 3411 | + } elseif(in_array($name, $this->scoping)) { |
|
| 3412 | + return self::SCOPING; |
|
| 3413 | + } elseif(in_array($name, $this->formatting)) { |
|
| 3414 | + return self::FORMATTING; |
|
| 3415 | + } else { |
|
| 3416 | + return self::PHRASING; |
|
| 3417 | + } |
|
| 3378 | 3418 | } |
| 3379 | 3419 | |
| 3380 | 3420 | private function clearStackToTableContext($elements) { |
@@ -3540,10 +3580,14 @@ discard block |
||
| 3540 | 3580 | } |
| 3541 | 3581 | |
| 3542 | 3582 | private function getAttr($token, $key) { |
| 3543 | - if (!isset($token['attr'])) return false; |
|
| 3583 | + if (!isset($token['attr'])) { |
|
| 3584 | + return false; |
|
| 3585 | + } |
|
| 3544 | 3586 | $ret = false; |
| 3545 | 3587 | foreach ($token['attr'] as $keypair) { |
| 3546 | - if ($keypair['name'] === $key) $ret = $keypair['value']; |
|
| 3588 | + if ($keypair['name'] === $key) { |
|
| 3589 | + $ret = $keypair['value']; |
|
| 3590 | + } |
|
| 3547 | 3591 | } |
| 3548 | 3592 | return $ret; |
| 3549 | 3593 | } |
@@ -3624,11 +3668,16 @@ discard block |
||
| 3624 | 3668 | * For debugging, prints active formatting elements |
| 3625 | 3669 | */ |
| 3626 | 3670 | private function printActiveFormattingElements() { |
| 3627 | - if (!$this->a_formatting) return; |
|
| 3671 | + if (!$this->a_formatting) { |
|
| 3672 | + return; |
|
| 3673 | + } |
|
| 3628 | 3674 | $names = array(); |
| 3629 | 3675 | foreach ($this->a_formatting as $node) { |
| 3630 | - if ($node === self::MARKER) $names[] = 'MARKER'; |
|
| 3631 | - else $names[] = $node->tagName; |
|
| 3676 | + if ($node === self::MARKER) { |
|
| 3677 | + $names[] = 'MARKER'; |
|
| 3678 | + } else { |
|
| 3679 | + $names[] = $node->tagName; |
|
| 3680 | + } |
|
| 3632 | 3681 | } |
| 3633 | 3682 | echo " -> active formatting [" . implode(', ', $names) . "]\n"; |
| 3634 | 3683 | } |
@@ -4,12 +4,12 @@ discard block |
||
| 4 | 4 | { |
| 5 | 5 | public function setContent($content) |
| 6 | 6 | { |
| 7 | - require_once(HTML5LIB_PATH.'/HTML5/Parser.php'); |
|
| 7 | + require_once(HTML5LIB_PATH . '/HTML5/Parser.php'); |
|
| 8 | 8 | |
| 9 | 9 | // Convert any errors to exceptions |
| 10 | 10 | set_error_handler( |
| 11 | - function ($no, $str) { |
|
| 12 | - throw new Exception("HTML Parse Error: ".$str); |
|
| 11 | + function($no, $str) { |
|
| 12 | + throw new Exception("HTML Parse Error: " . $str); |
|
| 13 | 13 | }, |
| 14 | 14 | error_reporting() |
| 15 | 15 | ); |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | // Use HTML5lib to parse the HTML fragment |
| 18 | 18 | try { |
| 19 | 19 | $document = HTML5_Parser::parse( |
| 20 | - '<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head>'. |
|
| 20 | + '<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head>' . |
|
| 21 | 21 | "<body>$content</body></html>" |
| 22 | 22 | ); |
| 23 | 23 | } catch (Exception $e) { |