From 09867864cbd4bdb6c947044ef56e018ff0222731 Mon Sep 17 00:00:00 2001 From: Flancian <0@flancia.org> Date: Fri, 22 Jan 2021 20:15:34 +0100 Subject: [PATCH] Fix lxml.etree.ParserError. --- app/db.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/db.py b/app/db.py index 5fca93c..3add96b 100644 --- a/app/db.py +++ b/app/db.py @@ -233,7 +233,11 @@ class Node: for subnode in self.subnodes: # I tried parsing the marko tree but honestly this seemed easier/simpler. html = render.markdown(subnode.content) - tree = lxml.html.fromstring(html) + try: + tree = lxml.html.fromstring(html) + except lxml.etree.ParserError: + continue + for link in tree.iterlinks(): # link is of the form (element, attribute, link, pos) -- see https://lxml.de/3.1/lxmlhtml.html. if link[2] == 'push':