Remove safe_mode=True for Markdown2, as most things go straight through allowlist_html, and it mangles code in <code> blocks

This commit is contained in:
freamon 2024-09-21 20:12:21 +00:00
parent 5e2ec8f9d9
commit bdb201f4d3

View file

@ -310,7 +310,7 @@ def allowlist_html(html: str, a_target='_blank') -> str:
# this is for pyfedi's version of Markdown (differs from lemmy for: newlines for soft breaks, ...)
def markdown_to_html(markdown_text, anchors_new_tab=True) -> str:
if markdown_text:
raw_html = markdown2.markdown(markdown_text, safe_mode=True,
raw_html = markdown2.markdown(markdown_text,
extras={'middle-word-em': False, 'tables': True, 'fenced-code-blocks': True, 'strike': True, 'breaks': {'on_newline': True, 'on_backslash': True}})
return allowlist_html(raw_html, a_target='_blank' if anchors_new_tab else '')
else: