| 1 |
<?php |
| 2 |
|
| 3 |
namespace Wikimedia\RemexHtml\TreeBuilder; |
| 4 |
|
| 5 |
use Wikimedia\RemexHtml\Tokenizer\Attributes; |
| 6 |
|
| 7 |
/** |
| 8 |
* The "text" insertion mode |
| 9 |
*/ |
| 10 |
class Text extends InsertionMode { |
| 11 |
/** @inheritDoc */ |
| 12 |
public function characters( $text, $start, $length, $sourceStart, $sourceLength ) { |
| 13 |
$this->builder->insertCharacters( $text, $start, $length, $sourceStart, $sourceLength ); |
| 14 |
} |
| 15 |
|
| 16 |
/** @inheritDoc */ |
| 17 |
public function endDocument( $pos ) { |
| 18 |
$this->builder->error( 'unexpected end of input in text mode', $pos ); |
| 19 |
$this->builder->pop( $pos, 0 ); |
| 20 |
$this->dispatcher->restoreMode() |
| 21 |
->endDocument( $pos ); |
| 22 |
} |
| 23 |
|
| 24 |
/** @inheritDoc */ |
| 25 |
public function startTag( $name, Attributes $attrs, $selfClose, $sourceStart, $sourceLength ) { |
| 26 |
// @phan-suppress-previous-line PhanPluginNeverReturnMethod |
| 27 |
throw new TreeBuilderError( 'unexpected token' ); |
| 28 |
} |
| 29 |
|
| 30 |
/** @inheritDoc */ |
| 31 |
public function endTag( $name, $sourceStart, $sourceLength ) { |
| 32 |
// I think this is complete if we have no support for executing scripts |
| 33 |
$this->builder->pop( $sourceStart, $sourceLength ); |
| 34 |
$this->dispatcher->restoreMode(); |
| 35 |
} |
| 36 |
} |