Better error handling in tag linkification
This commit is contained in:
parent
dc590b65ee
commit
c92c28b55a
|
@ -24,7 +24,10 @@ def relink_tags(value):
|
||||||
value = value.replace(''', "'")
|
value = value.replace(''', "'")
|
||||||
soup = BeautifulSoup(value, 'html.parser')
|
soup = BeautifulSoup(value, 'html.parser')
|
||||||
for link in soup.find_all('a', class_='hashtag'):
|
for link in soup.find_all('a', class_='hashtag'):
|
||||||
link['href'] = reverse('tag', args=[link.span.string])
|
try:
|
||||||
|
link['href'] = reverse('tag', args=[link.span.string])
|
||||||
|
except:
|
||||||
|
continue
|
||||||
return soup.decode(formatter='html')
|
return soup.decode(formatter='html')
|
||||||
|
|
||||||
@register.filter
|
@register.filter
|
||||||
|
@ -74,5 +77,5 @@ def fix_emojos(value, emojos):
|
||||||
value = value.replace(":%(shortcode)s:" % emojo,
|
value = value.replace(":%(shortcode)s:" % emojo,
|
||||||
'<img src="%(url)s" title=":%(shortcode)s:" alt=":%(shortcode)s:" class="emoji">' % emojo)
|
'<img src="%(url)s" title=":%(shortcode)s:" alt=":%(shortcode)s:" class="emoji">' % emojo)
|
||||||
except:
|
except:
|
||||||
pass
|
continue
|
||||||
return value
|
return value
|
||||||
|
|
Loading…
Reference in New Issue