mediawiki-title
Mediawiki title normalizetion, that conforms to the normalization rules used in MediaWiki Core.
In general, the page title is converted to the mediawiki DB key format by trimming spaces, replacing whitespace symbols to underscores
and applying wiki-specific capitalizetion rules. The namespace name is converted to a localized canonical name.
Functions
- normalize(title, siteInfo) ⇒
string
Normalize a title according to the rules of
Typedefs
- SiteInfo :
Object
Information about a wikimedia site required to make correct normalization.
normalize(title, siteInfo) ⇒ string
Normalize a title according to the rules of
Returns: string
- normalized version of a title.
Access: public
Param | Type | Description |
---|
title | string | The page title to normalize. |
siteInfo | SiteInfo | The site information. |
SiteInfo : Object
Information about a wikimedia site required to make correct
normalization.
Properties
Name | Type | Description |
---|
lang | string | Site language code. |
legaltitlechars | string | A perl-like regex for characters allowed in the page title. |
namespaces | Object | Site namespaces info in the same format as returned by PHP api. |
namespacealiases | Object | Site namespace aliases in the same format as returned by PHP api. |
Usage
The library returns a Bluebird promise of a normalized title.
Wiki-specific rules are fetched from the api, and
cached within the Normalizer
instance, so reusing the instance is highly recommended.
var result = normalizer.normalize('some_title', {
lang: 'en',
legaltitlechars: " %!\"$&'()*,\\-.\\/0-9:;=?@A-Z\\\\^_`a-z~\\x80-\\xFF+",
namespaces: {
"0": {
id: 0,
case: "first-letter",
content: "",
"*": ""
},
}
});
Bug reporting
For bug reporting please use Phabricator ]
and mark the bugs with Servises
label or contuct directly in IRC in the #wikimedia-services channel.