diff --git a/util/html.py b/util/html.py
index b0e3d43..1d0a7fe 100644
--- a/util/html.py
+++ b/util/html.py
@@ -83,10 +83,10 @@ class HTMLToTokensParser(HTMLParser):
def handle_endtag(self, tag: str) -> None:
if self.invisible:
if tag == self.invisible:
- if self.invisible_depth == 0:
+ if self.invisible_depth <= 0:
self.invisible = None
else:
- self.invisible_depth = -1
+ self.invisible_depth -= 1
return
match tag: