Add markdown support for notes

This commit is contained in:
Maxime Bloch 2020-08-04 04:15:11 +02:00
parent 73b82ff771
commit 47897d4317
5 changed files with 18 additions and 1 deletions

View file

@ -0,0 +1,3 @@
from django import template
register = template.Library()

View file

@ -1,5 +1,7 @@
{% extends "base.html" %} {% extends "base.html" %}
{% load events_extras %}
{% block title %}Events{% endblock %} {% block title %}Events{% endblock %}
{% block content %} {% block content %}
@ -18,7 +20,7 @@
<p>Verantwoordelijke: {{ x.event.responsible_person.username }}</p> <p>Verantwoordelijke: {{ x.event.responsible_person.username }}</p>
{% if x.event.note %} {% if x.event.note %}
<p>Beschrijving: {{ x.event.note }}</p> <p>Beschrijving: {{ x.event.note|markdown_to_html }}</p>
{% endif %} {% endif %}
<ul> <ul>

View file

View file

@ -0,0 +1,11 @@
from django.utils.html import conditional_escape
from django.utils.safestring import mark_safe
from markdown import markdown
from events import register
@register.filter(name='markdown_to_html', needs_autoescape=False)
def markdown_to_html(value):
result = markdown(value)
return mark_safe(result)

View file

@ -10,6 +10,7 @@ django-timezone-field==4.0
future==0.18.2 future==0.18.2
idna==2.10 idna==2.10
kombu==4.6.11 kombu==4.6.11
markdown==3.2.2
mysqlclient==2.0.1 mysqlclient==2.0.1
python-crontab==2.5.1 python-crontab==2.5.1
python-dateutil==2.8.1 python-dateutil==2.8.1