From 0133b7b7ee1bcde5cd63c48fdb0af25dfb1ffd00 Mon Sep 17 00:00:00 2001 From: ubq323 Date: Fri, 25 Jun 2021 19:37:09 +0000 Subject: allowify even more html tags --- apioforum/mdrender.py | 17 ++++++++++++++--- apioforum/static/style.css | 9 +++++++++ apioforum/templates/common.html | 2 +- 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/apioforum/mdrender.py b/apioforum/mdrender.py index 5f1192b..7dbbf6b 100644 --- a/apioforum/mdrender.py +++ b/apioforum/mdrender.py @@ -14,7 +14,11 @@ allowed_tags = [ 'mark', 'img', 'marquee', - 'pulsate' + 'pulsate', + 'sup','sub', + 'table','thead','tbody','tr','th','td', + 'details','summary', + ] allowed_tags += csscolors @@ -22,7 +26,9 @@ allowed_tags += ("mark" + c for c in csscolors) allowed_attributes = bleach.sanitizer.ALLOWED_ATTRIBUTES.copy() allowed_attributes.update( - img='src' + img=['src','alt','title'], + ol=['start'], + details=['open'], ) allowed_tags.extend(bleach.sanitizer.ALLOWED_TAGS) @@ -30,7 +36,12 @@ allowed_tags.extend(bleach.sanitizer.ALLOWED_TAGS) cleaner = bleach.sanitizer.Cleaner(tags=allowed_tags,attributes=allowed_attributes) import markdown -md = markdown.Markdown(extensions=['pymdownx.tilde','fenced_code']) +md = markdown.Markdown(extensions=[ + 'pymdownx.tilde', + 'fenced_code', + 'tables', + 'pymdownx.details', +]) def render(text): text = md.reset().convert(text) diff --git a/apioforum/static/style.css b/apioforum/static/style.css index bb57513..3815860 100644 --- a/apioforum/static/style.css +++ b/apioforum/static/style.css @@ -205,3 +205,12 @@ blockquote { padding: 1px 3px; border: 1px solid black; } + +.md table { + border: 1px solid grey; + border-collapse: collapse; +} +.md table td,.md table th { + border: 1px solid grey; + padding: 4px; +} diff --git a/apioforum/templates/common.html b/apioforum/templates/common.html index 9301a49..ff20644 100644 --- a/apioforum/templates/common.html +++ b/apioforum/templates/common.html @@ -26,7 +26,7 @@ #{{post.id}} -
+
{{ post.content|md|safe }}
-- cgit v1.2.3