From 4a2bdcdb496581cc83dd44e43639695b9e1f66b3 Mon Sep 17 00:00:00 2001 From: "Christopher T. Johnson" Date: Wed, 15 Nov 2023 22:05:00 -0500 Subject: [PATCH] Ignore Comment Nodes --- lib/books.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/books.py b/lib/books.py index 0109d8b..552bbf2 100644 --- a/lib/books.py +++ b/lib/books.py @@ -149,6 +149,8 @@ class Book: newelm.appendChild(newdom.createTextNode(text)) elif elm.localName == "img": pass + elif elm.nodeType == xml.dom.Node.COMMENT_NODE: + pass elif elm.localName == "a": a_node = cast(xml.dom.minidom.Element, elm.firstChild) while a_node: @@ -191,5 +193,9 @@ class Book: while node: parse_node(section, cast(xml.dom.minidom.Element, node)) node = node.nextSibling - self.sections.append(section.toxml()) + try: + self.sections.append(section.toxml()) + except Exception as e: + print(src, href) + raise e return