Fixed an issue with building links from URLs which are already part of a link. Fixes issue .

- Legacy-Id: 12742
This commit is contained in:
Henrik Levkowetz 2017-01-26 20:11:46 +00:00
parent 0481d97650
commit ccfbde8d33

View file

@ -428,7 +428,10 @@ def format_history_text(text, trunc_words=25):
@register.filter
def format_snippet(text, trunc_words=25):
full = keep_spacing(collapsebr(linebreaksbr(mark_safe(sanitize_html(urlize(text))))))
# urlize if there aren't already links present
if not 'href=' in text:
text = urlize(text)
full = keep_spacing(collapsebr(linebreaksbr(mark_safe(sanitize_html(text)))))
snippet = truncatewords_html(full, trunc_words)
if snippet != full:
return mark_safe(u'<div class="snippet">%s<button class="btn btn-xs btn-default show-all"><span class="fa fa-caret-down"></span></button></div><div class="hidden full">%s</div>' % (snippet, full))