Usage¶
HTML¶
Load the template tags.
{% load markdowny_tags %}
Use the {% markdowny %} template tag to convert Markdown into HTML.
{% markdowny %}Hello, world!{% endmarkdowny %}
Or use it as a template filter.
{{ post.body|markdowny }}
Result:
<p>Hello, world!</p>
Customize with keyword arguments¶
Additionally customize the behavior of the {% markdowny %} tag with keyword arguments that correspond to all available options of Python Markdown’s Markdown class, such as extensions and output_format, as keyword arguments.
{% markdowny extensions='["abbr", "codehilite"]' output_format='xhtml1' lazy_ol='true' %}Hello, world!{% endmarkdowny %}
Because Django’s template language is not Python, template tags expect either a string or a number as a keyword argument. Therefore, in instances when Python Markdown’s Markdown constructor expects a Python data type, such as a string, number, boolean, or list, the value of the keyword argument should be the equivalent string or number. For example, pass 'true' as the equivalent of True or '[...]' as the equivalent of [...]. Numbers can be left as is. All keyword arguments are later coerced into Python data types.
See Python Markdown’s documentation on the Markdown class for all available keyword arguments.