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

This represents the abstract interface for a wt2html parsing pipeline stage Currently there are 4 known pipeline stages: More...

+ Inheritance diagram for Wikimedia\Parsoid\Wt2Html\PipelineStage:

Public Member Functions

 __construct (Env $env, ?PipelineStage $prevStage=null)
 
 setPipelineId (int $id)
 
 getPipelineId ()
 
 getEnv ()
 
 addTransformer (TokenHandler $t)
 Register a token transformer.
 
 resetState (array $options)
 Resets any internal state for this pipeline stage.
 
 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.
 
 process ( $input, ?array $options=null)
 Process wikitext, an array of tokens, or a DOM document depending on what pipeline stage this is.
 
 processChunkily ( $input, ?array $options)
 Process wikitext, an array of tokens, or a DOM document depending on what pipeline stage this is.
 

Protected Attributes

 $prevStage
 
 $pipelineId = -1
 
 $env = null
 
bool $atTopLevel = false
 Defaults to false and resetState initializes it.
 
 $frame
 

Detailed Description

This represents the abstract interface for a wt2html parsing pipeline stage Currently there are 4 known pipeline stages:

  • PEG Tokenizer
  • Token Transform Manager
  • HTML5 Tree Builder
  • DOM Post Processor

The Token Transform Manager could eventually go away and be directly replaced by the very many token transformers that are represented by the abstract TokenHandler class.

Member Function Documentation

◆ addTransformer()

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

Register a token transformer.

Parameters
TokenHandler$t

Reimplemented in Wikimedia\Parsoid\Wt2Html\TokenTransformManager.

◆ process()

Wikimedia\Parsoid\Wt2Html\PipelineStage::process ( $input,
?array $options = null )
abstract

Process wikitext, an array of tokens, or a DOM document depending on what pipeline stage this is.

This will be entirety of the input that will be processed by this pipeline stage and no further input or an EOF signal will follow.

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

Reimplemented in Wikimedia\Parsoid\Wt2Html\PegTokenizer, and Wikimedia\Parsoid\Wt2Html\TokenTransformManager.

◆ processChunkily()

Wikimedia\Parsoid\Wt2Html\PipelineStage::processChunkily ( $input,
?array $options )
abstract

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$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 in Wikimedia\Parsoid\Wt2Html\DOMPostProcessor, and Wikimedia\Parsoid\Wt2Html\PegTokenizer.

◆ resetState()

Wikimedia\Parsoid\Wt2Html\PipelineStage::resetState ( array $options)

Resets any internal state for this pipeline stage.

This is usually called so a cached pipeline can be reused.

Parameters
array$options

Reimplemented in Wikimedia\Parsoid\Wt2Html\DOMPostProcessor, Wikimedia\Parsoid\Wt2Html\TreeBuilder\TreeBuilderStage, Wikimedia\Parsoid\Wt2Html\PegTokenizer, and Wikimedia\Parsoid\Wt2Html\TokenTransformManager.

◆ setFrame()

Wikimedia\Parsoid\Wt2Html\PipelineStage::setFrame ( Frame $frame)

Set frame on this pipeline stage.

Parameters
Frame$framePipeline frame

◆ setSourceOffsets()

Wikimedia\Parsoid\Wt2Html\PipelineStage::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.

This ensures that all source offsets assigned to tokens and DOM nodes in this stage are relative to the top-level page.

Parameters
SourceRange$so

Reimplemented in Wikimedia\Parsoid\Wt2Html\DOMPostProcessor, and Wikimedia\Parsoid\Wt2Html\PegTokenizer.


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