# Text::MediaWiki::Parser

A Perl port of [mwparserfromhell](https://github.com/earwig/mwparserfromhell)
(the MediaWiki Parser from Hell). It turns wikicode into a tree of nodes and
serialises that tree back to the original text byte for byte.

```perl
use Text::MediaWiki::Parser;

my $code = Text::MediaWiki::Parser::parse(
    "'''Foo''' is a [[bar]] with {{a|template}}."
);

for my $tpl ($code->filter_templates) {
    print $tpl->name->to_str, "\n";   # "a"
}

print $code->to_str;                  # identical to the input
```

## Status

Alpha. The tokenizer and builder are a direct transliteration of the Python
implementation.

The port was verified against `mwparserfromhell` 0.7.2 on 3676 real Gentoo Wiki
pages: for every page the token stream is byte-identical, `to_str` reproduces
the source byte for byte, and `strip_code` returns the same text as the
original. The bundled tests cover the same edge cases in miniature, because
the corpus itself is far too large to ship.

## License

MIT, the same terms as the original. See `LICENSE`: the copyright notice of
Ben Kurtovic applies to the ported code.
