templatetags.django_docutils

Django template tag and filter for docutils (rendering reStructuredText as HTML).

class django_docutils.templatetags.django_docutils.ReStructuredTextNode(content, args=None, kwargs=None, asvar=None)[source]

Bases: Node

Implement the actions of the rst tag.

render(context=None)[source]

Render Node as string.

Return type:

str

exception django_docutils.templatetags.django_docutils.MalformedArgumentsToRSTTag(*args, **kwargs)[source]

Bases: TemplateSyntaxError

Invalid arguments to rst django template tag.

django_docutils.templatetags.django_docutils.rst(parser, token)[source]

Django template tag to render reStructuredText as HTML.

Supports arguments, see below.

Return type:

ReStructuredTextNode

Examples

{% rst content %}
{% rst content toc_only=True %}
{% rst content show_title=False %}
{% rst %}
**Hello world**
{% endrst %}

Render table of contents:

{% rst toc_only=True %}
Welcome to my site!
===================

My header
---------

Some text

Additional information
----------------------

Thank you
{% endrst %}
django_docutils.templatetags.django_docutils.rst_filter(value)[source]

Django template filter to render reStructuredText (rst) as HTML.

Return type:

str