summaryrefslogtreecommitdiff
path: root/plugins/rst
blob: c1f07e4cdb845b100ea8e2a781e8bec516cddb95 (plain)
  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. from docutils.core import publish_parts;
  21. from proxy import IkiWikiProcedureProxy
  22. def rst2html(*kwargs):
  23. # FIXME arguments should be treated as a hash, the order could change
  24. # at any time and break this.
  25. parts = publish_parts(kwargs[3], writer_name='html',
  26. settings_overrides = { 'halt_level': 6
  27. , 'file_insertion_enabled': 0
  28. , 'raw_enabled': 1
  29. })
  30. return '\n'.join(parts['html_body'].splitlines()[1:-1])
  31. import sys
  32. def debug(s):
  33. sys.stderr.write(__name__ + ':DEBUG:%s' % s)
  34. sys.stderr.flush()
  35. proxy = IkiWikiProcedureProxy(__name__, debug_fn=None)
  36. proxy.register_hook('htmlize', rst2html)
  37. proxy.run()