CommonMark -> commonmark rename
This commit is contained in:
parent
050540c355
commit
d38453c745
|
@ -1,4 +1,4 @@
|
||||||
import CommonMark, bleach
|
import commonmark, bleach
|
||||||
|
|
||||||
from django import template
|
from django import template
|
||||||
from django.utils.safestring import mark_safe
|
from django.utils.safestring import mark_safe
|
||||||
|
@ -10,18 +10,18 @@ register = template.Library()
|
||||||
@register.filter
|
@register.filter
|
||||||
@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."""
|
||||||
parser = CommonMark.Parser()
|
parser = commonmark.Parser()
|
||||||
renderer = CommonMark.HtmlRenderer()
|
renderer = commonmark.HtmlRenderer()
|
||||||
ast = parser.parse(value)
|
ast = parser.parse(value)
|
||||||
return mark_safe(renderer.render(ast))
|
return mark_safe(renderer.render(ast))
|
||||||
|
|
||||||
@register.filter
|
@register.filter
|
||||||
@stringfilter
|
@stringfilter
|
||||||
def untrustedcommonmark(value):
|
def untrustedcommonmark(value):
|
||||||
"""Returns HTML given some CommonMark Markdown. Cleans actual HTML from input using bleach, suitable for use with untrusted input."""
|
"""Returns HTML given some commonmark Markdown. Cleans actual HTML from input using bleach, suitable for use with untrusted input."""
|
||||||
parser = CommonMark.Parser()
|
parser = commonmark.Parser()
|
||||||
renderer = CommonMark.HtmlRenderer()
|
renderer = commonmark.HtmlRenderer()
|
||||||
ast = parser.parse(bleach.clean(value))
|
ast = parser.parse(bleach.clean(value))
|
||||||
return mark_safe(renderer.render(ast))
|
return mark_safe(renderer.render(ast))
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue