pub struct SiteConfig { /* private fields */ }Expand description
Compiled per-wiki configuration. Cheap to share (Clone clones the compiled tables);
build one per wiki and reuse it for every parse.
Implementations§
Source§impl SiteConfig
impl SiteConfig
Sourcepub fn from_preset_json(json: &str) -> Result<SiteConfig, ConfigError>
pub fn from_preset_json(json: &str) -> Result<SiteConfig, ConfigError>
Loads a configuration from preset JSON (the schema written by
cargo xtask gen-siteconfig, not raw meta=siteinfo output).
Sourcepub fn enwiki() -> &'static SiteConfig
pub fn enwiki() -> &'static SiteConfig
English Wikipedia (en.wikipedia.org) preset.
Sourcepub fn ruwiki() -> &'static SiteConfig
pub fn ruwiki() -> &'static SiteConfig
Russian Wikipedia (ru.wikipedia.org) preset.
Sourcepub fn generic() -> &'static SiteConfig
pub fn generic() -> &'static SiteConfig
A plain-MediaWiki preset: canonical English namespaces, core magic words and extension tags, default protocols. Suitable for wikis you have no siteinfo for.
Source§impl SiteConfig
impl SiteConfig
Sourcepub fn builder(
lang: impl Into<String>,
site_name: impl Into<String>,
) -> SiteConfigBuilder
pub fn builder( lang: impl Into<String>, site_name: impl Into<String>, ) -> SiteConfigBuilder
Starts building a configuration for a wiki with the given content language code and site name.
Sourcepub fn site_name(&self) -> &str
pub fn site_name(&self) -> &str
The wiki’s site name (e.g. "Википедия"), the {{SITENAME}} value.
Sourcepub fn resolve_namespace(&self, prefix: &str) -> Option<Namespace>
pub fn resolve_namespace(&self, prefix: &str) -> Option<Namespace>
Resolves a namespace prefix (canonical, localized or alias; case-insensitive, underscore/space-insensitive) to a namespace.
Sourcepub fn namespace_name(&self, ns: Namespace) -> Option<&str>
pub fn namespace_name(&self, ns: Namespace) -> Option<&str>
The localized name of a namespace this config defines (empty string for main).
Sourcepub fn ns_first_letter(&self, ns: Namespace) -> bool
pub fn ns_first_letter(&self, ns: Namespace) -> bool
Whether titles in ns are first-letter case-insensitive (true for unknown ids,
matching MediaWiki’s default).
Sourcepub fn resolve_magic_word(&self, alias: &str) -> Option<&str>
pub fn resolve_magic_word(&self, alias: &str) -> Option<&str>
Resolves a magic-word alias to its stable id, honoring per-word case sensitivity.
Sourcepub fn redirect_aliases(&self) -> &[String]
pub fn redirect_aliases(&self) -> &[String]
The accepted redirect keywords (#REDIRECT, #ПЕРЕНАПРАВЛЕНИЕ, …), folded.
Sourcepub fn ext_tag(&self, name: &str) -> Option<ExtTagContent>
pub fn ext_tag(&self, name: &str) -> Option<ExtTagContent>
How the given extension tag treats its body, if the tag is registered.
Lookup is case-insensitive (<NoWiki> works).
Sourcepub fn protocols(&self) -> &[String]
pub fn protocols(&self) -> &[String]
External-link protocols, longest first (so https:// wins over http:// — and
both over //).
Sourcepub fn trail_accepts(&self, c: char) -> bool
pub fn trail_accepts(&self, c: char) -> bool
Whether c may extend a link label past the closing brackets ([[dog]]s).
Sourcepub fn is_interwiki_prefix(&self, prefix: &str) -> bool
pub fn is_interwiki_prefix(&self, prefix: &str) -> bool
Whether prefix is a known interwiki prefix (case-insensitive).
Sourcepub fn magic_links(&self) -> MagicLinks
pub fn magic_links(&self) -> MagicLinks
The RFC/PMID/ISBN magic-link toggles.
Sourcepub fn lang_converter(&self) -> bool
pub fn lang_converter(&self) -> bool
Whether LanguageConverter markup (-{ … }-) is recognized on this wiki.
Sourcepub fn months(&self) -> &MonthNames
pub fn months(&self) -> &MonthNames
The localized month names (genitive/nominative/abbreviated) used by the signature-timestamp matcher.