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