]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/blob - plugins/rst
prettydate creates Last edited in the wee hours of Tuesday night, July 1st, 2009
[git.ikiwiki.info.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 # based a little bit on rst.pm by Sergio Talens-Oliag, but only a little bit. :)
7 #
8 # Copyright © martin f. krafft <madduck@madduck.net>
9 # Released under the terms of the GNU GPL version 2
10 #
11 __name__ = 'rst'
12 __description__ = 'xml-rpc-based ikiwiki plugin to process RST files'
13 __version__ = '0.3'
14 __author__ = 'martin f. krafft <madduck@madduck.net>'
15 __copyright__ = 'Copyright © ' + __author__
16 __licence__ = 'GPLv2'
18 from docutils.core import publish_parts;
19 from proxy import IkiWikiProcedureProxy
21 def rst2html(proxy, *kwargs):
22     # FIXME arguments should be treated as a hash, the order could change
23     # at any time and break this.
24     parts = publish_parts(kwargs[3], writer_name='html',
25                           settings_overrides = { 'halt_level': 6
26                                                , 'file_insertion_enabled': 0
27                                                , 'raw_enabled': 1
28                                                })
29     return '\n'.join(parts['html_body'].splitlines()[1:-1])
31 def getsetup(proxy, *kwargs):
32     return 'plugin', { 'safe' : 1, 'rebuild' : 1 }
34 import sys
35 def debug(s):
36     sys.stderr.write(__name__ + ':DEBUG:%s\n' % s)
37     sys.stderr.flush()
39 proxy = IkiWikiProcedureProxy(__name__, debug_fn=None)
40 proxy.hook('getsetup', getsetup)
41 proxy.hook('htmlize', rst2html)
42 proxy.run()