Skip to content

A jinja2 `{% markdown %}` tag powered with PyMdown Extensions

License

Notifications You must be signed in to change notification settings

jpsca/jinja-markdown

Repository files navigation

Jinja-Markdown

Tests

A jinja2 extension that adds a {% markdown %} tag powered with PyMdown Extensions.

Installation

pip install jinja_markdown

Usage

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>

About indentation

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>

About

A jinja2 `{% markdown %}` tag powered with PyMdown Extensions

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published