rWikiText is a Rust library and command-line tool for converting MediaWiki wikitext to and from GitHub Flavored Markdown (GFM) and HTML.
Use it to move wiki documents into Markdown or HTML workflows, import documents into a wiki, or embed conversion in an application. The library returns converted content, structured page metadata, and diagnostics that identify conversion losses by byte range in the original input.
NamuMark (나무마크) is an additional planned input and output format for the first public release. Its parser and converters are not implemented yet. See the NamuMark scope and implementation plan.
Build from a source checkout with a current Rust toolchain, Cargo, and the linker for your Rust target. The Rust library and CLI run locally with caller-supplied wiki data. Check the native binding guide for the additional tools each binding requires. Native binding requirements
From the repository root, convert the supplied wikitext fixture to HTML.
cargo run --locked -- wikitext html tests/fixtures/paragraphs.wikiStandard output contains two <p> elements. The second contains Second paragraph & more.
The following describes the currently implemented MediaWiki conversions.
- Convert in both directions between wikitext and GFM or between wikitext and HTML. Each conversion takes wikitext as either its input or its output.
- Convert core document structure, including paragraphs, headings, links, emphasis, preformatted text, horizontal rules, lists, and tables. GFM uses native Markdown tables where possible and HTML for structures such as merged cells.
- Expand templates and supported core parser functions with explicit wiki context and caller-supplied data. HTML can carry Parsoid metadata that the importer validates to recover template calls and arguments.
- Return categories and their sort keys, redirects, and display titles as page metadata. Wikitext and HTML can carry these in the converted document. For GFM, the metadata is returned separately and diagnostics identify what saving the body alone would lose.
- Apply MediaWiki rules for elements, attributes, and URLs to embedded and imported HTML. Best-effort conversion reports losses and removals. Strict mode fails on conversion loss.
Compatibility is based on MediaWiki 1.46.2 and Parsoid HTML 2.8.0. Round-trip fidelity concerns rendered content, document structure, and page metadata. Equivalent wikitext can differ in spelling and whitespace. The first-release scope excludes MediaWiki extension tags and parser functions. See the verified cases and remaining differences in the compatibility baseline and parser case inventory.
Add a path dependency under [dependencies] in your application's Cargo.toml. This example assumes the rWikiText checkout is next to your application directory.
rwikitext = { path = "../rWikiText" }Put this in your application's src/main.rs and run cargo run from its root. It prints <p>Hello <b>wiki</b></p>.
use rwikitext::{convert, ConversionRequest, Format, WikiContext};
fn main() -> Result<(), rwikitext::ConversionError> {
let context = WikiContext::default();
let result = convert(ConversionRequest {
source: Format::Wikitext,
target: Format::Html,
input: "Hello '''wiki'''",
context: &context,
})?;
println!("{}", result.content);
Ok(())
}Use convert_with_mode with ConversionMode::Strict to reject conversion loss. Use convert_with_options to supply a WikiData implementation and adjust ExpansionLimits. The library calls back synchronously on the calling thread for template text, page existence, and file information. A lookup can return data, report missing data, or fail the conversion with a located diagnostic. Rust API · Callbacks and expansion limits
Pass the source and target formats as wikitext, gfm, or html. Omit the file path or use - to read standard input. The CLI writes converted content to standard output and diagnostics to standard error. Add --strict to exit with status 1 on conversion loss.
Use --wiki-data to load offline wiki lookups from a JSON file. The optional context, templates, pages, and files objects supply wiki context, template text, page-existence booleans, and file records with a URL and optional dimensions in pixels. Omit a lookup title or use null for missing data. Use an object with an error string to simulate a lookup failure. Example wiki data
--page-title, --site-language, and --reference-time override the corresponding JSON context fields. The defaults are an empty page title, en, and 1970-01-01T00:00:00Z.
From the repository root, expand a nested template using the example wiki data. The HTML renders example in bold and includes data-mw transclusion metadata.
echo "{{Outer|example}}" | cargo run --locked -- wikitext html - --wiki-data tests/fixtures/wiki-data.jsonThe version 1 C ABI exposes the same conversion core to C, Python, PHP, Java, Kotlin/Native, Node.js, and Go. The first-release verification matrix targets Linux x86-64 and ARM64 with glibc or musl. Kotlin/Native targets glibc in that matrix. The Go binding has its own build and verification instructions. Native binding build and callback examples · Target matrix · Go binding
The first public release and both Linux runtime checks are planned. glibc verification · musl verification · First public release
Run these commands from the repository root.
cargo build --locked
cargo test --lockedThe default suite exercises conversion, round trips, diagnostics, and wiki data callbacks through the Rust API and CLI. The full compatibility suite also uses a verified MediaWiki archive and a local PHP runtime. Full compatibility test instructions
The CLI and C ABI call the conversion pipeline in src/lib.rs. The pipeline parses input into internal document blocks, renders them in the target format, and returns the result with page metadata and diagnostics. For wikitext input it also expands templates and resolves links using the caller's wiki data. See the domain glossary and conversion design.
For contributions, follow the repository's issue, branch, and pull request workflow. Contributor and agent instructions · Work lifecycle
rWikiText's code is licensed under the MIT License. The supplied NamuWiki help snapshot is separately licensed under CC BY-NC-SA 2.0 KR; see third-party notices.