skillfed

mwparserfromhell

MWParserFromHell is a parser for MediaWiki wikicode

mwparserfromhell v0.7.2 906.9K downloads/30d#4,757 on PyPI896
Permissive license MIT Active released

What it is and what it does

mwparserfromhell is a parser for MediaWiki wikicode that converts raw wiki markup into a queryable object model. It provides methods to extract templates, links, sections, and other wiki elements from page text, and allows you to modify them programmatically before converting back to plain wikitext. The parser includes a fast compiled C tokenizer for most platforms, with an automatic fallback to pure Python if compilation fails.

The package is designed for direct source-code analysis rather than HTML rendering, which means it works with the raw wikitext as written. It handles nested structures (templates within templates, for example) and provides filtering and matching methods that account for MediaWiki conventions like case-insensitive template names. Common use cases include bot automation, content analysis, and wiki page editing workflows.

Use it for:

  • Extract and analyze all templates from a Wikipedia article to audit template usage or gather metadata.
  • Modify template parameters programmatically in bulk wiki edits, such as updating deprecated template syntax across pages.
  • Parse wiki markup to identify links, categories, and sections for content extraction or validation tasks.
  • Build bots that read, analyze, and edit wiki pages by parsing the raw wikitext before and after modifications.
  • Validate or normalize wikicode structure without rendering to HTML, useful for linting or preprocessing workflows.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Parses MediaWiki wikicode into a queryable syntax tree, allowing you to extract, analyze, and modify templates, links, and other wiki markup elements programmatically.

Yes. The package is actively maintained, has no known vulnerabilities, supports current Python versions (3.9+), and offers prebuilt wheels for common platforms. MIT licensing is permissive. Install friction is moderate due to the C extension, but fallback to pure Python is automatic. Recommended for any project that needs to parse or manipulate MediaWiki wikitext.

Install

mwparserfromhell on PyPI

pip

pip install mwparserfromhell

uv

uv add mwparserfromhell

poetry

poetry add mwparserfromhell

Installing mwparserfromhell

Before you install

Medium install friction due to a compiled C tokenizer extension, but prebuilt wheels are available for common platforms (Linux x86_64 and arm64, macOS x86_64 and arm64, Windows x86 and x86_64). Falls back to pure-Python implementation if the C extension cannot be built. Active maintenance with recent commits.

License in practice

MIT license permits unrestricted use, modification, and distribution in both open-source and commercial projects with minimal restrictions.

Quickstart

pip install mwparserfromhell

import mwparserfromhell
wikicode = mwparserfromhell.parse("{{template|param=value}}")
templates = wikicode.filter_templates()
print(templates[0].name)

Requires Python 3.9 or later. If building from source and the C tokenizer extension fails to compile, set environment variable WITH_EXTENSION=0 to use the slower pure-Python fallback.

Verify before relying

  • Performance characteristics and parsing speed compared to pure-Python implementation when C extension is unavailable.
  • Exact scope of MediaWiki syntax variants and edge cases the parser handles beyond the documented limitations.

Package facts

License MIT (permissive)
Python support supports the current Python release (>=3.9)
Install friction medium — platform-specific wheel
Runtime dependencies none
Maintenance actively maintained — 409 days since the last release
Last repo commit
First released
Downloads 906,873/month — #4,757 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: mwparserfromhell-0.7.2-cp310-cp310-macosx_10_9_x86_64.whl; mwparserfromhell-0.7.2-cp310-cp310-macosx_11_0_arm64.whl; mwparserfromhell-0.7.2-cp310-cp310-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl; mwparserfromhell-0.7.2-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl; mwparserfromhell-0.7.2-cp310-cp310-musllinux_1_2_aarch64.whl; mwparserfromhell-0.7.2-cp310-cp310-musllinux_1_2_x86_64.whl; mwparserfromhell-0.7.2-cp310-cp310-win32.whl; mwparserfromhell-0.7.2-cp310-cp310-win_amd64.whl; mwparserfromhell-0.7.2-cp311-cp311-macosx_10_9_x86_64.whl; mwparserfromhell-0.7.2-cp311-cp311-macosx_11_0_arm64.whl; mwparserfromhell-0.7.2-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl; mwparserfromhell-0.7.2-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl; mwparserfromhell-0.7.2-cp311-cp311-musllinux_1_2_aarch64.whl; mwparserfromhell-0.7.2-cp311-cp311-musllinux_1_2_x86_64.whl; mwparserfromhell-0.7.2-cp311-cp311-win32.whl; mwparserfromhell-0.7.2-cp311-cp311-win_amd64.whl; mwparserfromhell-0.7.2-cp312-cp312-macosx_10_13_x86_64.whl; mwparserfromhell-0.7.2-cp312-cp312-macosx_11_0_arm64.whl; mwparserfromhell-0.7.2-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl; mwparserfromhell-0.7.2-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl

Keywords: mwparserfromhell, wikipedia, wiki, mediawiki, wikicode, wikitext

Development Status :: 4 - BetaEnvironment :: ConsoleIntended Audience :: DevelopersOperating System :: OS IndependentProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.9Topic :: Text Processing :: Markup

Tags

mediawiki parserwikicode parsingwikipedia text parsingwiki template extractionwikitext parsermediawiki syntax parserwiki markup parser
wiki-parsingmediawikiwikitext

More Markup packages