Do commonmark and linkifying the same way with trusted as with untrusted.
This commit is contained in:
parent
eb07af9c39
commit
6d151b5519
|
@ -7,6 +7,7 @@ from django.template.defaultfilters import stringfilter
|
||||||
|
|
||||||
register = template.Library()
|
register = template.Library()
|
||||||
|
|
||||||
|
|
||||||
def parse_commonmark(value):
|
def parse_commonmark(value):
|
||||||
parser = commonmark.Parser()
|
parser = commonmark.Parser()
|
||||||
renderer = commonmark.HtmlRenderer()
|
renderer = commonmark.HtmlRenderer()
|
||||||
|
@ -18,8 +19,8 @@ def parse_commonmark(value):
|
||||||
@stringfilter
|
@stringfilter
|
||||||
def trustedcommonmark(value):
|
def trustedcommonmark(value):
|
||||||
"""Returns HTML given some commonmark Markdown. Also allows real HTML, so do not use this with untrusted input."""
|
"""Returns HTML given some commonmark Markdown. Also allows real HTML, so do not use this with untrusted input."""
|
||||||
linkified_value = bleach.linkify(value, parse_email=True)
|
markdown = parse_commonmark(value)
|
||||||
result = parse_commonmark(linkified_value)
|
result = bleach.linkify(markdown, parse_email=True)
|
||||||
return mark_safe(result)
|
return mark_safe(result)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue