Parsoid
A bidirectional parser between wikitext and HTML5
|
Small utility class that encapsulates the common 'collect all tokens starting from a token of type x until token of type y or (optionally) the end-of-input'. More...
Public Member Functions | ||||
__construct (TokenTransformManager $manager, array $options) | ||||
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.
| ||||
onEnd (EOFTk $token) | ||||
This handler is called for EOF tokens only.
| ||||
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).
| ||||
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. | ||||
Static Public Member Functions | |
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. | |
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 $array) | |
When an end delimiter is found, this function is called with the collected token array including the start and end delimiters. | |
Static Protected Member Functions | |
static | buildStrippedMetaToken (TokenTransformManager $manager, string $tokenName, Token $startDelim, ?Token $endDelim) |
Protected Attributes | |
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 | |
Small utility class that encapsulates the common 'collect all tokens starting from a token of type x until token of type y or (optionally) the end-of-input'.
Wikimedia\Parsoid\Wt2Html\TT\TokenCollector::__construct | ( | TokenTransformManager | $manager, |
array | $options ) |
TokenTransformManager | $manager | manager enviroment |
array | $options | various configuration options |
Reimplemented from Wikimedia\Parsoid\Wt2Html\TT\TokenHandler.
Reimplemented in Wikimedia\Parsoid\Wt2Html\TT\IncludeOnly, and Wikimedia\Parsoid\Wt2Html\TT\NoInclude.
|
abstractprotected |
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.
Reimplemented in Wikimedia\Parsoid\Wt2Html\TT\IncludeOnly, and Wikimedia\Parsoid\Wt2Html\TT\NoInclude.
|
static |
This helper function will build a meta token in the right way for these tags.
TokenTransformManager | $manager | |
string | $tokenName | |
bool | $isEnd | |
SourceRange | $tsr | |
?string | $src |
|
abstractprotected |
(optional, only for token type 'tag'): tag name.
Reimplemented in Wikimedia\Parsoid\Wt2Html\TT\IncludeOnly, and Wikimedia\Parsoid\Wt2Html\TT\NoInclude.
Wikimedia\Parsoid\Wt2Html\TT\TokenCollector::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).
Token | string | $token | Token to be processed |
Reimplemented from Wikimedia\Parsoid\Wt2Html\TT\TokenHandler.
Wikimedia\Parsoid\Wt2Html\TT\TokenCollector::onEnd | ( | EOFTk | $token | ) |
This handler is called for EOF tokens only.
EOFTk | $token | EOF token to be processed |
Reimplemented from Wikimedia\Parsoid\Wt2Html\TT\TokenHandler.
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.
Token | $token | Token to be processed |
Reimplemented from Wikimedia\Parsoid\Wt2Html\TT\TokenHandler.
|
abstractprotected |
Match the 'end' tokens as closing tag as well (accept unclosed sections).
Reimplemented in Wikimedia\Parsoid\Wt2Html\TT\IncludeOnly, and Wikimedia\Parsoid\Wt2Html\TT\NoInclude.
|
abstractprotected |
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.
array | $array |
Reimplemented in Wikimedia\Parsoid\Wt2Html\TT\IncludeOnly, and Wikimedia\Parsoid\Wt2Html\TT\NoInclude.
|
abstractprotected |
Token type to register for ('tag', 'text' etc)
Reimplemented in Wikimedia\Parsoid\Wt2Html\TT\IncludeOnly, and Wikimedia\Parsoid\Wt2Html\TT\NoInclude.