From bd53993b9055f4d36c5cac93cdd774468b32d5b8 Mon Sep 17 00:00:00 2001 From: miruka Date: Mon, 23 Mar 2020 16:29:32 -0400 Subject: [PATCH] Ignore mention links with no text --- src/backend/html_markdown.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/backend/html_markdown.py b/src/backend/html_markdown.py index fba588ec..4c252b00 100644 --- a/src/backend/html_markdown.py +++ b/src/backend/html_markdown.py @@ -194,7 +194,8 @@ class HTMLProcessor: return [ (a_tag.text, href) 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: href = el.attrib.get("href") - if not href: + if not href or not el.text: return el if self.link_is_user_id_regex.match(href):