State object for the wikitext serializers.
Here is what the state attributes mean:
- 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.
- 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
emitChunkis called consecutively on the same node. However, it also differs from
state.prevNodein that it only gets updated when a node calls
emitChunkso that nodes serializing
justChildrendon't mix up
- Is the serializer at the start of a new wikitext line?
- True when wts kicks off, false after the first char has been output
- Is the serializer currently handling link content (children of
- Is the serializer currently handling indent-pre tags?
- Is the serializer currently handling a tag that the PHP parser treats as a block tag?
- 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.
- Did we introduce nowikis for indent-pre protection? If yes, we might run a post-pass to strip useless ones.
- Did we introduce nowikis to preserve quote semantics? If yes, we might run a post-pass to strip useless ones.
- Did we introduce
<nowiki />s? If yes, we do a postpass to remove unnecessary trailing ones.
- Did we introduce nowikis around
=.*=text? If yes, we do a postpass to remove unnecessary escapes.
- Records the nesting level of wikitext tables
- Stack of wikitext escaping handlers -- these handlers are responsible for smart escaping when the surrounding wikitext context is known.
- This object is used by the wikitext escaping algorithm -- represents
a "single line" of output wikitext as represented by a block node in
- 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
- Stack used to enforce single-line context
- Text to be emitted at the start of file, for redirects