2 # -*- coding: utf-8 -*-
4 # rst — xml-rpc-based ikiwiki plugin to process RST files
6 # based a little bit on rst.pm by Sergio Talens-Oliag, but only a little bit. :)
8 # Copyright © martin f. krafft <madduck@madduck.net>
10 # Redistribution and use in source and binary forms, with or without
11 # modification, are permitted provided that the following conditions
13 # 1. Redistributions of source code must retain the above copyright
14 # notice, this list of conditions and the following disclaimer.
15 # 2. Redistributions in binary form must reproduce the above copyright
16 # notice, this list of conditions and the following disclaimer in the
17 # documentation and/or other materials provided with the distribution.
19 # THIS SOFTWARE IS PROVIDED BY IKIWIKI AND CONTRIBUTORS ``AS IS''
20 # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
22 # PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION
23 # OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
26 # USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
27 # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28 # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
29 # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 __description__
= 'xml-rpc-based ikiwiki plugin to process RST files'
35 __author__
= 'martin f. krafft <madduck@madduck.net>'
36 __copyright__
= 'Copyright © ' + __author__
37 __licence__
= 'BSD-2-clause'
39 from docutils
.core
import publish_parts
;
40 from proxy
import IkiWikiProcedureProxy
42 def rst2html(proxy
, *args
):
43 kwargs
= _to_dict(args
)
44 parts
= publish_parts(kwargs
["content"],
46 settings_overrides
= { 'halt_level': 6
47 , 'file_insertion_enabled': 0
50 return '\n'.join(parts
['html_body'].splitlines()[1:-1])
53 # args is a list paired by key, value, so we turn it into a dict
54 return dict((k
, v
) for k
, v
in zip(*[iter(args
)]*2))
56 def getsetup(proxy
, *kwargs
):
57 return 'plugin', { 'safe' : 1, 'rebuild' : 1, 'section' : 'format' }
61 sys
.stderr
.write(__name__
+ ':DEBUG:%s\n' % s
)
64 proxy
= IkiWikiProcedureProxy(__name__
, debug_fn
=None)
65 proxy
.hook('getsetup', getsetup
)
66 proxy
.hook('htmlize', rst2html
)