jpsca / jinja-markdown

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

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

License:MIT License


Languages

Language:Python 88.6%Language:Makefile 11.4%