I'm working on a Django project in Python and using markdown2 to convert some markdown text into HTML but it appears to not be doing it well or I'm missing something in the code.
In my views.py file I'm using a custom function to extract some text from an .md file in markdown format and with the markdown2 module I try pass it on to the HTML template like so:
text = markdown2.markdown(util.get_entry(entry))
But in the HTML, if I inspect the source code what is supposed to render as
<h1>HTML</h1>
Am I missing something in my code? Is the error on the HTML template or in my views.py file?
Thanks in advance!
You probably have rendered the content in the template with:
{{ text }}
Django will by default escape the content, and thus replace <
with <
, etc.
You can make use of the |safe
template filter [Django-doc] to prevent this:
{{ text|safe }}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With