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

Catch-all class for all token types. More...

+ Inheritance diagram for Wikimedia\Parsoid\Tokens\Token:
+ Collaboration diagram for Wikimedia\Parsoid\Tokens\Token:

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
 
 $attribs
 

Detailed Description

Catch-all class for all token types.

Member Function Documentation

◆ addAttribute()

Wikimedia\Parsoid\Tokens\Token::addAttribute ( string $name,
$value,
?KVSourceRange $srcOffsets = null )

Generic set attribute method.

Parameters
string$nameAlways 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

◆ addNormalizedAttribute()

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.

Parameters
string$name
string | Token | Token[]$value
mixed$origValue

◆ addSpaceSeparatedAttribute()

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.

Parameters
string$nameThe attribute name
string$valueThe value to add to the attribute

◆ getAttributeKV()

Wikimedia\Parsoid\Tokens\Token::getAttributeKV ( string $name)

Generic attribute accessor.

Parameters
string$name
Returns
KV|null

◆ getAttributeShadowInfo()

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.

Parameters
string$name
Returns
array Information about the shadow info attached to this attribute:
  • value: (Token|Token[]|string) When modified is false and fromsrc is true, this is always a string.
  • modified: (bool)
  • fromsrc: (bool)

◆ getAttributeV()

Wikimedia\Parsoid\Tokens\Token::getAttributeV ( string $name)

Generic attribute accessor.

Parameters
string$name
Returns
string|Token|Token[]|KV[]|null

◆ getName()

Wikimedia\Parsoid\Tokens\Token::getName ( )

Get a name for the token.

Derived classes can override this.

Returns
string

Reimplemented in Wikimedia\Parsoid\Tokens\EndTagTk, Wikimedia\Parsoid\Tokens\SelfclosingTagTk, and Wikimedia\Parsoid\Tokens\TagTk.

◆ getToken()

static Wikimedia\Parsoid\Tokens\Token::getToken ( $input)
static

Get a token from some PHP structure.

Used by the PHPUnit tests.

Parameters
KV | Token | array | string | int | float | bool | null$input
Returns
Token|string|int|float|bool|null|array<Token|string|int|float|bool|null>

◆ getType()

Wikimedia\Parsoid\Tokens\Token::getType ( )

Returns a string key for this token.

Returns
string

◆ getWTSource()

Wikimedia\Parsoid\Tokens\Token::getWTSource ( Frame $frame)

Get the wikitext source of a token.

Parameters
Frame$frame
Returns
string

◆ hasAttribute()

Wikimedia\Parsoid\Tokens\Token::hasAttribute ( string $name)

Generic attribute accessor.

Parameters
string$name
Returns
bool

◆ jsonSerialize()

◆ removeAttribute()

Wikimedia\Parsoid\Tokens\Token::removeAttribute ( string $name)

Completely remove all attributes with this name.

Parameters
string$name

◆ setAttribute()

Wikimedia\Parsoid\Tokens\Token::setAttribute ( string $name,
$value )

Set an unshadowed attribute.

Parameters
string$name
string | Token | Token[]$value

◆ setShadowInfo()

Wikimedia\Parsoid\Tokens\Token::setShadowInfo ( string $name,
$value,
$origValue )

Store the original value of an attribute in a token's dataParsoid.

Parameters
string$name
mixed$value
mixed$origValue

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