12

我倾向于编写大量文档,因此 MediaWiki 格式对我来说很容易理解,而且与编写传统 HTML 相比,它为我节省了大量时间。然而,我也写了一篇博客,发现一直从键盘切换到鼠标以输入正确的 HTML 标签会增加很多时间。我希望能够以 Mediawiki 语法编写我的文章,然后将其转换为 HTML 以在我的博客上使用。

我已经尝试过 Google-ing,但必须需要更好的命名法,因为令人惊讶的是我找不到任何东西。

我使用 Linux,并且更愿意从命令行执行此操作。

任何人有任何想法或想法?

4

3 回答 3

14

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
<p><i><strong class="selflink">foo</strong></i>
</p>
$

The usual file input method:

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

And of course piping to stdin:

$ cat /tmp/foo | php maintenance/parse.php
<p><b>bold</b>
</p>$

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.

于 2012-03-04T23:16:59.240 回答
8

对此进行了一些研究,并认为在这里采取的一条好方法是学习通用标记语言,例如 restructuredtext 或 markdown,然后能够从那里进行转换。发现了一个名为pandoc的程序,可以将其中任何一个转换为 HTML 和 Mediawiki。感谢帮助。

例子:

pandoc -f mediawiki -s myfile.mediawiki  -o myfile.html -s
于 2012-02-25T09:55:26.760 回答
4

此页面列出了您可以尝试的大量 MediaWiki 解析器。

于 2012-02-18T18:31:49.053 回答