I’ve been using Martor (https://github.com/agusmakmun/django-markdown-editor) as a markdown editor in my Django blog project. It’s not too bad, but I suspect there might be better ways to write markdown in a Django powered blog.
So my question is what do you use in your own projects for writing markdown in a Django application? Or perhaps you have a different way of writing and inputting markdown into your Django application?
It really depends on your needs – I usually use the Python markdown with bleach for sanitising the input to a list of restricted allowed tags. I combine those two into a template tag – shout-out to the pretix project, where I saw the practice first. You can see it here.
Cheers Rixx. Bleach looks very interesting and is something that I’ll check out.
What I’m really on the lookout for at this stage though is a nice editor for me to write my posts and articles in. Lot’s of sites have them, for example, Confluence and Jira, Stackoverflow, this site, but I can’t seem to find a highly recommend one that plugs into Django. I’m quite surprised by this, as I thought such a tool would be very popular. Of course, I could be missing something obvious.
Which workflow do you have for actually inputting the markdown into Django? Are you using the standard editor/textfield that comes with Django?
I combine the rendering done by bleach and markdown on finished texts with a simple side-by-side markdown editor. I built that one using JavaScript alone, so I had no need of any Django integration (and I’m not quite sure what such an integration would gain). I’m using marked.js because it is small and standalone, but there are really a lot of options out there. You just tie an event listener to the input field, and render its contents to the output element.
I know me typing this will bump up the post, but I think django-pagedown looks like a ‘proper’ markdown editor, and it was not mentioned before, and I think if you’d be in the market for such an editor you might want to find out about it.
Happy to hear any experiences with django-pagedown!
shout-out to the pretix project, where I saw the practice first. You can see it here.
Hey, rixx!
Just touching on this, but the usage of this in pretix project is really neat. Unfortunately in Django 5.0, django.utils.http.is_safe_url seems to have been deprecated.
The tag still works fine regardless, once you remove certain parts of it.
unsure: I think django.utils.http.url_has_allowed_host_and_scheme could possibly work in its place, but I’m a bit too unskilled to make that work.