From a1a4464304700c6ee38ee299d72c6d65fdab99d0 Mon Sep 17 00:00:00 2001 From: freamon Date: Sat, 6 Apr 2024 10:43:06 +0100 Subject: [PATCH] Avoid returning empty anchors in html --- app/utils.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/utils.py b/app/utils.py index 44d62329..d100c842 100644 --- a/app/utils.py +++ b/app/utils.py @@ -211,7 +211,9 @@ def allowlist_html(html: str) -> str: if tag.name == 'table': tag.attrs['class'] = 'table' - return str(soup) + # avoid returning empty anchors + re_empty_anchor = re.compile(r'<\/a>') + return re_empty_anchor.sub(r'\1', str(soup)) def markdown_to_html(markdown_text) -> str: