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