Expand description
§wikioxide
Parse MediaWiki wikitext into typed domain models — locally, deterministically and
without HTML: template calls with full parameter maps, categories with sort keys,
internal/external links, typed parser warnings and structural statistics, mirroring what
the Action API’s action=parse reports for
prop=templates|categories|links|externallinks|parsewarnings.
Configure a WikitextParser once per wiki (vendored presets for en/ru Wikipedia ship
behind the default presets feature), then parse any number of pages:
use wikioxide::{DocumentView, NamespaceDef, PageContext, SiteConfig, WikitextParser};
let config = SiteConfig::builder("ru", "Вики")
.namespace(NamespaceDef::main())
.namespace(NamespaceDef::new(10, "Template", "Шаблон", ["Ш"], true))
.link_trail("a-zа-яё")
.build()?;
let parser = WikitextParser::builder().site_config(config).build()?;
let doc = parser.parse(
"Стихи [[кота|котика]] в {{рамке|цвет=серый}}",
&PageContext::default(),
);
assert_eq!(doc.links()[0].target().text(), "Кота");
assert_eq!(doc.links()[0].anchor_text(), Some("котика"));
assert_eq!(doc.templates()[0].title().text(), "Шаблон:Рамке");
assert_eq!(doc.templates()[0].param("цвет"), Some("серый"));The parser is total over input: malformed wikitext yields a document plus typed
Warnings, never an error. Template expansion (with a pluggable template source)
arrives with the next milestone; today’s ParsedDocument is the faithful as-written
view of a page.
Modules§
- discussion
- Discussion parsing: turns a talk page’s raw wikitext into signed comments with authors, timestamps and original-source spans.
Structs§
- Category
Link - A category membership (the API’s
prop=categoriesitem). - Empty
Template Source - A
TemplateSourcethat knows nothing — every lookup isTemplateFetch::Unknown. The default source when a parser is built without one. - Existence
Map - A batch of existence facts, keyed by title, applied to a parsed document via
ExpandedDocument::apply_existence. - Existence
Record - A page-existence fact returned by an
ExistenceProvider. - Expanded
Document - The post-expansion view of a page: templates transcluded,
{{{arguments}}}substituted and parser functions evaluated. Itslinks/categories/external_linksare the API’s post-expansion sets, andtransclusion_closureis the recursive template/module set (prop=templates). Produced byWikitextParser::expand. - External
Link - An external link (the API’s
externallinksitem). - Fixed
Clock - A frozen clock for reproducible parses (tests, golden fixtures).
- InMemory
Template Store - A thread-safe in-memory template cache. Share one via
Arcbetween the parser and a prefetch task: expand, collectMissingTemplates, fill the store, expand again. - Inter
Language Link - An interlanguage (or interwiki) sidebar link, e.g.
[[fr:Chat]]. - Internal
Link - An internal wikilink (the API’s
prop=linksitem). - Limits
- Expansion and parsing resource limits.
- Magic
Links - Toggles for MediaWiki’s RFC/PMID/ISBN “magic links” (still enabled on Wikimedia wikis).
- Magic
Word Def - One magic word — a variable, parser function or behavior switch — with its aliases.
- Missing
Templates - The template pages an expansion pass could not resolve under
UnresolvedPolicy::Halt. - Module
Invocation - One
{{#invoke:Module|function|…}}call (Scribunto is not executed in v1). - Month
Names - Localized month names in the three forms MediaWiki date formatting uses. The
genitive form is the one that appears in signature timestamps (Russian
8 мая 2026uses the genitiveмая); English uses the nominative for all three. - Namespace
- A MediaWiki namespace number.
- Namespace
Def - One namespace definition fed to
SiteConfigBuilder::namespace. - Page
Context - Per-page parse context: the page’s own title (drives
{{PAGENAME}}and self-link detection once expansion lands) and an optional fixed “now” override. - Parsed
Document - The as-written view of one page: what is literally in the wikitext, templates
unexpanded. Produced by
WikitextParser::parse. - Provider
Error - Opaque, caller-defined error from an
ExistenceProviderlookup. - Redirect
- A
#REDIRECT [[Target#fragment]]declaration at the top of the page. - Section
- A heading and the section it introduces, with byte spans into the original source (never the flattened text) so a consumer can slice or move the raw wikitext.
- Site
Config - Compiled per-wiki configuration. Cheap to share (
Cloneclones the compiled tables); build one per wiki and reuse it for every parse. - Site
Config Builder - Builder for
SiteConfig— the JSON-free construction path. - Span
- A byte range into the original input passed to the parser.
- Structural
Stats - Structural counts over the parsed document — the replacement for counting
<table/<trsubstrings in API HTML. - System
Clock - Wall-clock time (the default for interactive use).
- Template
Call - One template call, with its full parameter map — including calls nested inside other calls’ argument values.
- Timestamp
- A point in time: seconds since the Unix epoch, UTC.
- Title
- A normalized MediaWiki page title: a namespace plus a dbkey (underscored page name).
- Wikitext
Parser - A configured, reusable, thread-safe wikitext parser. Build one per wiki and share it —
Cloneis cheap (Arcinside). - Wikitext
Parser Builder - Builder for
WikitextParser.
Enums§
- Build
Error - Errors from constructing a parser.
- Config
Error - Errors from loading or building a
SiteConfig. - Expand
Outcome - The outcome of
WikitextParser::expand. - ExtTag
Content - How an extension tag’s body is treated by the parser.
- Origin
- Where an extracted item came from.
- Template
Fetch - The result of asking a
TemplateSourcefor a page. - Title
Error - Errors from
Title::parse. - Unresolved
Policy - What expansion does when a
TemplateSourcereturnsTemplateFetch::Unknown. - Warning
- One parser warning: machine-readable data with a human-readable
Display.
Traits§
- Clock
- Source of “now” for time-dependent magic words.
- Document
View - The read surface shared by every parse result — write one diff/analysis routine over
&dyn DocumentViewand it works for both the as-written and (later) the expanded view. - Existence
Provider - A synchronous page-existence oracle consulted by
{{#ifexist:}}during expansion. Optional: without one,{{#ifexist:}}records the query and takes the false branch. - Template
Source - Where template and module wikitext comes from. Implementations must be pure and deterministic per call (the engine may ask for the same title more than once) and perform no blocking I/O on the calling thread — prefetch into a cache instead.