Compare commits

...

1 Commits

Author SHA1 Message Date
François Leborne b6ace61f48 Add support for markdown images 2023-01-24 22:35:23 +01:00
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)