Update markdown
This commit is contained in:
parent
2a0276d0fd
commit
8f95b070cd
2 changed files with 3 additions and 4 deletions
|
@ -17,6 +17,7 @@ EXTENSIONS = [
|
||||||
"markdown.extensions.def_list",
|
"markdown.extensions.def_list",
|
||||||
"markdown.extensions.tables",
|
"markdown.extensions.tables",
|
||||||
"markdown.extensions.admonition",
|
"markdown.extensions.admonition",
|
||||||
|
"nl2br",
|
||||||
]
|
]
|
||||||
|
|
||||||
ALLOWED_TAGS = bleach.sanitizer.ALLOWED_TAGS + [
|
ALLOWED_TAGS = bleach.sanitizer.ALLOWED_TAGS + [
|
||||||
|
@ -52,10 +53,8 @@ ALLOWED_ATTRS = ["src", "width", "height", "href", "class"]
|
||||||
|
|
||||||
|
|
||||||
@registry.filter
|
@registry.filter
|
||||||
def markdown(value, hard_wrap=False):
|
def markdown(value):
|
||||||
extensions = EXTENSIONS
|
extensions = EXTENSIONS
|
||||||
if hard_wrap:
|
|
||||||
extensions = EXTENSIONS + ["nl2br"]
|
|
||||||
html = _markdown.markdown(value, extensions=extensions)
|
html = _markdown.markdown(value, extensions=extensions)
|
||||||
html = bleach.clean(html, tags=ALLOWED_TAGS, attributes=ALLOWED_ATTRS)
|
html = bleach.clean(html, tags=ALLOWED_TAGS, attributes=ALLOWED_ATTRS)
|
||||||
if not html:
|
if not html:
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
</a>
|
</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<div class="message-text message-text-other">
|
<div class="message-text message-text-other">
|
||||||
{{message.body|markdown(hard_wrap=True)|reference|str|safe }}
|
{{message.body|markdown|reference|str|safe }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</span>
|
</span>
|
||||||
|
|
Loading…
Reference in a new issue