From 2e070b5fa98cb7a5258fcf054f52d91a0ac96d61 Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Mon, 30 Dec 2019 13:48:06 -0800 Subject: [PATCH] Add step for normalizing the opf file specifically. --- epubfile.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/epubfile.py b/epubfile.py index 3910a9a..18035dc 100644 --- a/epubfile.py +++ b/epubfile.py @@ -1036,7 +1036,6 @@ class Epub: if ncx_id: self._set_ncx_toc(ncx_id, copy.copy(toc)) - def move_nav_to_end(self): ''' Move the nav.xhtml file to the end and set linear=no. @@ -1103,6 +1102,11 @@ class Epub: self.fix_interlinking_text(id, rename_map, old_relative_to=old_filepaths[id].parent) self.fix_interlinking_ncx(rename_map, old_relative_to=old_ncx_parent) + def normalize_opf(self): + for tag in self.opf.descendants: + if tag.name: + tag.name = tag.name.replace('opf:', '') + # COMMAND LINE TOOLS ################################################################################ @@ -1379,6 +1383,7 @@ def normalize_argparse(args): for epub in epubs: print(epub) book = Epub.open(epub) + book.normalize_opf() book.normalize_directory_structure() book.move_nav_to_end() book.save(epub)