It would be best to use the MediaWiki parser. The good news is that MediaWiki 1.19 will provide a command line tool just for that!
Disclaimer: I wrote this tool.
The script is maintenance/parse.php
examples of use directly from the source code:
Entering the text yourself, ending it with Control + D:
$ php maintenance/parse.php --title foo ''[[foo]]''^D <p><i><strong class="selflink">foo</strong></i> </p> $
The usual way to enter files is:
$ echo "'''bold'''" > /tmp/foo.txt $ php maintenance/parse.php /tmp/foo.txt <p><b>bold</b> </p>$
And, of course, the pipeline to stdin:
$ cat /tmp/foo | php maintenance/parse.php <p><b>bold</b> </p>$
today you can get the script from http://svn.wikimedia.org/svnroot/mediawiki/trunk/phase3/maintenance/parse.php and put it in your service directory. It should work with MediaWiki 1.18
The script will be available in MediaWiki 1.19.0.
source share