3 namespace RemexHtml\TreeBuilder;
4 use RemexHtml\Tokenizer\Attributes;
7 * This is not a tree builder state in the spec. I added it to handle the
8 * "next token" references in textarea. If the first token is a newline, it is
9 * ignored. Then we switch the dispatcher to the "text" mode regardless, which
10 * is the correct mode for parsing textarea elements.
12 class InTextarea extends InsertionMode {
13 public function characters( $text, $start, $length, $sourceStart, $sourceLength ) {
14 if ( $length > 0 && $text[$start] === "\n" ) {
15 // Ignore initial line break
21 $mode = $this->dispatcher->switchMode( Dispatcher::TEXT );
23 $mode->characters( $text, $start, $length, $sourceStart, $sourceLength );
27 public function endDocument( $pos ) {
28 $this->dispatcher->switchMode( Dispatcher::TEXT )
29 ->endDocument( $pos );
32 public function startTag( $name, Attributes $attrs, $selfClose, $sourceStart, $sourceLength ) {
33 $this->dispatcher->switchMode( Dispatcher::TEXT )
34 ->startTag( $name, $attrs, $selfClose, $sourceStart, $sourceLength );
37 public function endTag( $name, $sourceStart, $sourceLength ) {
38 $this->dispatcher->switchMode( Dispatcher::TEXT )
39 ->endTag( $name, $sourceStart, $sourceLength );
42 public function doctype( $name, $public, $system, $quirks, $sourceStart, $sourceLength ) {
43 $this->dispatcher->switchMode( Dispatcher::TEXT )
44 ->doctype( $name, $public, $system, $quirks, $sourceStart, $sourceLength );
47 public function comment( $text, $sourceStart, $sourceLength ) {
48 $this->dispatcher->switchMode( Dispatcher::TEXT )
49 ->comment( $text, $sourceStart, $sourceLength );