From 4fa8d13af5059928ef17841849f8c0cd895b4363 Mon Sep 17 00:00:00 2001 From: rimu <3310831+rimu@users.noreply.github.com> Date: Mon, 18 Mar 2024 16:03:53 +1300 Subject: [PATCH] fenced code blocks --- app/utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/utils.py b/app/utils.py index 1832d1b6..4fbcd545 100644 --- a/app/utils.py +++ b/app/utils.py @@ -199,7 +199,7 @@ def allowlist_html(html: str) -> str: else: # Filter and sanitize attributes for attr in list(tag.attrs): - if attr not in ['href', 'src', 'alt']: + if attr not in ['href', 'src', 'alt', 'class']: del tag[attr] # Add nofollow and target=_blank to anchors if tag.name == 'a': @@ -251,7 +251,7 @@ def html_to_markdown_worker(element, indent_level=0): def markdown_to_html(markdown_text) -> str: if markdown_text: - return allowlist_html(markdown2.markdown(markdown_text, safe_mode=True, extras={'middle-word-em': False, 'tables': True})) + return allowlist_html(markdown2.markdown(markdown_text, safe_mode=True, extras={'middle-word-em': False, 'tables': True, 'fenced-code-blocks': True, 'spoiler': True})) else: return ''