Constructor
new TextMasker(text, maskedTextsopt)
- Source:
Create a text masker.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
text |
string | ||
maskedTexts |
Array.<string> |
<optional> |
Array of masked texts to reuse. Use this when you are using the class with a string that already has masked parts, or you will run into problems. |
Members
maskedTexts :Array.<string>
- Source:
Array of masked texts. Its indexes correspond to marker indexes.
Type:
- Array.<string>
text :string
- Source:
Text parts of which are masked.
Type:
- string
Methods
getMaskedTexts() → {Array.<string>}
- Source:
Get the masked texts.
Returns:
- Type
- Array.<string>
getText() → {string}
- Source:
Get the text in its current (masked/unmasked) state.
Returns:
- Type
- string
mask(regexp, typeopt, useGroupsopt) → {TextMasker}
- Source:
Replace text matched by a regexp with placeholders.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
regexp |
RegExp | |||
type |
string |
<optional> |
Should consist only of alphanumeric characters. |
|
useGroups |
boolean |
<optional> |
false
|
Use the first two capturing groups in the regexp as the
|
Returns:
- Type
- TextMasker
maskSensitiveCode(templateHandleropt) → {TextMasker}
- Source:
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:
Mask HTML tags in the text.
Parameters:
Name | Type | Description |
---|---|---|
tags |
Array.<string> | |
type |
string |
Returns:
- Type
- TextMasker
maskTemplatesRecursively(handleropt, addLengthsopt) → {TextMasker}
- Source:
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
unmask(type) → {TextMasker}
- Source:
Replace placeholders added by TextMasker#mask with their text.
Parameters:
Name | Type | Description |
---|---|---|
type |
string |
Returns:
- Type
- TextMasker
unmaskText(text, typeopt) → {string}
- Source:
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:
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