working on village description escaping
This commit is contained in:
parent
14644b1b45
commit
fa6f168070
|
@ -1,17 +1,16 @@
|
|||
import CommonMark
|
||||
|
||||
from django import template
|
||||
from django.utils.encoding import force_text
|
||||
from django.utils.safestring import mark_safe
|
||||
from django.template.defaultfilters import stringfilter
|
||||
|
||||
register = template.Library()
|
||||
|
||||
|
||||
@register.filter(is_safe=True)
|
||||
@register.filter
|
||||
@stringfilter
|
||||
def commonmark(value):
|
||||
parser = CommonMark.Parser()
|
||||
renderer = CommonMark.HtmlRenderer()
|
||||
ast = parser.parse(force_text(value))
|
||||
return mark_safe(
|
||||
force_text(renderer.render(ast))
|
||||
)
|
||||
ast = parser.parse(value)
|
||||
return renderer.render(ast)
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ Village: {{ village.name }} | {{ block.super }}
|
|||
|
||||
<h3>{{ village.name }}</h3>
|
||||
|
||||
{{ village.description|commonmark }}
|
||||
{{ village.description|escape|commonmark }}
|
||||
|
||||
{% if user == village.contact %}
|
||||
<hr />
|
||||
|
|
|
@ -44,7 +44,7 @@ Villages | {{ block.super }}
|
|||
</a>
|
||||
</td>
|
||||
<td>
|
||||
{{ village.description|truncatewords:50|commonmark }}
|
||||
{{ village.description|commonmark|truncatewords:50 }}
|
||||
</td>
|
||||
<td>
|
||||
<i class="glyphicon glyphicon-{% if village.private %}remove{% else %}ok{% endif %}"></i>
|
||||
|
|
Loading…
Reference in a new issue