Ticket #11708: rst.patch

File rst.patch, 1.2 KB (added by Chris.Wesseling@…, 15 years ago)
  • django/contrib/markup/templatetags/markup.py

     
    7676            return mark_safe(force_unicode(markdown.markdown(smart_str(value))))
    7777markdown.is_safe = True
    7878
    79 def restructuredtext(value):
     79def restructuredtext(value, arg='html4css1'):
     80    """
     81    Optionally pass the name of a module containing a Writer class as an argument.
     82    It will default to html4css1. See Docutils Hacker's Guide for documentation on Writers.
     83    """
    8084    try:
    8185        from docutils.core import publish_parts
    8286    except ImportError:
     
    8589        return force_unicode(value)
    8690    else:
    8791        docutils_settings = getattr(settings, "RESTRUCTUREDTEXT_FILTER_SETTINGS", {})
    88         parts = publish_parts(source=smart_str(value), writer_name="html4css1", settings_overrides=docutils_settings)
     92        parts = publish_parts(source=smart_str(value), writer_name=arg, settings_overrides=docutils_settings)
    8993        return mark_safe(force_unicode(parts["fragment"]))
    9094restructuredtext.is_safe = True
    9195
Back to Top