[bugfix] Fix the wrong typesetting of the generated temporary files (#124)

This commit is contained in:
Brikarl 2023-03-09 14:48:37 +08:00 committed by GitHub
parent b25c4ca873
commit 83afab371c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -125,21 +125,16 @@ class EPUBBookLoader(BaseBookLoader):
raise Exception("can not load resume file") raise Exception("can not load resume file")
def _save_temp_book(self): def _save_temp_book(self):
origin_book_temp = epub.read_epub( origin_book_temp = epub.read_epub(self.epub_name)
self.epub_name
) # we need a new instance for temp save
new_temp_book = self._make_new_book(origin_book_temp) new_temp_book = self._make_new_book(origin_book_temp)
p_to_save_len = len(self.p_to_save) p_to_save_len = len(self.p_to_save)
trans_taglist = self.translate_tags.split(",")
index = 0 index = 0
try: try:
for item in self.origin_book.get_items(): for item in origin_book_temp.get_items():
if item.get_type() == ITEM_DOCUMENT: if item.get_type() == ITEM_DOCUMENT:
soup = ( soup = bs(item.content, "html.parser")
bs(item.content, "xml") p_list = soup.findAll(trans_taglist)
if item.file_name.endswith(".xhtml")
else bs(item.content, "html.parser")
)
p_list = soup.findAll("p")
for p in p_list: for p in p_list:
if not p.text or self._is_special_text(p.text): if not p.text or self._is_special_text(p.text):
continue continue