State object for the wikitext serializers.
More...
|
| __construct (WikitextSerializer $serializer, array $options=[]) |
|
| getEnv () |
|
| initMode (bool $selserMode) |
| Initialize a few boolean flags based on serialization mode.
|
|
| appendSep (string $src) |
| Appends the separator source to the separator src buffer.
|
|
| updateSep (Node $node) |
| Cycle the state after processing a node.
|
|
| getOrigSrc (int $start, int $end) |
| Extracts a subset of the page source bound by the supplied indices.
|
|
| updateModificationFlags (Node $node) |
| Like it says on the tin.
|
|
| recoverTrimmedWhitespace (Node $node, bool $leading) |
| Recovers and emits any trimmed whitespace for $node.
|
|
| emitChunk ( $res, Node $node) |
| Pushes the chunk to the current line.
|
|
| serializeChildren (Node $node, ?callable $wtEscaper=null, ?Node $firstChild=null) |
| Serialize the children of a DOM node, sharing the global serializer state.
|
|
| kickOffSerialize (Node $node, ?callable $wtEscaper=null) |
| Abstracts some steps taken in serializeChildrenToString and serializeDOM
|
|
| serializeLinkChildrenToString (Node $node, ?callable $wtEscaper=null) |
| Serialize children of a link to a string.
|
|
| serializeCaptionChildrenToString (Node $node, ?callable $wtEscaper=null) |
| Serialize children of a caption to a string.
|
|
| serializeIndentPreChildrenToString (Node $node, ?callable $wtEscaper=null) |
| Serialize children of an indent-pre to a string.
|
|
| openAnnotationRange (string $ann, bool $extended) |
| Take notes of the open annotation ranges and whether they have been extended.
|
|
| closeAnnotationRange (string $ann) |
| Removes the corresponding annotation range from the list of open ranges.
|
|
|
| $sep |
|
| $onSOL = true |
|
| $atStartOfOutput = true |
|
| $inLink = false |
|
| $inCaption = false |
|
| $inIndentPre = false |
|
| $inHTMLPre = false |
|
| $inPHPBlock = false |
|
| $inAttribute = false |
|
| $inModifiedContent |
|
| $hasIndentPreNowikis = false |
|
| $hasQuoteNowikis = false |
|
| $hasSelfClosingNowikis = false |
|
| $hasHeadingEscapes = false |
|
| $wikiTableNesting = 0 |
|
| $wteHandlerStack = [] |
|
| $currLine |
|
| $singleLineContext |
|
| $redirectText = null |
|
| $serializer |
|
| $extApi |
|
| $out = '' |
|
| $useWhitespaceHeuristics |
|
| $selserMode |
|
| $prevNodeUnmodified |
|
| $currNodeUnmodified |
|
| $needsEscaping = false |
|
| $protect |
|
| $separators |
|
| $currNode |
|
| $openAnnotations |
|
| $haveTrimmedWsDSR = false |
|
State object for the wikitext serializers.
◆ __construct()
Wikimedia\Parsoid\Html2Wt\SerializerState::__construct |
( |
WikitextSerializer | $serializer, |
|
|
array | $options = [] ) |
- Parameters
-
WikitextSerializer | $serializer | |
array | $options | List of options for serialization:
- onSOL: (bool)
- inPHPBlock: (bool)
- inAttribute: (bool)
- protect: (string)
- selserData: (SelserData)
|
◆ appendSep()
Wikimedia\Parsoid\Html2Wt\SerializerState::appendSep |
( |
string | $src | ) |
|
Appends the separator source to the separator src buffer.
Don't update $state->onSOL since this string hasn't been emitted yet. If content handlers change behavior based on whether this newline will be emitted or not, they should peek into this buffer (ex: see TDHandler and THHandler code).
- Parameters
-
◆ closeAnnotationRange()
Wikimedia\Parsoid\Html2Wt\SerializerState::closeAnnotationRange |
( |
string | $ann | ) |
|
Removes the corresponding annotation range from the list of open ranges.
- Parameters
-
◆ emitChunk()
Wikimedia\Parsoid\Html2Wt\SerializerState::emitChunk |
( |
| $res, |
|
|
Node | $node ) |
Pushes the chunk to the current line.
- Parameters
-
ConstrainedText | string | $res | |
Node | $node | |
◆ getEnv()
Wikimedia\Parsoid\Html2Wt\SerializerState::getEnv |
( |
| ) |
|
- Note
- Porting note: this replaces direct access
- Returns
- Env
◆ getOrigSrc()
Wikimedia\Parsoid\Html2Wt\SerializerState::getOrigSrc |
( |
int | $start, |
|
|
int | $end ) |
Extracts a subset of the page source bound by the supplied indices.
- Parameters
-
int | $start | Start offset, in bytes |
int | $end | End offset, in bytes |
- Returns
- string|null
◆ initMode()
Wikimedia\Parsoid\Html2Wt\SerializerState::initMode |
( |
bool | $selserMode | ) |
|
Initialize a few boolean flags based on serialization mode.
FIXME: Ideally, this should be private. Requires shuffing around where SerializerState is constructed so that $selserMode is known at the time of construction. for use by WikitextSerializer only
- Parameters
-
bool | $selserMode | Are we running selective serialization? |
◆ kickOffSerialize()
Wikimedia\Parsoid\Html2Wt\SerializerState::kickOffSerialize |
( |
Node | $node, |
|
|
?callable | $wtEscaper = null ) |
Abstracts some steps taken in serializeChildrenToString
and serializeDOM
- Parameters
-
◆ openAnnotationRange()
Wikimedia\Parsoid\Html2Wt\SerializerState::openAnnotationRange |
( |
string | $ann, |
|
|
bool | $extended ) |
Take notes of the open annotation ranges and whether they have been extended.
- Parameters
-
◆ recoverTrimmedWhitespace()
Wikimedia\Parsoid\Html2Wt\SerializerState::recoverTrimmedWhitespace |
( |
Node | $node, |
|
|
bool | $leading ) |
Recovers and emits any trimmed whitespace for $node.
- Parameters
-
Node | $node | |
bool | $leading | if true, trimmed leading whitespace is emitted if false, trimmed railing whitespace is emitted |
- Returns
- string|null
◆ serializeCaptionChildrenToString()
Wikimedia\Parsoid\Html2Wt\SerializerState::serializeCaptionChildrenToString |
( |
Node | $node, |
|
|
?callable | $wtEscaper = null ) |
Serialize children of a caption to a string.
- Parameters
-
- Returns
- string
◆ serializeChildren()
callable[] See link Wikimedia\Parsoid\Html2Wt\SerializerState::serializeChildren |
( |
Node | $node, |
|
|
?callable | $wtEscaper = null, |
|
|
?Node | $firstChild = null ) |
Serialize the children of a DOM node, sharing the global serializer state.
Stack of wikitext escaping handlers – these handlers are responsible for smart escaping when the surrounding wikitext context is known.
Typically called by a DOM-based handler to continue handling its children.
- Parameters
-
Element | DocumentFragment | $node | |
?callable | $wtEscaper | ( $state, $text, $opts ) PORT-FIXME document better; should this be done via WikitextEscapeHandlers somehow? |
?Node | $firstChild | |
◆ serializeIndentPreChildrenToString()
Wikimedia\Parsoid\Html2Wt\SerializerState::serializeIndentPreChildrenToString |
( |
Node | $node, |
|
|
?callable | $wtEscaper = null ) |
Serialize children of an indent-pre to a string.
- Parameters
-
- Returns
- string
◆ serializeLinkChildrenToString()
Wikimedia\Parsoid\Html2Wt\SerializerState::serializeLinkChildrenToString |
( |
Node | $node, |
|
|
?callable | $wtEscaper = null ) |
Serialize children of a link to a string.
- Parameters
-
- Returns
- string
◆ updateModificationFlags()
Wikimedia\Parsoid\Html2Wt\SerializerState::updateModificationFlags |
( |
Node | $node | ) |
|
Like it says on the tin.
- Parameters
-
◆ updateSep()
Wikimedia\Parsoid\Html2Wt\SerializerState::updateSep |
( |
Node | $node | ) |
|
Cycle the state after processing a node.
- Parameters
-
The documentation for this class was generated from the following file:
- src/Html2Wt/SerializerState.php