Parsoid
A bidirectional parser between wikitext and HTML5
Loading...
Searching...
No Matches
Wikimedia\Parsoid\Wt2Html\TokenTransformManager Class Reference

Token transformation manager. More...

+ Inheritance diagram for Wikimedia\Parsoid\Wt2Html\TokenTransformManager:
+ Collaboration diagram for Wikimedia\Parsoid\Wt2Html\TokenTransformManager:

Public Member Functions

 __construct (Env $env, array $options, string $stageId, ?PipelineStage $prevStage=null)
 
 setPipelineId (int $id)
 
 getFrame ()
 
 getOptions ()
 
 addTransformer (TokenHandler $t)
 Register a token transformer.
Parameters
TokenHandler$t

 
 shuttleTokensToEndOfStage (array $toks)
 
 processChunk (array $tokens)
 Push the tokens through all the registered transformers.
 
 resetState (array $opts)
 Resets any internal state for this pipeline stage.This is usually called so a cached pipeline can be reused.
Parameters
array$options

 
 process ( $tokens, array $opts)
 See PipelineStage::process docs as well.
 
 processChunkily ( $input, array $opts)
 Process wikitext, an array of tokens, or a DOM document depending on what pipeline stage this is.This method will either directly or indirectly implement a generator that parses the input in chunks and yields output in chunks as well.Implementations that don't consume tokens (ex: Tokenizer, DOMPostProcessor) will provide specialized implementations that handle their input type.
Parameters
string | array | Document$input
array{sol:bool}$options
  • atTopLevel: (bool) Whether we are processing the top-level document
  • sol: (bool) Whether input should be processed in start-of-line context
Returns
Generator

 
- Public Member Functions inherited from Wikimedia\Parsoid\Wt2Html\PipelineStage
 __construct (Env $env, ?PipelineStage $prevStage=null)
 
 getPipelineId ()
 
 getEnv ()
 
 setFrame (Frame $frame)
 Set frame on this pipeline stage.
 
 setSourceOffsets (SourceRange $so)
 Set the source offsets for the content being processing by this pipeline This matters for when a substring of the top-level page is being processed in its own pipeline.
 

Public Attributes

 $tokenTimes = 0
 
 $profile
 

Additional Inherited Members

- Protected Attributes inherited from Wikimedia\Parsoid\Wt2Html\PipelineStage
 $prevStage
 
 $pipelineId = -1
 
 $env = null
 
bool $atTopLevel = false
 Defaults to false and resetState initializes it.
 
bool $toFragment = true
 
 $frame
 

Detailed Description

Token transformation manager.

Individual transformations implement the TokenHandler interface. The parser pipeline registers individual transformers.

See https://www.mediawiki.org/wiki/Parsoid/Token_stream_transformations for more documentation. This abstract class could eventually be eliminated and the various token transforms just extend PipelineStage directly.

Member Function Documentation

◆ addTransformer()

Wikimedia\Parsoid\Wt2Html\TokenTransformManager::addTransformer ( TokenHandler $t)

Register a token transformer.

Parameters
TokenHandler$t

Reimplemented from Wikimedia\Parsoid\Wt2Html\PipelineStage.

◆ process()

Wikimedia\Parsoid\Wt2Html\TokenTransformManager::process ( $tokens,
array $opts )

See PipelineStage::process docs as well.

This doc block refines the generic arg types to be specific to this pipeline stage.

Process a chunk of tokens.

Parameters
array$tokensArray of tokens to process
array$opts
Returns
array Returns the array of processed tokens

Reimplemented from Wikimedia\Parsoid\Wt2Html\PipelineStage.

◆ processChunk()

Wikimedia\Parsoid\Wt2Html\TokenTransformManager::processChunk ( array $tokens)

Push the tokens through all the registered transformers.

◆ processChunkily()

Wikimedia\Parsoid\Wt2Html\TokenTransformManager::processChunkily ( $input,
array $opts )

Process wikitext, an array of tokens, or a DOM document depending on what pipeline stage this is.This method will either directly or indirectly implement a generator that parses the input in chunks and yields output in chunks as well.Implementations that don't consume tokens (ex: Tokenizer, DOMPostProcessor) will provide specialized implementations that handle their input type.

Parameters
string | array | Document$input
array{sol:bool}$options
  • atTopLevel: (bool) Whether we are processing the top-level document
  • sol: (bool) Whether input should be processed in start-of-line context
Returns
Generator

Reimplemented from Wikimedia\Parsoid\Wt2Html\PipelineStage.

◆ resetState()

Wikimedia\Parsoid\Wt2Html\TokenTransformManager::resetState ( array $opts)

Resets any internal state for this pipeline stage.This is usually called so a cached pipeline can be reused.

Parameters
array$options

Reimplemented from Wikimedia\Parsoid\Wt2Html\PipelineStage.

◆ setPipelineId()

Wikimedia\Parsoid\Wt2Html\TokenTransformManager::setPipelineId ( int $id)

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