1 This is a whole lot better than nothing, but it's a shame it forks python
2 every page. Anyone want to get [this](http://search.cpan.org/~nodine/Text-Restructured-0.003016/) into Debian and use it instead?
5 Actually, if someone adds support for it to ikiwiki, I would be glad to get
6 the package into Debian myself --[[Joey]]
9 # Very simple reStructuredText processor.
11 # This plugin calls python and requires python-docutils to transform the text
14 # It's main problem is that it does not support ikiwiki's WikiLinks nor
15 # Preprocessor Directives (in fact the same problem applies to the current
16 # Wikitext processor, although in that case the output looks less worse ;)
18 # Probably Wikilinks and Preprocessor Directives should support a list of
19 # extensions to process (i.e. the linkify function could be transformed into
20 # reStructuredText instead of HTML using a hook on rst.py instead of the
21 # current linkify function)
23 # by Sergio Talens-Oliag <sto@debian.org>
25 package IkiWiki::Plugin::rst;
32 # Simple python script, maybe it should be implemented using an external script.
33 # The settings_overrides are given to avoid potential security risks when
34 # reading external files or if raw html is included on rst pages.
36 from docutils.core import publish_string;
37 from sys import stdin;
38 html = publish_string(stdin.read(), writer_name='html',
39 settings_overrides = { 'halt_level': 6,
40 'file_insertion_enabled': 0,
43 print html[html.find('<body>')+6:html.find('</body>')].strip();
47 IkiWiki::hook(type => "htmlize", id => "rst", call => \&htmlize);
50 sub htmlize ($) { #{{{
53 # Try to call python and run our command
54 open2(*IN, *OUT, "python", "-c", "$pyCmnd") or return $content;
56 # open2 doesn't respect "use open ':utf8'"
57 binmode (IN, ':utf8');
58 binmode (OUT, ':utf8');