Add support for markdown images

This commit is contained in:
François Leborne 2023-01-24 22:35:23 +01:00
parent 9292862fe4
commit b6ace61f48
1 changed files with 3 additions and 2 deletions

View File

@ -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)