Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 18 |
|
0.00% |
0 / 6 |
CRAP | |
0.00% |
0 / 1 |
| InPre | |
0.00% |
0 / 18 |
|
0.00% |
0 / 6 |
90 | |
0.00% |
0 / 1 |
| characters | |
0.00% |
0 / 8 |
|
0.00% |
0 / 1 |
20 | |||
| endDocument | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
| startTag | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
| endTag | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
| doctype | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
| comment | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | declare( strict_types = 1 ); |
| 3 | |
| 4 | namespace Wikimedia\RemexHtml\TreeBuilder; |
| 5 | |
| 6 | use Wikimedia\RemexHtml\Tokenizer\Attributes; |
| 7 | |
| 8 | /** |
| 9 | * This is not a tree builder state in the spec. I added it to handle the |
| 10 | * "next token" references in pre/listing. The specified mode for parsing the |
| 11 | * pre/listing is saved before entering this mode. This mode checks if the |
| 12 | * first token is a newline, and then switches to the correct mode regardless. |
| 13 | */ |
| 14 | class InPre extends InsertionMode { |
| 15 | /** @inheritDoc */ |
| 16 | public function characters( $text, $start, $length, $sourceStart, $sourceLength ) { |
| 17 | if ( $length > 0 && $text[$start] === "\n" ) { |
| 18 | $start++; |
| 19 | $length--; |
| 20 | $sourceStart++; |
| 21 | $sourceLength--; |
| 22 | } |
| 23 | $mode = $this->dispatcher->restoreMode(); |
| 24 | if ( $length ) { |
| 25 | $mode->characters( $text, $start, $length, $sourceStart, $sourceLength ); |
| 26 | } |
| 27 | } |
| 28 | |
| 29 | /** @inheritDoc */ |
| 30 | public function endDocument( $pos ) { |
| 31 | $this->dispatcher->restoreMode() |
| 32 | ->endDocument( $pos ); |
| 33 | } |
| 34 | |
| 35 | /** @inheritDoc */ |
| 36 | public function startTag( $name, Attributes $attrs, $selfClose, $sourceStart, $sourceLength ) { |
| 37 | $this->dispatcher->restoreMode() |
| 38 | ->startTag( $name, $attrs, $selfClose, $sourceStart, $sourceLength ); |
| 39 | } |
| 40 | |
| 41 | /** @inheritDoc */ |
| 42 | public function endTag( $name, $sourceStart, $sourceLength ) { |
| 43 | $this->dispatcher->restoreMode() |
| 44 | ->endTag( $name, $sourceStart, $sourceLength ); |
| 45 | } |
| 46 | |
| 47 | /** @inheritDoc */ |
| 48 | public function doctype( $name, $public, $system, $quirks, $sourceStart, $sourceLength ) { |
| 49 | $this->dispatcher->restoreMode() |
| 50 | ->doctype( $name, $public, $system, $quirks, $sourceStart, $sourceLength ); |
| 51 | } |
| 52 | |
| 53 | /** @inheritDoc */ |
| 54 | public function comment( $text, $sourceStart, $sourceLength ) { |
| 55 | $this->dispatcher->restoreMode() |
| 56 | ->comment( $text, $sourceStart, $sourceLength ); |
| 57 | } |
| 58 | } |