Render Markdown to HTML in Django templates

Viewed 7147

I would like to render Markdown to HTML so that I could simply write markdown inside my HTML templates.

Example: home.html:

#This is a simple markdown in HTML

And I would like Django to interpret my Markdown and display it as if it was HTML:

<h1> This is a simple markdown in HTML </h1>

What would be the easiest way to implement it?

1 Answers

In order to do this, one would need to create a template filter that converts the Markdown text into HTML for the template.

Fortunately this is a common task and there are multiple packages that can help you.

Django Package - For use with django

Python Markdown - Python Markdown that you can use within the custom Django template filter

Related