Class: WikitextEscapeHandlers

html2wt/escapeWikitext~WikitextEscapeHandlers(env, serializer)

new WikitextEscapeHandlers(env, serializer)

...
Parameters:
Name Type Description
env MWParserEnvironment
serializer WikitextSerializer
Source:

Methods

escapedText()

This function attempts to wrap smallest escapable units into nowikis (which can potentially add multiple nowiki pairs in a single string).

This function attempts to wrap smallest escapable units into nowikis (which can potentially add multiple nowiki pairs in a single string). The idea here is that since this should all be text, anything that tokenizes to another construct needs to be wrapped.

Full-wrapping is enabled if the string is being escaped within context-specific handlers where the tokenization context might be different from what we use in this code.

Source:

escapeTplArgWT()

General strategy:

Tokenize the arg wikitext.

General strategy:

Tokenize the arg wikitext. Anything that parses as tags are good and we need not bother with those. Check for harmful characters [[]]{{}} or additionally = in positional parameters and escape those fragments since these characters could change semantics of the entire template transclusion.

This function makes a couple of assumptions:

  1. The tokenizer sets tsr on all non-string tokens.
  2. The tsr on TagTk and EndTagTk corresponds to the width of the opening and closing wikitext tags and not the entire DOM range they span in the end.
Source:

escapeWikiText(text, opts)

...
Parameters:
Name Type Description
text string
opts Object
Source: