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

Simple noinclude / onlyinclude implementation. More...

+ Inheritance diagram for Wikimedia\Parsoid\Wt2Html\TT\IncludeOnly:
+ Collaboration diagram for Wikimedia\Parsoid\Wt2Html\TT\IncludeOnly:

Public Member Functions

 __construct (TokenTransformManager $manager, array $options)
 
- Public Member Functions inherited from Wikimedia\Parsoid\Wt2Html\TT\TokenCollector
 onTag (Token $token)
 This handler is called for tokens that are not EOFTk or NLTk tokens.The handler may choose to process only specific kinds of tokens. For example, a list handler may only process 'listitem' TagTk tokens.
Parameters
Token$tokenToken to be processed
Returns
TokenHandlerResult|null A TokenHandlerResult, or null to efficiently indicate that the input token is unchanged.

 
 onEnd (EOFTk $token)
 This handler is called for EOF tokens only.
Parameters
EOFTk$tokenEOF token to be processed
Returns
TokenHandlerResult|null A TokenHandlerResult, or null to efficiently indicate that the input token is unchanged.

 
 onAny ( $token)
 This handler is called for all tokens in the token stream except if (a) The more specific handlers above modified the token (b) the more specific handlers (onTag, onEnd, onNewline) have set the skip flag in their return values.(c) this handlers 'active' flag is set to false (can be set by any of the handlers).
Parameters
Token | string$tokenToken to be processed
Returns
TokenHandlerResult|null A TokenHandlerResult, or null to efficiently indicate that the input token is unchanged.

 
- Public Member Functions inherited from Wikimedia\Parsoid\Wt2Html\TT\TokenHandler
 setPipelineId (int $id)
 
 resetState (array $options)
 Resets any internal state for this token handler.
 
 isDisabled ()
 Is this transformer disabled?
 
 onNewline (NlTk $token)
 This handler is called for newline tokens only.
 
 process ( $tokens)
 Push an input array of tokens through the transformer and return the transformed tokens.
 

Protected Member Functions

 type ()
 Token type to register for ('tag', 'text' etc)
 
 name ()
 (optional, only for token type 'tag'): tag name.
 
 toEnd ()
 Match the 'end' tokens as closing tag as well (accept unclosed sections).
 
 ackEnd ()
 Whether to transform unmatched end tags.
 
 transformation (array $collection)
 When an end delimiter is found, this function is called with the collected token array including the start and end delimiters.
 

Additional Inherited Members

- Static Public Member Functions inherited from Wikimedia\Parsoid\Wt2Html\TT\TokenCollector
static buildMetaToken (TokenTransformManager $manager, string $tokenName, bool $isEnd, SourceRange $tsr, ?string $src)
 This helper function will build a meta token in the right way for these tags.
 
- Static Protected Member Functions inherited from Wikimedia\Parsoid\Wt2Html\TT\TokenCollector
static buildStrippedMetaToken (TokenTransformManager $manager, string $tokenName, Token $startDelim, ?Token $endDelim)
 
- Protected Attributes inherited from Wikimedia\Parsoid\Wt2Html\TT\TokenCollector
array $scopeStack = []
 
- Protected Attributes inherited from Wikimedia\Parsoid\Wt2Html\TT\TokenHandler
 $env
 
 $manager
 
 $pipelineId
 
 $options
 
bool $disabled = false
 This is set if the token handler is disabled for the entire pipeline.
 
bool $onAnyEnabled = true
 This is set/reset by the token handlers at various points in the token stream based on what is encountered.
 
 $atTopLevel = false
 

Detailed Description

Simple noinclude / onlyinclude implementation.

Strips all tokens in noinclude sections.

Constructor & Destructor Documentation

◆ __construct()

Wikimedia\Parsoid\Wt2Html\TT\IncludeOnly::__construct ( TokenTransformManager  $manager,
array  $options 
)
Parameters
TokenTransformManager$managermanager enviroment
array$optionsvarious configuration options

Reimplemented from Wikimedia\Parsoid\Wt2Html\TT\TokenCollector.

Member Function Documentation

◆ ackEnd()

Wikimedia\Parsoid\Wt2Html\TT\IncludeOnly::ackEnd ( )
protected

Whether to transform unmatched end tags.

If this returns true, unbalanced end tags will be passed to transform(). If it returns false, they will be left in the token stream unmodified.

Returns
bool

Reimplemented from Wikimedia\Parsoid\Wt2Html\TT\TokenCollector.

◆ name()

Wikimedia\Parsoid\Wt2Html\TT\IncludeOnly::name ( )
protected

(optional, only for token type 'tag'): tag name.

Returns
string

Reimplemented from Wikimedia\Parsoid\Wt2Html\TT\TokenCollector.

◆ toEnd()

Wikimedia\Parsoid\Wt2Html\TT\IncludeOnly::toEnd ( )
protected

Match the 'end' tokens as closing tag as well (accept unclosed sections).

Returns
bool

Reimplemented from Wikimedia\Parsoid\Wt2Html\TT\TokenCollector.

◆ transformation()

Wikimedia\Parsoid\Wt2Html\TT\IncludeOnly::transformation ( array  $array)
protected

When an end delimiter is found, this function is called with the collected token array including the start and end delimiters.

The subclass should transform it and return the result.

Parameters
array$array
Returns
TokenHandlerResult

Reimplemented from Wikimedia\Parsoid\Wt2Html\TT\TokenCollector.

◆ type()

Wikimedia\Parsoid\Wt2Html\TT\IncludeOnly::type ( )
protected

Token type to register for ('tag', 'text' etc)

Returns
string

Reimplemented from Wikimedia\Parsoid\Wt2Html\TT\TokenCollector.


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