Skip to content

Commit

Permalink
Fix markdown filter
Browse files Browse the repository at this point in the history
Not sure how this was working before hand, but it was broken. This
change is cribbed from wcivf, and seems to work locally now.
  • Loading branch information
GeoWill committed Apr 13, 2023
1 parent 2925365 commit f0fff2f
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 3 deletions.
1 change: 0 additions & 1 deletion polling_stations/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,6 @@
"rest_framework.authtoken",
"rest_framework_gis",
"django_extensions",
"markdown",
"corsheaders",
"pipeline",
"dc_signup_form",
Expand Down
2 changes: 1 addition & 1 deletion polling_stations/templates/election_explainers.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% load i18n %}
{% load markdown %}
{% load markdown_filter %}
{% if request.brand == 'democracyclub' %}
<div class="ds-card">
<div class="ds-card-body">>
Expand Down
3 changes: 2 additions & 1 deletion polling_stations/templates/fragments/cancelled_election.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{% load i18n_with_welsh markdown %}
{% load i18n_with_welsh %}
{% load markdown_filter %}
{% if cancelled_election.metadata.cancelled_election.title %}
<h2>{{ cancelled_election.metadata.cancelled_election.title }}</h2>
{% else %}
Expand Down
14 changes: 14 additions & 0 deletions polling_stations/templatetags/markdown_filter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from django import template
from django.utils.safestring import mark_safe

import markdown

register = template.Library()


@register.filter(name="markdown")
def markdown_filter(text):
return mark_safe(markdown.markdown(text))


markdown_filter.is_safe = True

0 comments on commit f0fff2f

Please sign in to comment.