3 namespace RemexHtml\Tokenizer;
6 * The handler which converts events to tokens arrays for TokenGenerator
8 class TokenGeneratorHandler implements TokenHandler {
11 public function startDocument( Tokenizer $tokenizer, $fragmentNamespace, $fragmentName ) {
13 'type' => 'startDocument',
14 'fragmentNamespace' => $fragmentNamespace,
15 'fragmentName' => $fragmentName
19 public function endDocument( $pos ) {
20 $this->tokens[] = [ 'type' => 'endDocument' ];
23 public function error( $text, $pos ) {
31 public function characters( $text, $start, $length, $sourceStart, $sourceLength ) {
37 'sourceStart' => $sourceStart,
38 'sourceLength' => $sourceLength ];
41 public function startTag( $name, Attributes $attrs, $selfClose, $sourceStart, $sourceLength ) {
46 'selfClose' => $selfClose,
47 'sourceStart' => $sourceStart,
48 'sourceLength' => $sourceLength ];
51 public function endTag( $name, $sourceStart, $sourceLength ) {
55 'sourceStart' => $sourceStart,
56 'sourceLength' => $sourceLength ];
59 public function doctype( $name, $public, $system, $quirks, $sourceStart, $sourceLength ) {
65 'quirks' => $quirks ];
68 public function comment( $text, $sourceStart, $sourceLength ) {
72 'sourceStart' => $sourceStart,
73 'sourceLength' => $sourceLength ];