Skip to content

Commit ccfbde8

Browse files
committed
Fixed an issue with building links from URLs which are already part of a link. Fixes issue ietf-tools#2175.
- Legacy-Id: 12742
1 parent 0481d97 commit ccfbde8

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

ietf/doc/templatetags/ietf_filters.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,10 @@ def format_history_text(text, trunc_words=25):
428428

429429
@register.filter
430430
def format_snippet(text, trunc_words=25):
431-
full = keep_spacing(collapsebr(linebreaksbr(mark_safe(sanitize_html(urlize(text))))))
431+
# urlize if there aren't already links present
432+
if not 'href=' in text:
433+
text = urlize(text)
434+
full = keep_spacing(collapsebr(linebreaksbr(mark_safe(sanitize_html(text)))))
432435
snippet = truncatewords_html(full, trunc_words)
433436
if snippet != full:
434437
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))

0 commit comments

Comments
 (0)