From b6ace61f4884614036a38da26c718307a1b97234 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Leborne?= Date: Tue, 24 Jan 2023 22:35:23 +0100 Subject: [PATCH] Add support for markdown images --- ponyconf/utils.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ponyconf/utils.py b/ponyconf/utils.py index 151033b..1c6f8b0 100644 --- a/ponyconf/utils.py +++ b/ponyconf/utils.py @@ -16,6 +16,7 @@ class PonyConfModel(models.Model): def markdown_to_html(md): html = markdown(md) - allowed_tags = bleach.ALLOWED_TAGS + ['p', 'pre', 'span' ] + ['h%d' % i for i in range(1, 7) ] - html = bleach.clean(html, tags=allowed_tags) + allowed_tags = bleach.ALLOWED_TAGS + ['p', 'pre', 'span', 'img'] + ['h%d' % i for i in range(1, 7) ] + allowed_attributes = bleach.ALLOWED_ATTRIBUTES['img'] = ['src', 'alt'] + html = bleach.clean(html, tags=allowed_tags, attributes=allowed_attributes) return mark_safe(html)