Coverage for markupmirror.markup.restructuredtext: 89%

# Coverage for markupmirror.markup.restructuredtext : 89%

## 18 statements 16 run 2 missing 0 excluded

Hot-keys on this page

r m x p toggle line displays

j k next/prev highlighted chunk

0 (zero) top of page

1 (one) first highlighted chunk

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | from django.utils.encoding import smart_str from django.utils.translation import ugettext_lazy as _ from markupmirror.markup.base import BaseMarkup from markupmirror.markup.base import register_markup class ReStructuredTextMarkup(BaseMarkup): """Markup transformer for `reStructuredText`_ content. .. _reStructuredText: http://docutils.sourceforge.net/rst.html """ codemirror_mode = 'text/x-rst' title = _(u"reStructuredText") def __init__(self): self.restructuredtext = publish_parts def convert(self, markup): parts = self.restructuredtext( source=smart_str(markup), writer_name='html4css1') # Intentionally return ``html_body`` instead of ``fragment`` as # Django's templatetag does. ``html_body`` also includes the document's # title and subtitle, and if the first parts of ``markup`` are # headlines (=== or ---), they would be stripped off the result # otherwise. return parts['html_body'] # Only register if docutils is installed try: from docutils.core import publish_parts register_markup(ReStructuredTextMarkup) except ImportError: pass __all__ = ('ReStructuredTextMarkup',)