From 1b8d7c0e911ee35c973bcc8eb51867249b217af1 Mon Sep 17 00:00:00 2001 From: lifegpc Date: Mon, 11 Mar 2024 18:02:21 +0800 Subject: [PATCH] Bug fix --- epub.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/epub.py b/epub.py index 9794052..8131fe5 100644 --- a/epub.py +++ b/epub.py @@ -209,6 +209,7 @@ class ContentParser(HTMLParser): self._paragraph_data = '' self.cfg = cfg self.footnote = '' + self.img_index = 0 def handle_data(self, data: str): if self._in_paragraph: @@ -265,7 +266,6 @@ class ContentParser(HTMLParser): root = self self.footnote = '' data = '' - img_index = 0 for i in data_list: if isinstance(i, str): if default_data_list: @@ -275,11 +275,11 @@ class ContentParser(HTMLParser): elif isinstance(i, HTMLImage): if i.is_valid(): try: - data += i.to_local(img_index) + data += i.to_local(root.img_index) self.images.append(i) if i.footnote: root.footnote += i.footnote - img_index += 1 + root.img_index += 1 except ValueError: print("the image is not valid.", i.src) elif isinstance(i, list):