html_rst_directive.py 631 B

12345678910111213141516171819202122232425262728293031
  1. # -*- coding: utf-8 -*-
  2. """
  3. HTML tags for reStructuredText
  4. ==============================
  5. This plugin allows you to use HTML tags from within reST documents.
  6. """
  7. from __future__ import unicode_literals
  8. from docutils import nodes
  9. from docutils.parsers.rst import directives, Directive
  10. class RawHtml(Directive):
  11. required_arguments = 0
  12. optional_arguments = 0
  13. final_argument_whitespace = True
  14. has_content = True
  15. def run(self):
  16. html = ' '.join(self.content)
  17. node = nodes.raw('', html, format='html')
  18. return [node]
  19. def register():
  20. directives.register_directive('html', RawHtml)