From 0b542d0cbe6ab3bc6df1d3f29ffecfa15c14df5b Mon Sep 17 00:00:00 2001 From: Marcin Koziej Date: Mon, 3 Feb 2014 10:42:11 +0100 Subject: [PATCH] =?utf8?q?for=20epubs,=20we=20zip=20all=20resources=20into?= =?utf8?q?=20OPS,=20not=20preserving=20tree=20structure=20=E2=80=94=20flat?= =?utf8?q?tening=20of=20paths=20is=20needed?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- librarian/epub.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/librarian/epub.py b/librarian/epub.py index 8dc11c7..de136ea 100644 --- a/librarian/epub.py +++ b/librarian/epub.py @@ -330,6 +330,12 @@ def transform_chunk(chunk_xml, chunk_no, annotations, empty=False, _empty_html_s return output_html, toc, chars +def flatten_image_paths(wldoc): + root = wldoc.edoc.getroot() + for node in root.findall(".//ilustr"): + node.attrib['src'] = os.path.basename(node.attrib['src']) + return wldoc + def render_latex(wldoc, prefix="latex"): """ Renders CODE as images and returns @@ -398,6 +404,8 @@ def transform(wldoc, verbose=False, if main_text.tag == RDFNS('RDF'): main_text = None + flatten_image_paths(wldoc) + if main_text is not None: for chunk_xml in chop(main_text): empty = False -- 2.20.1