From 3f6164384bfd12f173e5f38835ce8a5cfb8b282a Mon Sep 17 00:00:00 2001 From: Jan Szejko Date: Wed, 16 Mar 2016 10:22:15 +0100 Subject: [PATCH] images in epub/mobi --- librarian/epub.py | 8 +++++--- librarian/epub/xsltScheme.xsl | 18 ++++++++++++++++++ librarian/mobi.py | 4 ++-- 3 files changed, 25 insertions(+), 5 deletions(-) diff --git a/librarian/epub.py b/librarian/epub.py index 9e7010a..3b405f8 100644 --- a/librarian/epub.py +++ b/librarian/epub.py @@ -406,9 +406,8 @@ def transform_chunk(chunk_xml, chunk_no, annotations, empty=False, _empty_html_s return output_html, toc, chars -def transform(wldoc, verbose=False, - style=None, html_toc=False, - sample=None, cover=None, flags=None, hyphenate=False): +def transform(wldoc, verbose=False, style=None, html_toc=False, + sample=None, cover=None, flags=None, hyphenate=False, ilustr_path=''): """ produces a EPUB file sample=n: generate sample e-book (with at least n paragraphs) @@ -527,6 +526,9 @@ def transform(wldoc, verbose=False, functions.reg_mathml_epub(zip) + for filename in os.listdir(ilustr_path): + zip.write(os.path.join(ilustr_path, filename), os.path.join('OPS', filename)) + # write static elements mime = zipfile.ZipInfo() mime.filename = 'mimetype' diff --git a/librarian/epub/xsltScheme.xsl b/librarian/epub/xsltScheme.xsl index bcb3d70..1260073 100644 --- a/librarian/epub/xsltScheme.xsl +++ b/librarian/epub/xsltScheme.xsl @@ -73,6 +73,24 @@ + + + + + + + + + + + + + + + + + + diff --git a/librarian/mobi.py b/librarian/mobi.py index 61a6de1..65f2598 100644 --- a/librarian/mobi.py +++ b/librarian/mobi.py @@ -13,7 +13,7 @@ from librarian import OutputFile def transform(wldoc, verbose=False, sample=None, cover=None, - use_kindlegen=False, flags=None, hyphenate=True): + use_kindlegen=False, flags=None, hyphenate=True, ilustr_path=''): """ produces a MOBI file wldoc: a WLDocument @@ -27,7 +27,7 @@ def transform(wldoc, verbose=False, sample=None, cover=None, epub = document.as_epub(verbose=verbose, sample=sample, html_toc=True, cover=cover or True, flags=flags, - hyphenate=hyphenate) + hyphenate=hyphenate, ilustr_path=ilustr_path) if verbose: kwargs = {} else: -- 2.20.1