mwtitle
mwtitle is a library for parsing, normalizing and formatting MediaWiki
page titles. It is primarily a port of the MediaWikiTitleCodec class
from MediaWiki, and passes the MediaWiki test suite.
The easiest way to get started is create a [TitleCodec] from a siteinfo
API request.
let url = "https://en.wikipedia.org/w/api.php\
?action=query&meta=siteinfo\
&siprop=general|namespaces|namespacealiases|interwikimap\
&formatversion=2&format=json";
let resp: SiteInfoResponse = get.await?.json.await?;
let codec = from_site_info?;
let title = codec.new_title?;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
It's also possible to possible to create a TitleCodec from a JSON
siteinfo-namespaces.json or compressed siteinfo-namespaces.json.gz
that comes from Wikimedia dumps. This requires the extra utils feature
to be enabled.
Contributing
mwtitle is a part of the mwbot-rs project.
We're always looking for new contributors, please reach out
if you're interested!
License
This crate is released under GPL-3.0-or-later. See COPYING for details.