From 772765b057570fd806633638d5481dad15e963e4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jan=20Bedna=C5=99=C3=ADk?= <jan.bednarik@gmail.com>
Date: Wed, 19 May 2021 17:08:52 +0200
Subject: [PATCH] elections2021: Strip sup on program list page

---
 .../elections2021/elections2021_program_page.html        | 4 ++--
 elections2021/templatetags/elections2021_extras.py       | 9 +++++++++
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/elections2021/templates/elections2021/elections2021_program_page.html b/elections2021/templates/elections2021/elections2021_program_page.html
index a06953d0..4e2993aa 100644
--- a/elections2021/templates/elections2021/elections2021_program_page.html
+++ b/elections2021/templates/elections2021/elections2021_program_page.html
@@ -1,5 +1,5 @@
 {% extends "elections2021/base.html" %}
-{% load static wagtailcore_tags wagtailimages_tags wagtailroutablepage_tags %}
+{% load static wagtailcore_tags wagtailimages_tags wagtailroutablepage_tags elections2021_extras %}
 
 {% block content_header %}
 
@@ -110,7 +110,7 @@
       <div class="card icon-card shadow-none bg-grey-125 card--hoveractive" data-archetype="{% if show_archetype_icon %}{{ point.archetype }}{% endif %}">
         <div class="card__body">
           <h1 class="card-headline mb-8"><a href="{% pageurl point %}">{{ point.title }}</a></h1>
-          <div class="card-body-text">{{ point.annotation|richtext }}</div>
+          <div class="card-body-text"><a href="{% pageurl point %}">{{ point.annotation|richtext|strip_sup }}</a></div>
         </div>
       </div>
 
diff --git a/elections2021/templatetags/elections2021_extras.py b/elections2021/templatetags/elections2021_extras.py
index 9f510afd..7a43be23 100644
--- a/elections2021/templatetags/elections2021_extras.py
+++ b/elections2021/templatetags/elections2021_extras.py
@@ -57,3 +57,12 @@ def format_sources(value):
     for sup in soup.find_all("sup"):
         sup.wrap(soup.new_tag("a", id="reference", href="#zdroje"))
     return str(soup)
+
+
+@register.filter(is_safe=True)
+@stringfilter
+def strip_sup(value):
+    soup = bs4.BeautifulSoup(value, "html.parser")
+    for sup in soup.find_all("sup"):
+        sup.decompose()
+    return str(soup)
-- 
GitLab