Convert MediaWiki wikitext format to HTML using command line

前端 未结 3 677
悲&欢浪女
悲&欢浪女 2021-02-06 00:26

I tend to write a good amount of documentation so the MediaWiki format to me is easy for me to understand plus it saves me a lot of time than having to write traditional HTML.

3条回答
  •  既然无缘
    2021-02-06 01:03

    The best would be to use MediaWiki parser. The good news is that MediaWiki 1.19 will provide a command line tool just for that!

    Disclaimer: I wrote that tool.

    The script is maintenance/parse.php some usage examples straight from the source code:

    Entering text yourself, ending it with Control + D:

    $ php maintenance/parse.php --title foo
    ''[[foo]]''^D
    

    foo

    $

    The usual file input method:

    $ echo "'''bold'''" > /tmp/foo.txt
    $ php maintenance/parse.php /tmp/foo.txt
    

    bold

    $

    And of course piping to stdin:

    $ cat /tmp/foo | php maintenance/parse.php
    

    bold

    $

    as of today you can get the script from http://svn.wikimedia.org/svnroot/mediawiki/trunk/phase3/maintenance/parse.php and place it in your maintenance directory. It should work with MediaWiki 1.18

    The script will be made available with MediaWiki 1.19.0.

提交回复
热议问题