Show:

State object for the wikitext serializers.

Here is what the state attributes mean:

rtTestMode

  • Are we currently running round-trip tests? If yes, then we know there won't be any edits and we more aggressively try to use original source and source flags during serialization since this is a test of Parsoid's efficacy in preserving information.

sep

  • Separator information:
    • constraints: min/max number of newlines
    • text: collected separator text from DOM text/comment nodes
    • lastSourceNode: Seems to be bookkeeping to make sure we don't reuse original separators when emitChunk is called consecutively on the same node. However, it also differs from state.prevNode in that it only gets updated when a node calls emitChunk so that nodes serializing justChildren don't mix up buildSep.

onSOL

  • Is the serializer at the start of a new wikitext line?

atStartOfOutput

  • True when wts kicks off, false after the first char has been output

inLink

  • Is the serializer currently handling link content (children of <a>)?

inIndentPre

  • Is the serializer currently handling indent-pre tags?

inPHPBlock

  • Is the serializer currently handling a tag that the PHP parser treats as a block tag?

inAttribute

  • Is the serializer being invoked recursively to serialize a template-generated attribute (via WSP.getAttributeValue's template handling). If so, we should suppress some serialization escapes, like autolink protection, since these are not valid for attribute values.

hasIndentPreNowikis

  • Did we introduce nowikis for indent-pre protection? If yes, we might run a post-pass to strip useless ones.

hasQuoteNowikis

  • Did we introduce nowikis to preserve quote semantics? If yes, we might run a post-pass to strip useless ones.

hasSelfClosingNowikis:

  • Did we introduce <nowiki />s? If yes, we do a postpass to remove unnecessary trailing ones.

hasHeadingEscapes:

  • Did we introduce nowikis around =.*= text? If yes, we do a postpass to remove unnecessary escapes.

wikiTableNesting

  • Records the nesting level of wikitext tables

wteHandlerStack

  • Stack of wikitext escaping handlers -- these handlers are responsible for smart escaping when the surrounding wikitext context is known.

currLine

  • This object is used by the wikitext escaping algorithm -- represents a "single line" of output wikitext as represented by a block node in the DOM.
    • firstNode: first DOM node processed on this line
    • text: output so far from all nodes on the current line
    • chunks: list of ConstrainedText chunks comprising the current line

singleLineContext

  • Stack used to enforce single-line context

redirectText

  • Text to be emitted at the start of file, for redirects

Classes

SerializerState
SingleLineContext