From 55d8efbdcdedcf8505bcc83782ce165d27869a97 Mon Sep 17 00:00:00 2001 From: Jim Miller Date: Sun, 2 Nov 2025 09:49:51 -0600 Subject: [PATCH] writer_epub: Only do svg check for epub3 --- fanficfare/writers/writer_epub.py | 48 +++++++++++++++++-------------- 1 file changed, 26 insertions(+), 22 deletions(-) diff --git a/fanficfare/writers/writer_epub.py b/fanficfare/writers/writer_epub.py index 49b7baed..306c81f1 100644 --- a/fanficfare/writers/writer_epub.py +++ b/fanficfare/writers/writer_epub.py @@ -327,11 +327,6 @@ div { margin: 0pt; padding: 0pt; } return retval - ## in case it needs more complexity later. - def write_to_epub(self, outputepub, href, data): - outputepub.writestr(href,data) - self.svg_files[href] = b' tags marked. I # don't want to completely change how this writer operates. # So we'll flag as we go and generate content.opf later. Only # used with application/xhtml+xml files but currently set for all. - self.svg_files = {} # filename -> bool contains ' bool contains '|
)\n*',r'\1\n',fullhtml) # logger.debug("write OEBPS/file%s.xhtml"%chap['index04']) - self.write_to_epub(outputepub,"OEBPS/file%s.xhtml"%chap['index04'],fullhtml.encode('utf-8')) + write_to_epub("OEBPS/file%s.xhtml"%chap['index04'],fullhtml.encode('utf-8')) del fullhtml if self.story.calibrebookmark: - self.write_to_epub(outputepub,"META-INF/calibre_bookmarks.txt",self.story.calibrebookmark) + write_to_epub("META-INF/calibre_bookmarks.txt",self.story.calibrebookmark) manifest = contentdom.createElement("manifest") package.appendChild(manifest) @@ -790,7 +794,7 @@ div { margin: 0pt; padding: 0pt; } if id=='cover': ## Flag the cover *page*--epub3 only flags cover *img* props.append('calibre:title-page') - if type == 'application/xhtml+xml' and self.svg_files[href]: + if type == 'application/xhtml+xml' and svg_files[href]: ## epub3 wants content files containing tags ## flagged in the metadata. props.append('svg') @@ -825,7 +829,7 @@ div { margin: 0pt; padding: 0pt; } ensure_binary(''%coverimgid)) # write_to_epub used, but already passed using svg_files - self.write_to_epub(outputepub,"content.opf",contentxml) + write_to_epub("content.opf",contentxml) contentdom.unlink() del contentdom @@ -876,7 +880,7 @@ div { margin: 0pt; padding: 0pt; } index=index+1 # write_to_epub used, but already passed using svg_files - self.write_to_epub(outputepub,"toc.ncx",tocncxdom.toxml(encoding='utf-8')) + write_to_epub("toc.ncx",tocncxdom.toxml(encoding='utf-8')) tocncxdom.unlink() del tocncxdom @@ -937,7 +941,7 @@ div { margin: 0pt; padding: 0pt; } li.appendChild(atag) # write_to_epub used, but already passed using svg_files - self.write_to_epub(outputepub,"nav.xhtml",tocnavdom.toxml(encoding='utf-8')) + write_to_epub("nav.xhtml",tocnavdom.toxml(encoding='utf-8')) tocnavdom.unlink() del tocnavdom