Last active
August 8, 2016 03:40
-
-
Save Jwpe/fad38fd47679ff57f0d4 to your computer and use it in GitHub Desktop.
Markdown template filter in Django 1.5+
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django import template | |
import markdown | |
register = template.Library() | |
@register.filter | |
def markdownify(text): | |
# safe_mode governs how the function handles raw HTML | |
return markdown.markdown(text, safe_mode='escape') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% load markdown_filter %} | |
<html> | |
... | |
<div class="md-content"> | |
{{ my_markdown_content|markdownify|safe }} | |
</div> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment