|
Parsoid
A bidirectional parser between wikitext and HTML5
|
Represents a preprocessor "piece". More...
Inheritance diagram for Wikimedia\Parsoid\Tokens\PreprocTk:
Collaboration diagram for Wikimedia\Parsoid\Tokens\PreprocTk:Public Member Functions | |
| getContents () | |
| getContentsKV () | |
| setContents (array $contents, SourceRange $tsr) | |
| setContentsKV (KV $contents) | |
| __clone () | |
| jsonSerialize () | |
| __toString () | |
| Return the string form of this PreprocTk; this should be identical to the original "preprocessed" wikitext. | |
| getBarredArgs () | |
Split this token by | and return target and named args. | |
| print ( $pretty=true) | |
| Pretty-print a PreprocTk token. | |
Public Member Functions inherited from Wikimedia\Parsoid\Tokens\Token | |
| toJsonArray () | |
| getType () | |
| Returns a string key for this token. | |
| addAttribute (string $name, $value, ?KVSourceRange $srcOffsets=null) | |
| Generic set attribute method. | |
| addNormalizedAttribute (string $name, $value, $origValue) | |
| Generic set attribute method with support for change detection. | |
| getAttributeV (string $name) | |
| Generic attribute accessor. | |
| getAttributeKV (string $name) | |
| Generic attribute accessor. | |
| hasAttribute (string $name) | |
| Generic attribute accessor. | |
| setAttribute (string $name, $value) | |
| Set an unshadowed attribute. | |
| setShadowInfo (string $name, $value, $origValue) | |
| Store the original value of an attribute in a token's dataParsoid. | |
| setShadowInfoIfModified (string $name, $value, $origValue) | |
| Store the original value of an attribute in a token's dataParsoid. | |
| getAttributeShadowInfo (string $name) | |
| Attribute info accessor for the wikitext serializer. | |
| removeAttribute (string $name) | |
| Completely remove all attributes with this name. | |
| addSpaceSeparatedAttribute (string $name, string $value) | |
| Add a space-separated property value. | |
| getWTSource (Source ... $source) | |
| Get the wikitext source of a token. | |
| fetchExpandedAttrValue (string $key) | |
Static Public Member Functions | |
| static | newContentsKV (array $contents, ?SourceRange $tsr) |
| Helper: return a new contents KV. | |
| static | trimContentsKV (KV $contents) |
| Trim whitespace from both sides of a contents KV. | |
| static | newFromJsonArray (array $json) |
| static | splitContentsBy (string|array|callable $sep, KV $contents, int $limit=-1) |
| Split a contents KV by a string or a function. | |
| static | printContents ( $contents, bool $pretty=true) |
| Pretty-print a contents KV on multiple lines. | |
Static Public Member Functions inherited from Wikimedia\Parsoid\Tokens\Token | |
| static | jsonClassHintFor (string $keyName) |
| static | hint () |
| static | getToken ( $input) |
| Get a token from some PHP structure. | |
Public Attributes | |
| const | CONTENTS_ATTR = 'mw:contents' |
Public Attributes inherited from Wikimedia\Parsoid\Tokens\Token | |
| DataParsoid | $dataParsoid |
| DataMw | $dataMw = null |
| array | $attribs = null |
Protected Member Functions | |
| recomputeTsr () | |
| printInternal (array &$result, string $prefix, bool $pretty) | |
| Pretty-print this PreprocTk token. | |
Protected Member Functions inherited from Wikimedia\Parsoid\Tokens\Token | |
| __construct (?DataParsoid $dataParsoid, ?DataMw $dataMw) | |
Static Protected Member Functions | |
| static | printContentsInternal (array &$result, array $pieces, string $prefix, bool $pretty) |
Represents a preprocessor "piece".
Contents of this token are not fully parsed, only the boundary locations are known.
| Wikimedia\Parsoid\Tokens\PreprocTk::__clone | ( | ) |
Reimplemented from Wikimedia\Parsoid\Tokens\Token.
| Wikimedia\Parsoid\Tokens\PreprocTk::getBarredArgs | ( | ) |
Split this token by | and return target and named args.
| Wikimedia\Parsoid\Tokens\PreprocTk::getContents | ( | ) |
| Wikimedia\Parsoid\Tokens\PreprocTk::getContentsKV | ( | ) |
list<PreprocTk|string> as value | Wikimedia\Parsoid\Tokens\PreprocTk::jsonSerialize | ( | ) |
Reimplemented from Wikimedia\Parsoid\Tokens\Token.
Reimplemented in Wikimedia\Parsoid\Tokens\PreprocAngleTk, Wikimedia\Parsoid\Tokens\PreprocHeadingTk, Wikimedia\Parsoid\Tokens\PreprocIgnoreTk, and Wikimedia\Parsoid\Tokens\PreprocPFragmentTk.
|
static |
Helper: return a new contents KV.
| list<PreprocTk|string> | $contents | |
| ?SourceRange | $tsr |
self::CONTENTS_ATTR and given $contents as value.
|
static |
Reimplemented from Wikimedia\Parsoid\Tokens\Token.
Reimplemented in Wikimedia\Parsoid\Tokens\PreprocAngleTk, Wikimedia\Parsoid\Tokens\PreprocHeadingTk, Wikimedia\Parsoid\Tokens\PreprocIgnoreTk, and Wikimedia\Parsoid\Tokens\PreprocPFragmentTk.
| Wikimedia\Parsoid\Tokens\PreprocTk::print | ( | $pretty = true | ) |
Pretty-print a PreprocTk token.
| bool | $pretty | if true (default) the output will be on multiple lines. If false, the string result should be identical to the original "preprocessed" wikitext. |
|
static |
Pretty-print a contents KV on multiple lines.
| KV | $contents | A contents KV containing a list<string|PreprocTk> |
| bool | $pretty | if true (default) the output will be on multiple lines. If false, the string result should be identical to the original "preprocessed" wikitext. |
|
staticprotected |
| list<string> | &$result | |
| list<string|PreprocTk> | $pieces A contents array | |
| string | $prefix | Indentation prefix |
|
protected |
Pretty-print this PreprocTk token.
| list<string> | &$result An array of output lines. | |
| string | $prefix | Indentation prefix |
Reimplemented in Wikimedia\Parsoid\Tokens\PreprocAngleTk, Wikimedia\Parsoid\Tokens\PreprocHeadingTk, Wikimedia\Parsoid\Tokens\PreprocIgnoreTk, and Wikimedia\Parsoid\Tokens\PreprocPFragmentTk.
| Wikimedia\Parsoid\Tokens\PreprocTk::setContents | ( | array | $contents, |
| SourceRange | $tsr ) |
| list<PreprocTk|string> | $contents | |
| SourceRange | $tsr |
| Wikimedia\Parsoid\Tokens\PreprocTk::setContentsKV | ( | KV | $contents | ) |
| KV | $contents |
|
static |
Split a contents KV by a string or a function.
| string|list<string>|callable(string,int):array | $sep Either a separator string, or a list of separator alternatives, or else a function compatible with preg_split with the PREG_SPLIT_DELIM_CAPTURE flag; that is, returns a list of strings with the "splitter" string in odd indexes. | |
| KV | $contents | A contents KV, containing a list<string|PreprocTk> |
| int | $limit | A split limit, or -1 for "no limit" This is the number of splits permitted; the return array length will be 1 + 2*$limit. |