Namespace: Util

utils/Util~Util

Members

(static) linkTrailRegex

This regex was generated by running through all unicode characters and testing them against all regexes for linktrails in a default MW install.

This regex was generated by running through all unicode characters and testing them against all regexes for linktrails in a default MW install. We had to treat it a little bit, here's what we changed:

  1. A-Z, though allowed in Walloon, is disallowed.
  2. '"', though allowed in Chuvash, is disallowed.
  3. '-', though allowed in Icelandic (possibly due to a bug), is disallowed.
  4. '1', though allowed in Lak (possibly due to a bug), is disallowed.
Properties:
Type Description
RegExp
Source:

(static) magicMasqs

Magic words masquerading as templates.

Magic words masquerading as templates.

Properties:
Type Description
Set
Source:

(static) TPL_META_TYPE_REGEXP

Regexp for checking marker metas typeofs representing transclusion markup or template param markup.

Regexp for checking marker metas typeofs representing transclusion markup or template param markup.

Properties:
Type Description
RegExp
Source:

Methods

(static) bcp47(code) → {string}

Convert mediawiki-format language code to a BCP47-compliant language code suitable for including in HTML.

Convert mediawiki-format language code to a BCP47-compliant language code suitable for including in HTML. See GlobalFunctions.php::wfBCP47() in mediawiki sources.

Parameters:
Name Type Description
code string

Mediawiki language code.

Source:
Returns:

BCP47 language code.

Type
string

(static) decodeWtEntities(text) → {string}

Decode HTML5 entities in wikitext.

Decode HTML5 entities in wikitext.

NOTE that wikitext only allows semicolon-terminated entities, while HTML allows a number of "legacy" entities to be decoded without a terminating semicolon. This function deliberately does not decode these HTML-only entity forms.

Parameters:
Name Type Description
text string
Source:
Returns:
Type
string

(static) entityEncodeAll(s) → {string}

Encode all characters as entity references.

Encode all characters as entity references. This is done to make characters safe for wikitext (regardless of whether they are HTML-safe).

Parameters:
Name Type Description
s string
Source:
Returns:
Type
string

(static) escapeWtEntities(text) → {string}

Entity-escape anything that would decode to a valid wikitext entity.

Entity-escape anything that would decode to a valid wikitext entity.

Note that HTML5 allows certain "semicolon-less" entities, like ¶ these aren't allowed in wikitext and won't be escaped by this function.

Parameters:
Name Type Description
text string
Source:
Returns:
Type
string

(static) extendProps(tgt, …subject) → {Object}

Update only those properties that are undefined or null in the target.

Update only those properties that are undefined or null in the target.

Parameters:
Name Type Attributes Description
tgt Object

The object to modify.

subject Object <repeatable>

The object to extend tgt with. Add more arguments to the function call to chain more extensions.

Source:
Returns:

The modified object.

Type
Object

(static) isLinkTrail(text) → {boolean}

Check whether some text is a valid link trail.

Check whether some text is a valid link trail.

Parameters:
Name Type Description
text string
Source:
Returns:
Type
boolean

(static) isProtocolValid()

Determine whether the protocol of a link is potentially valid.

Determine whether the protocol of a link is potentially valid. Use the environment's per-wiki config to do so.

Source:

(static) isVoidElement()

Determine if the named tag is void (can not have content).

Determine if the named tag is void (can not have content).

Source:

(static) makeHash(arr)

Quickly hash an array or string.

Quickly hash an array or string.

Parameters:
Name Type Description
arr Array | string
Source:

(static) normalizeNamespaceName(name) → {string}

Cannonicalizes a namespace name.

Cannonicalizes a namespace name.

Used by WikiConfig.

Parameters:
Name Type Description
name string

Non-normalized namespace name.

Source:
Returns:
Type
string

(static) phpURLEncode()

Emulate PHP's urlencode by patching results of JS's encodeURIComponent.

Emulate PHP's urlencode by patching results of JS's encodeURIComponent.

PHP: https://secure.php.net/manual/en/function.urlencode.php

JS: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURIComponent

Spaces to '+' is a PHP peculiarity as well.

Source: