RemexHtml
Fast HTML 5 parser
Loading...
Searching...
No Matches
Wikimedia\RemexHtml\Tokenizer\TokenGenerator Class Reference

This class provides a convenient iterative view of the token stream, implemented as a Generator. More...

Static Public Member Functions

static Generator generate ( $text, $options)
 Get a Generator which iterates over all tokens in the supplied HTML.
 

Protected Member Functions

 __construct ( $text, $options)
 

Protected Attributes

TokenGeneratorHandler $handler
 
Tokenizer $tokenizer
 

Detailed Description

This class provides a convenient iterative view of the token stream, implemented as a Generator.

It is intended to be used as follows:

foreach ( TokenGenerator::generate( $html, [] ) as $token ) { ... }

Performance is slightly slower than a plain TokenHandler, probably due to the need to convert event parameters to associative arrays.

Constructor & Destructor Documentation

◆ __construct()

Wikimedia\RemexHtml\Tokenizer\TokenGenerator::__construct ( $text,
$options )
protected
Parameters
string$text
array$optionsOptions passed through to Tokenizer

Member Function Documentation

◆ generate()

static Generator Wikimedia\RemexHtml\Tokenizer\TokenGenerator::generate ( $text,
$options )
static

Get a Generator which iterates over all tokens in the supplied HTML.

Parameters
string$textThe HTML
array$optionsThe Tokenizer options, see Tokenizer::__construct()
Returns
\Generator

Member Data Documentation

◆ $handler

TokenGeneratorHandler Wikimedia\RemexHtml\Tokenizer\TokenGenerator::$handler
protected

◆ $tokenizer

Tokenizer Wikimedia\RemexHtml\Tokenizer\TokenGenerator::$tokenizer
protected

The documentation for this class was generated from the following file: