Generated: Wed 2012-04-11 05:19 CDT
Source file: /home/buechler/Sites/django-markupmirror/markupmirror/markup/restructuredtext.py
Stats: 12 executed, 0 missed, 8 excluded, 21 ignored
from django.utils.encoding import smart_strfrom django.utils.translation import ugettext_lazy as _from markupmirror import settingsfrom markupmirror.markup.base import BaseMarkupfrom markupmirror.markup.base import register_markupclass ReStructuredTextMarkup(BaseMarkup): """Markup transformer for reStructuredText content. """ codemirror_mode = 'text/x-rst' title = _(u"reStructuredText") def __init__(self): self.filter_settings = settings.RESTRUCTUREDTEXT_FILTER self.restructuredtext = publish_parts def convert(self, markup): parts = self.restructuredtext( source=smart_str(markup), writer_name='html4css1', settings_overrides=self.filter_settings) # 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 installedtry: from docutils.core import publish_parts register_markup(ReStructuredTextMarkup)except ImportError: pass__all__ = ('ReStructuredTextMarkup',)