CommentFormInputTransformer

CommentFormInputTransformer

Class that processes the comment form input and prepares the wikitext to insert into the page.

Constructor

new CommentFormInputTransformer(text, commentForm, action)

Source:

Create a comment form input processor.

Parameters:
Name Type Description
text string
commentForm CommentForm
action string

Extends

Members

maskedTexts :Array.<string>

Source:
Overrides:

Array of masked texts. Its indexes correspond to marker indexes.

Type:
  • Array.<string>

text :string

Source:
Overrides:

Text parts of which are masked.

Type:
  • string

Methods

(static) init()

Source:

Initialize the class.

(static) prependIndentationToLine(indentation, line) → {string}

Source:

Add indentation chars to the start of a line.

Parameters:
Name Type Description
indentation string
line string
Returns:
Type
string

getMaskedTexts() → {Array.<string>}

Source:
Overrides:

Get the masked texts.

Returns:
Type
Array.<string>

getText() → {string}

Source:
Overrides:

Get the text in its current (masked/unmasked) state.

Returns:
Type
string

isIndented() → {boolean}

Source:

Check whether the comment will be indented.

Returns:
Type
boolean

mask(regexp, type, useGroupsopt) → {TextMasker}

Source:
Overrides:

Replace text matched by a regexp with placeholders.

Parameters:
Name Type Attributes Default Description
regexp RegExp
type string

Should consist only of alphanumeric characters.

useGroups boolean <optional>
false

Use the first two capturing groups in the regexp as the preText and textToMask parameters. (Used for processing table code.)

Returns:
Type
TextMasker

maskSensitiveCode(templateHandleropt) → {TextMasker}

Source:
Overrides:

Replace code, that should not be modified when processing it, with placeholders.

Parameters:
Name Type Attributes Description
templateHandler function <optional>
Returns:
Type
TextMasker

maskTags(tags, type) → {TextMasker}

Source:
Overrides:

Mask HTML tags in the text.

Parameters:
Name Type Description
tags Array.<string>
type string
Returns:
Type
TextMasker

maskTemplatesRecursively(handleropt, addLengthsopt) → {TextMasker}

Source:
Overrides:
Author:
  • Putnik
  • Jack who built the house

Mask templates taking into account nested ones.

Borrowed from https://ru.wikipedia.org/w/index.php?title=MediaWiki:Gadget-wikificator.js&oldid=102530721

Parameters:
Name Type Attributes Default Description
handler function <optional>

Function that processes the template code.

addLengths boolean <optional>
false

Add lengths of the masked templates to markers.

Returns:
Type
TextMasker

processNewlines(code, isInTemplate) → {string}

Source:

Process newlines by adding or not adding <br> and keeping or not keeping the newline. \x01 and \x02 mean the beginning and ending of sensitive code except for tables. \x03 and \x04 mean the beginning and ending of a table. Note: This should be kept coordinated with the reverse transformation code in CommentSource#toInput.

Parameters:
Name Type Default Description
code string
isInTemplate boolean false
Returns:

code

Type
string

transform() → {string}

Source:

The main method that actually processes the code and returns the result.

Returns:
Type
string

unmask(type) → {TextMasker}

Source:
Overrides:

Replace placeholders added by TextMasker#mask with their text.

Parameters:
Name Type Description
type string
Returns:
Type
TextMasker

unmaskText(text, typeopt) → {string}

Source:
Overrides:

In a provided string, replace placeholders added by TextMasker#mask with their text.

Parameters:
Name Type Attributes Description
text string
type string <optional>
Returns:
Type
string

withText(func) → {TextMasker}

Source:
Overrides:

Run a certain function for the text.

Parameters:
Name Type Description
func function

Function that should accept and return a string. It can also accept the TextMasker object as a second parameter.

Returns:
Type
TextMasker