aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorubq323 <ubq323>2021-06-19 15:05:49 +0000
committerubq323 <ubq323>2021-06-19 15:05:49 +0000
commitd56b760f15b0a7cdfc6e9f49bc95cc3d3f2f445f (patch)
tree38f1003f67959ebfe130b9bf355ba0b93c48df65
parentac17795f8401411362249611e3b6967b20eb40f8 (diff)
enable images and fenced code blocks
-rw-r--r--apioforum/mdrender.py13
1 files 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)