Ignore mention links with no text

This commit is contained in:
miruka 2020-03-23 16:29:32 -04:00
parent 320a238dd2
commit bd53993b90

View File

@ -194,7 +194,8 @@ class HTMLProcessor:
return [ return [
(a_tag.text, href) (a_tag.text, href)
for a_tag, _, href, _ in lxml.html.iterlinks(html) for a_tag, _, href, _ in lxml.html.iterlinks(html)
if self.link_is_matrix_to_regex.match(unquote(href.strip())) if a_tag.text and
self.link_is_matrix_to_regex.match(unquote(href.strip()))
] ]
@ -458,7 +459,7 @@ class HTMLProcessor:
def _matrix_to_links_add_classes(self, el: HtmlElement) -> HtmlElement: def _matrix_to_links_add_classes(self, el: HtmlElement) -> HtmlElement:
href = el.attrib.get("href") href = el.attrib.get("href")
if not href: if not href or not el.text:
return el return el
if self.link_is_user_id_regex.match(href): if self.link_is_user_id_regex.match(href):