Bump rst plugin version to 0.3
[ikiwiki.git] / plugins / rst
1 #!/usr/bin/python
2 # -*- coding: utf-8 -*-
3 #
4 # rst — xml-rpc-based ikiwiki plugin to process RST files
5 #
6 # TODO: the top of this file should be converted to a python library for
7 # ikiwiki plugins
8
9 # based a little bit on rst.pm by Sergio Talens-Oliag, but only a little bit. :)
10 #
11 # Copyright © martin f. krafft <madduck@madduck.net>
12 # Released under the terms of the GNU GPL version 2
13 #
14 __name__ = 'rst'
15 __description__ = 'xml-rpc-based ikiwiki plugin to process RST files'
16 __version__ = '0.3'
17 __author__ = 'martin f. krafft <madduck@madduck.net>'
18 __copyright__ = 'Copyright © ' + __author__
19 __licence__ = 'GPLv2'
20
21 from docutils.core import publish_parts;
22 from proxy import IkiWikiProcedureProxy
23
24 def rst2html(*kwargs):
25     # FIXME arguments should be treated as a hash, the order could change
26     # at any time and break this.
27     parts = publish_parts(kwargs[3], writer_name='html',
28                           settings_overrides = { 'halt_level': 6
29                                                , 'file_insertion_enabled': 0
30                                                , 'raw_enabled': 1
31                                                })
32     return '\n'.join(parts['html_body'].splitlines()[1:-1])
33
34 import sys
35 def debug(s):
36     sys.stderr.write(__name__ + ':DEBUG:%s' % s)
37     sys.stderr.flush()
38
39 proxy = IkiWikiProcedureProxy(__name__, debug_fn=None)
40 proxy.register_hook('htmlize', rst2html)
41 proxy.run()