1
0
mirror of https://gitlab.com/brutaldon/brutaldon.git synced 2024-12-04 14:46:24 -05:00

Better error handling in tag linkification

This commit is contained in:
Jason McBrayer 2018-09-05 05:21:02 -04:00
parent dc590b65ee
commit c92c28b55a

View File

@ -24,7 +24,10 @@ def relink_tags(value):
value = value.replace(''', "'")
soup = BeautifulSoup(value, 'html.parser')
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')
@register.filter
@ -74,5 +77,5 @@ def fix_emojos(value, emojos):
value = value.replace(":%(shortcode)s:" % emojo,
'<img src="%(url)s" title=":%(shortcode)s:" alt=":%(shortcode)s:" class="emoji">' % emojo)
except:
pass
continue
return value