From 9d171f94a491efdd68c9557c52914d48ccd33a28 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Wed, 26 Apr 2017 10:58:57 -0400 Subject: xml family css --- src/sdp/output_epub3.d | 45 ++++++++++++++++++++++++++++++++++----------- 1 file changed, 34 insertions(+), 11 deletions(-) (limited to 'src/sdp/output_epub3.d') diff --git a/src/sdp/output_epub3.d b/src/sdp/output_epub3.d index f16b25b..ea33f2e 100644 --- a/src/sdp/output_epub3.d +++ b/src/sdp/output_epub3.d @@ -25,7 +25,8 @@ template outputEPub3() { create_zip_file, defaults, output_rgx, - output_xhtmls, + output_xmls, + output_xmls_css, paths_output; mixin InternalMarkup; mixin outputXHTMLs; @@ -186,7 +187,7 @@ template outputEPub3() { %s%s - + @@ -303,7 +304,7 @@ template outputEPub3() { break; case 4: segment_filename = obj.segment_anchor_tag; - doc_epub3[segment_filename] ~= xhtml_format.seg_head(doc_matters.dochead_meta); + doc_epub3[segment_filename] ~= xhtml_format.epub3_seg_head(doc_matters.dochead_meta); foreach (top_level_heading; top_level_headings) { doc_epub3[segment_filename] ~= top_level_heading; } @@ -531,6 +532,7 @@ template outputEPub3() { Otn oebps_toc_ncx, Oc oebps_content_opf, ) { + auto css = SiSUcss(); debug(asserts) { static assert(is(typeof(doc_epub3) == string[][string])); static assert(is(typeof(mimetypes) == string)); @@ -682,17 +684,21 @@ template outputEPub3() { } { /+ OEBPS/_sisu/image (images) +/ foreach (image; doc_matters.image_list) { - if (exists(doc_matters.src_path_info.image_root ~ "/" ~ image)) { - (doc_matters.src_path_info.image_root ~ "/" ~ image) - .copy((pth_epub3.dbg_doc_oebps_image(doc_matters.source_filename)) ~ "/" ~ image); + debug(epub_output) { + if (exists(doc_matters.src_path_info.image_root ~ "/" ~ image)) { + (doc_matters.src_path_info.image_root ~ "/" ~ image) + .copy((pth_epub3.dbg_doc_oebps_image(doc_matters.source_filename)) ~ "/" ~ image); + } } } foreach (image; doc_matters.image_list) { - debug(epub_images) { - writeln( - doc_matters.src_path_info.image_root, image, " -> ", - pth_epub3.dbg_doc_oebps_image(doc_matters.source_filename), "/", image - ); + debug(epub_output) { + debug(epub_images) { + writeln( + doc_matters.src_path_info.image_root, image, " -> ", + pth_epub3.dbg_doc_oebps_image(doc_matters.source_filename), "/", image + ); + } } auto fn_src = doc_matters.src_path_info.image_root ~ image; auto fn_out = pth_epub3.doc_oebps_image(doc_matters.source_filename).to!string ~ "/" ~ image; @@ -709,6 +715,23 @@ template outputEPub3() { } } } + { /+ OEBPS/epub.css +/ + debug(epub_output) { + fn_dbg = pth_epub3.dbg_fn_oebps_css(doc_matters.source_filename); + File(fn_dbg, "w").writeln(css.epub_css); + } + fn = pth_epub3.fn_oebps_css(doc_matters.source_filename); + /+ add zip archive file members (with their content) +/ + auto zip_arc_member_file = new ArchiveMember(); + // add OEBPS/content.opf to zip archive + zip_arc_member_file.name = fn; + auto zip_data = new OutBuffer(); + zip_data.write(oebps_content_opf.dup); // cast as: char[] + zip_arc_member_file.expandedData = zip_data.toBytes(); + zip.addMember(zip_arc_member_file); + /+ create the zip file +/ + createZipFile!()(fn_epub, zip.build()); + } } catch (ErrnoException ex) { // Handle error -- cgit v1.2.3