A jinja2 extension that adds a {% markdown %}
tag powered with PyMdown Extensions.
pip install jinja_markdown
jinja_env = Environment(extensions=['jinja_markdown.MarkdownExtension'])
or
from jinja_markdown import MarkdownExtension
jinja_env.add_extension(MarkdownExtension)
Then your templates can contain Markdown inside {% markdown %}
/ {% endmarkdown %}
block tags.
<article>
{% markdown %}
# Heading
Regular text
print("Hello world!")
{% endmarkdown %}
</article>
To avoid issues is recommended that you don't indent the markdown code inside the tag. If you prefer do it anyway, make sure the first line has the baseline indentation level.
<!-- Supported but not recommended -->
<article>
{% markdown %}
# Baseline of identation
Regular paragraph
This will be interpreted as code
</article>