From d56b760f15b0a7cdfc6e9f49bc95cc3d3f2f445f Mon Sep 17 00:00:00 2001 From: ubq323 Date: Sat, 19 Jun 2021 15:05:49 +0000 Subject: enable images and fenced code blocks --- apioforum/mdrender.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/apioforum/mdrender.py b/apioforum/mdrender.py index 1df104f..5f5292d 100644 --- a/apioforum/mdrender.py +++ b/apioforum/mdrender.py @@ -10,14 +10,21 @@ allowed_tags = [ 'h6', 'pre', 'del', - 'mark' + 'mark', + 'img', ] + +allowed_attributes = bleach.sanitizer.ALLOWED_ATTRIBUTES.copy() +allowed_attributes.update( + img='src', +) + allowed_tags.extend(bleach.sanitizer.ALLOWED_TAGS) -cleaner = bleach.sanitizer.Cleaner(tags=allowed_tags) +cleaner = bleach.sanitizer.Cleaner(tags=allowed_tags,attributes=allowed_attributes) import markdown -md = markdown.Markdown(extensions=['pymdownx.tilde']) +md = markdown.Markdown(extensions=['pymdownx.tilde','fenced_code']) def render(text): text = md.reset().convert(text) -- cgit v1.2.3