sohaibafifi sohaibafifi - 3 months ago 10x
Python Question

limit Markdown in Django

I am using markdown on the comments system in my blog developed using django
I want to limit the possible format to accept just a basic one (with bold, italic, link and code)

How do I set Markdown to do this ?

if this is not possible using markdown so any alternatives ?
PS : i am using the default django app 'django.contrib.markup'

here is the actual code i am using on my template:

<div class="comment-content>
{% load markup %}
{{ comment.comment|markdown:"safe" }}


It would depend on which markdown plugin you're using there are many out there from a quick google search.

You'll have to either find documentation online for the specific one you are using, or perhaps look through the source and if it's open source modify it if you have to. Or just find another one that allows that functionality.

edit: Seems that django uses python-markdown(, from a quick look it doesn't seem to support specifying only specific formatting options. However it seems to be easily extensible, so if you write an extension you can use it in django like this:

{{ string|markdown:"extension_name,extension2,etc..." }}