Parsoid
A bidirectional parser between wikitext and HTML5
|
Catch-all class for all token types. More...
Public Member Functions | |
jsonSerialize () | |
getName () | |
Get a name for the token. | |
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. | |
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 (Frame $frame) | |
Get the wikitext source of a token. | |
fetchExpandedAttrValue (string $key) | |
Static Public Member Functions | |
static | getToken ( $input) |
Get a token from some PHP structure. | |
Public Attributes | |
DataParsoid | $dataParsoid |
DataMw | $dataMw = null |
$attribs | |
Protected Member Functions | |
__construct (?DataParsoid $dataParsoid, ?DataMw $dataMw) | |
Catch-all class for all token types.
Wikimedia\Parsoid\Tokens\Token::addAttribute | ( | string | $name, |
$value, | |||
?KVSourceRange | $srcOffsets = null ) |
Generic set attribute method.
string | $name | Always a string when used this way. The more complex form (where the key is a non-string) are found when KV objects are constructed in the tokenizer. |
string|Token|array<Token|string> | $value | |
?KVSourceRange | $srcOffsets |
Wikimedia\Parsoid\Tokens\Token::addNormalizedAttribute | ( | string | $name, |
$value, | |||
$origValue ) |
Generic set attribute method with support for change detection.
Set a value and preserve the original wikitext that produced it.
string | $name | |
string|Token|array<Token|string> | $value | |
mixed | $origValue |
Wikimedia\Parsoid\Tokens\Token::addSpaceSeparatedAttribute | ( | string | $name, |
string | $value ) |
Add a space-separated property value.
These are Parsoid-added attributes, not something present in source. So, only a regular ASCII space characters will be used here.
string | $name | The attribute name |
string | $value | The value to add to the attribute |
Wikimedia\Parsoid\Tokens\Token::getAttributeKV | ( | string | $name | ) |
Generic attribute accessor.
string | $name |
Wikimedia\Parsoid\Tokens\Token::getAttributeShadowInfo | ( | string | $name | ) |
Attribute info accessor for the wikitext serializer.
Performs change detection and uses unnormalized attribute values if set. Expects the context to be set to a token.
string | $name |
Wikimedia\Parsoid\Tokens\Token::getAttributeV | ( | string | $name | ) |
Generic attribute accessor.
string | $name |
Wikimedia\Parsoid\Tokens\Token::getName | ( | ) |
Get a name for the token.
Derived classes can override this.
Reimplemented in Wikimedia\Parsoid\Tokens\EndTagTk, Wikimedia\Parsoid\Tokens\SelfclosingTagTk, and Wikimedia\Parsoid\Tokens\TagTk.
|
static |
Get a token from some PHP structure.
Used by the PHPUnit tests.
KV | Token | array | string | int | float | bool | null | $input |
Wikimedia\Parsoid\Tokens\Token::getType | ( | ) |
Returns a string key for this token.
Wikimedia\Parsoid\Tokens\Token::getWTSource | ( | Frame | $frame | ) |
Get the wikitext source of a token.
Frame | $frame |
Wikimedia\Parsoid\Tokens\Token::hasAttribute | ( | string | $name | ) |
Generic attribute accessor.
string | $name |
|
abstract |
Wikimedia\Parsoid\Tokens\Token::removeAttribute | ( | string | $name | ) |
Completely remove all attributes with this name.
string | $name |
Wikimedia\Parsoid\Tokens\Token::setAttribute | ( | string | $name, |
$value ) |
Set an unshadowed attribute.
string | $name | |
string|Token|array<Token|string> | $value |
Wikimedia\Parsoid\Tokens\Token::setShadowInfo | ( | string | $name, |
$value, | |||
$origValue ) |
Store the original value of an attribute in a token's dataParsoid.
string | $name | |
mixed | $value | |
mixed | $origValue |