diff options
author | Ralph Amissah <ralph@amissah.com> | 2017-05-06 11:33:10 -0400 |
---|---|---|
committer | Ralph Amissah <ralph@amissah.com> | 2019-04-10 15:14:14 -0400 |
commit | 7a73aa10276b0c1151500d26b194336b56af7aba (patch) | |
tree | e267901f73375393cc429c5c17ce661216de111a /src/sdp/output_epub3.d | |
parent | xmls work particularly with epub output (diff) |
cleaningdoc-reform_v0.0.14
Diffstat (limited to 'src/sdp/output_epub3.d')
-rw-r--r-- | src/sdp/output_epub3.d | 50 |
1 files changed, 14 insertions, 36 deletions
diff --git a/src/sdp/output_epub3.d b/src/sdp/output_epub3.d index 074808c..56f9be3 100644 --- a/src/sdp/output_epub3.d +++ b/src/sdp/output_epub3.d @@ -346,10 +346,10 @@ template outputEPub3() { doc_epub3[segment_filename] ~= t[0]; doc_epub3_endnotes[segment_filename] ~= t[1]; break; - case 8: .. case 9: // unused numbers, if remain check + case 8: .. case 9: if ((doc_matters.opt_action_bool["debug"])) { writeln(__FILE__, ":", __LINE__, ": ", obj.is_a, ": ", obj.heading_lev_markup); - writeln(__FILE__, ":", __LINE__, ": ", obj.text); // check + writeln(__FILE__, ":", __LINE__, ": ", obj.text); } break; default: @@ -416,7 +416,7 @@ template outputEPub3() { doc_epub3[segment_filename] ~= to!string(t[0]); doc_epub3_endnotes[segment_filename] ~= t[1]; break; - case "poem": // double check why both poem & verse + case "poem": break; case "verse": auto t = xhtml_format.verse_seg(obj, _txt, suffix); @@ -606,26 +606,23 @@ template outputEPub3() { { /+ OEBPS/[segments].xhtml (the document contents) +/ foreach (seg_filename; doc_matters.segnames_lv_0_to_4) { string fn = pth_epub3.fn_oebps_content_xhtml(doc_matters.source_filename, seg_filename); - /+ add zip archive file members (with their content) +/ auto zip_arc_member_file = new ArchiveMember(); - // add seg fn to zip archive zip_arc_member_file.name = fn; auto zip_data = new OutBuffer(); debug(epub_output) { string fn_dbg = pth_epub3.dbg_fn_oebps_content_xhtml(doc_matters.source_filename, seg_filename); auto f = File(fn_dbg, "w"); } - /+ // f.writeln(seg_head); // not needed built and inserted earlier +/ foreach (docseg; doc_epub3[seg_filename]) { debug(epub_output) { f.writeln(docseg); } - zip_data.write(docseg.dup); // cast as: char[] + zip_data.write(docseg.dup); } foreach (docseg; doc_epub3_endnotes[seg_filename]) { debug(epub_output) { f.writeln(docseg); } - zip_data.write(docseg.dup); // cast as: char[] + zip_data.write(docseg.dup); } - debug(epub_output) { f.writeln(xhtml_format.tail); } // needed for each lev4 - zip_data.write(xhtml_format.tail.dup); // cast as: char[] + debug(epub_output) { f.writeln(xhtml_format.tail); } + zip_data.write(xhtml_format.tail.dup); zip_arc_member_file.expandedData = zip_data.toBytes(); zip.addMember(zip_arc_member_file); /+ create the zip file +/ @@ -641,15 +638,12 @@ template outputEPub3() { File(fn_dbg, "w").writeln(mimetypes); } fn = pth_epub3.fn_mimetypes(doc_matters.source_filename); - /+ add zip archive file members (with their content) +/ auto zip_arc_member_file = new ArchiveMember(); - // add mimetypes to zip archive zip_arc_member_file.name = fn; auto zip_data = new OutBuffer(); - zip_data.write(mimetypes.dup); // cast as: char[] + zip_data.write(mimetypes.dup); zip_arc_member_file.expandedData = zip_data.toBytes(); zip.addMember(zip_arc_member_file); - /+ create the zip file +/ createZipFile!()(fn_epub, zip.build()); } { /+ META-INF/container.xml (identify doc root) +/ @@ -658,15 +652,12 @@ template outputEPub3() { File(fn_dbg, "w").writeln(meta_inf_container_xml); } fn = pth_epub3.fn_dmi_container_xml(doc_matters.source_filename); - /+ add zip archive file members (with their content) +/ auto zip_arc_member_file = new ArchiveMember(); - // add META-INF/container.xml to zip archive zip_arc_member_file.name = fn; auto zip_data = new OutBuffer(); - zip_data.write(meta_inf_container_xml.dup); // cast as: char[] + zip_data.write(meta_inf_container_xml.dup); zip_arc_member_file.expandedData = zip_data.toBytes(); zip.addMember(zip_arc_member_file); - /+ create the zip file +/ createZipFile!()(fn_epub, zip.build()); } { /+ OEBPS/toc_nav.xhtml (navigation toc epub3) +/ @@ -675,15 +666,12 @@ template outputEPub3() { File(fn_dbg, "w").writeln(oebps_toc_nav_xhtml); } fn = pth_epub3.fn_oebps_toc_nav_xhtml(doc_matters.source_filename); - /+ add zip archive file members (with their content) +/ auto zip_arc_member_file = new ArchiveMember(); - // add OEBPS/toc_nav.xhtml to zip archive zip_arc_member_file.name = fn; auto zip_data = new OutBuffer(); - zip_data.write(oebps_toc_nav_xhtml.dup); // cast as: char[] + zip_data.write(oebps_toc_nav_xhtml.dup); zip_arc_member_file.expandedData = zip_data.toBytes(); zip.addMember(zip_arc_member_file); - /+ create the zip file +/ createZipFile!()(fn_epub, zip.build()); } { /+ OEBPS/toc.ncx (navigation toc epub2) +/ @@ -692,15 +680,12 @@ template outputEPub3() { File(fn_dbg, "w").writeln(oebps_toc_ncx); } fn = pth_epub3.fn_oebps_toc_ncx(doc_matters.source_filename); - /+ add zip archive file members (with their content) +/ auto zip_arc_member_file = new ArchiveMember(); - // add OEBPS/toc.ncx to zip archive zip_arc_member_file.name = fn; auto zip_data = new OutBuffer(); - zip_data.write(oebps_toc_ncx.dup); // cast as: char[] + zip_data.write(oebps_toc_ncx.dup); zip_arc_member_file.expandedData = zip_data.toBytes(); zip.addMember(zip_arc_member_file); - /+ create the zip file +/ createZipFile!()(fn_epub, zip.build()); } { /+ OEBPS/content.opf (doc manifest) +/ @@ -709,15 +694,12 @@ template outputEPub3() { File(fn_dbg, "w").writeln(oebps_content_opf); } fn = pth_epub3.fn_oebps_content_opf(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_data.write(oebps_content_opf.dup); zip_arc_member_file.expandedData = zip_data.toBytes(); zip.addMember(zip_arc_member_file); - /+ create the zip file +/ createZipFile!()(fn_epub, zip.build()); } { /+ OEBPS/_sisu/image (images) +/ @@ -760,15 +742,12 @@ template outputEPub3() { 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(css.epub_css.dup); // cast as: char[] + zip_data.write(css.epub_css.dup); zip_arc_member_file.expandedData = zip_data.toBytes(); zip.addMember(zip_arc_member_file); - /+ create the zip file +/ createZipFile!()(fn_epub, zip.build()); } } @@ -781,8 +760,7 @@ template outputEPub3() { auto zipped = new ZipArchive((fn_epub).read); foreach (filename, member; zipped.directory) { auto data = zipped.expand(member); - writeln(filename, " length ", data.length); // member.name - // Use data + writeln(filename, " length ", data.length); } } catch (ZipException ex) { |