MediaWiki's original parser is a nasty pile of PHP and regex, but there's a new officially supported parser you can use called Parsoid. It's used extensively in production on Wikimedia sites and basically does MediaWiki wikitext to HTML roundtrip.
https://www.mediawiki.org/wiki/Parsoid
If I were parsing lots of MediaWiki wikitext, I'd put Parsoid at the top of the list as the rest seem incomplete or unsupported.