Fix lxml.etree.ParserError.

This commit is contained in:
Flancian 2021-01-22 20:15:34 +01:00
parent 82fd22b8e8
commit 09867864cb
1 changed files with 5 additions and 1 deletions

View File

@ -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':