Module: html2wt/ConstrainedText

Chunk-based serialization support.

Keeping wikitext output in ConstrainedText chunks allows us to preserve meta-information about boundary conditions at the edges of chunks. This allows us to more easily add <nowiki> and other fixups where needed to prevent misparsing caused by juxtaposition.

For example, the chunk corresponding to a magic link can "remember" that it needs to have word boundaries on either side. If these aren't present (after the chunks on either side have been serialized) then we can add escapes at the proper places.

Classes

AutoURLLinkText
An autolink to an external resource, like http://example.com.
ConstrainedText
A chunk of wikitext output.
ExtLinkText
An external link, like [http://example.com].
LanguageVariantText
Language Variant markup, like -{ ...
MagicLinkText
An autolink to an RFC/PMID/ISBN, like RFC 1234.
RegExpConstrainedText

This subclass allows specification of a regular expression for acceptable (or prohibited) leading (and/or trailing) contexts.

WikiLinkText
An internal wiki link, like [[Foo]].

Methods

(inner) escapeLine(line) → {string}

This adds necessary escapes to a line of chunks.

This adds necessary escapes to a line of chunks. We provide the ConstrainedText#escape function with its left and right context, and it can determine what escapes are needed.

The line parameter is an array of ConstrainedText chunks which make up a line (or part of a line, in some cases of nested processing).

Parameters:
Name Type Description
line Array.<ConstrainedText>
Source:
Returns:
Type
string