aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/sisudoc/io_out/epub3.d
diff options
context:
space:
mode:
Diffstat (limited to 'src/sisudoc/io_out/epub3.d')
-rw-r--r--src/sisudoc/io_out/epub3.d122
1 files changed, 59 insertions, 63 deletions
diff --git a/src/sisudoc/io_out/epub3.d b/src/sisudoc/io_out/epub3.d
index 8fd1cb5..610d6b8 100644
--- a/src/sisudoc/io_out/epub3.d
+++ b/src/sisudoc/io_out/epub3.d
@@ -95,10 +95,10 @@ template outputEPub3() {
</rootfiles>┃") ~ "\n</container>\n";
return o;
}
- string epub3_oebps_content(D,M,P)(D doc_abstraction, M doc_matters, P parts) {
+ string epub3_oebps_content(D,P)(D doc, P parts) {
auto xhtml_format = outputXHTMLs();
- auto pth_epub3 = spinePathsEPUB!()(doc_matters.output_path, doc_matters.src.language);
- string _uuid = "18275d951861c77f78acd05672c9906924c59f18a2e0ba06dad95959693e9bd8"; // TODO sort uuid in doc_matters!
+ auto pth_epub3 = spinePathsEPUB!()(doc.matters.output_path, doc.matters.src.language);
+ string _uuid = "18275d951861c77f78acd05672c9906924c59f18a2e0ba06dad95959693e9bd8"; // TODO sort uuid in doc.matters!
string content = format(q"┃<?xml version="1.0" encoding="utf-8"?>
<package version="3.0" xmlns="http://www.idpf.org/2007/opf" unique-identifier="uid" prefix="rendition: http://www.idpf.org/vocab/rendition/#">
<metadata
@@ -122,25 +122,25 @@ template outputEPub3() {
<item id="nav" href="toc_nav.xhtml" media-type="application/xhtml+xml" properties="nav" />
┃",
_uuid,
- xhtml_format.special_characters_text(doc_matters.conf_make_meta.meta.title_main),
- (doc_matters.conf_make_meta.meta.title_sub.empty)
- ? "" : xhtml_format.special_characters_text(doc_matters.conf_make_meta.meta.title_sub),
- (doc_matters.conf_make_meta.meta.creator_author.empty)
- ? "" : xhtml_format.special_characters_text(doc_matters.conf_make_meta.meta.creator_author),
- (doc_matters.conf_make_meta.meta.creator_author.empty)
- ? "" : xhtml_format.special_characters_text(doc_matters.conf_make_meta.meta.creator_author),
- doc_matters.src.language, // language, fix (needed in dochead metadata)
- (doc_matters.conf_make_meta.meta.date_published.empty)
- ? "" : xhtml_format.special_characters_date(doc_matters.conf_make_meta.meta.date_published),
- (doc_matters.conf_make_meta.meta.rights_copyright.empty)
- ? "" : xhtml_format.special_characters_text(doc_matters.conf_make_meta.meta.rights_copyright),
+ xhtml_format.special_characters_text(doc.matters.conf_make_meta.meta.title_main),
+ (doc.matters.conf_make_meta.meta.title_sub.empty)
+ ? "" : xhtml_format.special_characters_text(doc.matters.conf_make_meta.meta.title_sub),
+ (doc.matters.conf_make_meta.meta.creator_author.empty)
+ ? "" : xhtml_format.special_characters_text(doc.matters.conf_make_meta.meta.creator_author),
+ (doc.matters.conf_make_meta.meta.creator_author.empty)
+ ? "" : xhtml_format.special_characters_text(doc.matters.conf_make_meta.meta.creator_author),
+ doc.matters.src.language, // language, fix (needed in dochead metadata)
+ (doc.matters.conf_make_meta.meta.date_published.empty)
+ ? "" : xhtml_format.special_characters_date(doc.matters.conf_make_meta.meta.date_published),
+ (doc.matters.conf_make_meta.meta.rights_copyright.empty)
+ ? "" : xhtml_format.special_characters_text(doc.matters.conf_make_meta.meta.rights_copyright),
_uuid,
_uuid,
(pth_epub3.fn_oebps_css).chompPrefix("OEBPS/"),
);
content ~= parts["manifest_documents"];
// TODO sort jpg & png
- foreach (image; doc_matters.srcs.image_list) {
+ foreach (image; doc.matters.srcs.image_list) {
content ~= format(q"┃ <item id="%s" href="%s/%s" media-type="image/%s" />
┃",
image.baseName.stripExtension,
@@ -158,8 +158,8 @@ template outputEPub3() {
content ~= " " ~ "</guide>" ~ "\n ";
content ~= "" ~ "</package>";
debug(epubmanifest) {
- foreach (section; doc_matters.has.keys_seq.seg) { // TODO
- foreach (obj; doc_abstraction[section]) {
+ foreach (section; doc.matters.has.keys_seq.seg) { // TODO
+ foreach (obj; doc.abstraction[section]) {
if (obj.metainfo.is_a == "heading") {
if (obj.metainfo.heading_lev_markup == 4) {
writefln(
@@ -183,7 +183,7 @@ template outputEPub3() {
}
return content;
}
- string epub3_oebps_toc_nav_xhtml(D,I)(D doc_abstraction, I doc_matters) {
+ string epub3_oebps_toc_nav_xhtml(D)(D doc) {
enum DomTags { none, open, close, close_and_open, open_still, }
auto markup = InlineMarkup();
static auto rgx = RgxO();
@@ -202,12 +202,12 @@ template outputEPub3() {
</header>
<nav epub:type="toc" id="toc">
┃",
- (doc_matters.conf_make_meta.meta.title_full).special_characters_text,
+ (doc.matters.conf_make_meta.meta.title_full).special_characters_text,
);
string _toc_nav_tail = "";
- // writeln(doc_matters.has.keys_seq.seg); // DEBUG line
- foreach (sect; doc_matters.has.keys_seq.seg) {
- foreach (obj; doc_abstraction[sect]) {
+ // writeln(doc.matters.has.keys_seq.seg); // DEBUG line
+ foreach (sect; doc.matters.has.keys_seq.seg) {
+ foreach (obj; doc.abstraction[sect]) {
if ((sect == "head") && (obj.metainfo.is_a == "heading")) {
toc = toc_head;
}
@@ -263,7 +263,7 @@ template outputEPub3() {
}
break;
}
- if (doc_matters.has.keys_seq.seg[doc_matters.has.keys_seq.seg.length - 2] == sect) {
+ if (doc.matters.has.keys_seq.seg[doc.matters.has.keys_seq.seg.length - 2] == sect) {
// writeln(n, ": ", sect, ": ", _txt, " - ", obj.metainfo.dom_structure_collapsed_tags_status); // DEBUG
// read last heading (heading prior to closing) and determine what those instructions imply still need to be done
// CLOSE // DomTags { 0 none, 1 open, 2 close, 3 close_and_open, 4 open_still, }
@@ -296,16 +296,12 @@ template outputEPub3() {
toc ~= _toc_nav_tail;
return toc;
}
- @system void outputEPub3(D,I)(
- const D doc_abstraction,
- I doc_matters,
- ) {
+ @system void outputEPub3(D)(D doc) {
mixin spineRgxOut;
mixin spineRgxXHTML;
auto xhtml_format = outputXHTMLs();
static auto rgx = RgxO();
static auto rgx_xhtml = RgxXHTML();
- string[] doc;
string segment_filename;
string[] top_level_headings = ["","","",""];
string[string] oepbs_content_parts;
@@ -322,8 +318,8 @@ template outputEPub3() {
string[] doc_parts;
}
auto epubWrite = writeOut();
- foreach (section; doc_matters.has.keys_seq.seg) {
- foreach (obj; doc_abstraction[section]) {
+ foreach (section; doc.matters.has.keys_seq.seg) {
+ foreach (obj; doc.abstraction[section]) {
string _txt = xhtml_format.special_characters_breaks_indents_bullets(obj);
if (obj.metainfo.is_a == "heading") {
assert(section == "head" || "toc" || "body" || "endnotes" || "glossary" || "bibliography" || "bookindex" || "blurb" || "tail");
@@ -351,8 +347,8 @@ template outputEPub3() {
goto default;
default:
epubWrite.doc_parts ~= obj.tags.segment_anchor_tag_epub;
- epubWrite.doc_epub3[obj.tags.segment_anchor_tag_epub] ~= xhtml_format.epub3_seg_head(doc_matters);
- Tuple!(string, string[]) t = xhtml_format.heading_seg(_txt, obj, doc_matters, suffix, "epub");
+ epubWrite.doc_epub3[obj.tags.segment_anchor_tag_epub] ~= xhtml_format.epub3_seg_head(doc.matters);
+ Tuple!(string, string[]) t = xhtml_format.heading_seg(_txt, obj, doc.matters, suffix, "epub");
epubWrite.doc_epub3[obj.tags.segment_anchor_tag_epub] ~= t[0];
epubWrite.doc_epub3_endnotes[obj.tags.segment_anchor_tag_epub] ~= t[1];
break;
@@ -360,19 +356,19 @@ template outputEPub3() {
break;
case 4:
segment_filename = obj.tags.segment_anchor_tag_epub;
- epubWrite.doc_epub3[segment_filename] ~= xhtml_format.epub3_seg_head(doc_matters);
- Tuple!(string, string[]) t = xhtml_format.heading_seg(_txt, obj, doc_matters, suffix, "epub");
+ epubWrite.doc_epub3[segment_filename] ~= xhtml_format.epub3_seg_head(doc.matters);
+ Tuple!(string, string[]) t = xhtml_format.heading_seg(_txt, obj, doc.matters, suffix, "epub");
epubWrite.doc_epub3[segment_filename] ~= t[0];
epubWrite.doc_epub3_endnotes[segment_filename] ~= t[1];
break;
case 5: .. case 7:
- Tuple!(string, string[]) t = xhtml_format.heading_seg(_txt, obj, doc_matters, suffix, "epub");
+ Tuple!(string, string[]) t = xhtml_format.heading_seg(_txt, obj, doc.matters, suffix, "epub");
epubWrite.doc_epub3[segment_filename] ~= t[0];
epubWrite.doc_epub3_endnotes[segment_filename] ~= t[1];
break;
case 8: .. case 9:
{ /+ debug +/
- if (doc_matters.opt.action.debug_do_epub) {
+ if (doc.matters.opt.action.debug_do_epub) {
writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a, ": ", obj.metainfo.heading_lev_markup);
writeln(__FILE__, ":", __LINE__, ": ", obj.text);
}
@@ -380,7 +376,7 @@ template outputEPub3() {
break;
default:
{ /+ debug +/
- if (doc_matters.opt.action.debug_do_epub) {
+ if (doc.matters.opt.action.debug_do_epub) {
writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a, ": ", obj.metainfo.heading_lev_markup);
}
}
@@ -395,13 +391,13 @@ template outputEPub3() {
case "para":
switch (obj.metainfo.is_a) {
case "toc":
- t = xhtml_format.para_seg(_txt, obj, doc_matters, suffix, "epub");
+ t = xhtml_format.para_seg(_txt, obj, doc.matters, suffix, "epub");
epubWrite.doc_epub3[segment_filename] ~= t[0];
epubWrite.doc_epub3_endnotes[segment_filename] ~= t[1];
break;
default:
{ /+ debug +/
- if (doc_matters.opt.action.debug_do_epub) {
+ if (doc.matters.opt.action.debug_do_epub) {
writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a);
}
}
@@ -410,7 +406,7 @@ template outputEPub3() {
break;
default:
{ /+ debug +/
- if (doc_matters.opt.action.debug_do_epub) {
+ if (doc.matters.opt.action.debug_do_epub) {
writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_of_type);
}
}
@@ -422,13 +418,13 @@ template outputEPub3() {
case "para":
switch (obj.metainfo.is_a) {
case "para":
- t = xhtml_format.para_seg(_txt, obj, doc_matters, suffix, "epub");
+ t = xhtml_format.para_seg(_txt, obj, doc.matters, suffix, "epub");
epubWrite.doc_epub3[segment_filename] ~= t[0];
epubWrite.doc_epub3_endnotes[segment_filename] ~= t[1];
break;
default:
{ /+ debug +/
- if (doc_matters.opt.action.debug_do_epub) {
+ if (doc.matters.opt.action.debug_do_epub) {
writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a);
}
}
@@ -438,37 +434,37 @@ template outputEPub3() {
case "block":
switch (obj.metainfo.is_a) {
case "quote":
- t = xhtml_format.quote_seg(_txt, obj, doc_matters, suffix, "epub");
+ t = xhtml_format.quote_seg(_txt, obj, doc.matters, suffix, "epub");
epubWrite.doc_epub3[segment_filename] ~= t[0].to!string;
epubWrite.doc_epub3_endnotes[segment_filename] ~= t[1];
break;
case "group":
- t = xhtml_format.group_seg(_txt, obj, doc_matters, suffix, "epub");
+ t = xhtml_format.group_seg(_txt, obj, doc.matters, suffix, "epub");
epubWrite.doc_epub3[segment_filename] ~= t[0].to!string;
epubWrite.doc_epub3_endnotes[segment_filename] ~= t[1];
break;
case "block":
- t = xhtml_format.block_seg(_txt, obj, doc_matters, suffix, "epub");
+ t = xhtml_format.block_seg(_txt, obj, doc.matters, suffix, "epub");
epubWrite.doc_epub3[segment_filename] ~= t[0].to!string;
epubWrite.doc_epub3_endnotes[segment_filename] ~= t[1];
break;
case "poem":
break;
case "verse":
- t = xhtml_format.verse_seg(_txt, obj, doc_matters, suffix, "epub");
+ t = xhtml_format.verse_seg(_txt, obj, doc.matters, suffix, "epub");
epubWrite.doc_epub3[segment_filename] ~= t[0].to!string;
epubWrite.doc_epub3_endnotes[segment_filename] ~= t[1];
break;
case "code":
- epubWrite.doc_epub3[segment_filename] ~= xhtml_format.code(_txt, obj, doc_matters);
+ epubWrite.doc_epub3[segment_filename] ~= xhtml_format.code(_txt, obj, doc.matters);
break;
case "table":
- epubWrite.doc_epub3[segment_filename] ~= xhtml_format.table(_txt, obj, doc_matters);
+ epubWrite.doc_epub3[segment_filename] ~= xhtml_format.table(_txt, obj, doc.matters);
epubWrite.doc_epub3_endnotes[segment_filename] ~= "";
break;
default:
{ /+ debug +/
- if (doc_matters.opt.action.debug_do_epub) {
+ if (doc.matters.opt.action.debug_do_epub) {
writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a);
}
}
@@ -477,7 +473,7 @@ template outputEPub3() {
break;
default:
{ /+ debug +/
- if (doc_matters.opt.action.debug_do_epub) {
+ if (doc.matters.opt.action.debug_do_epub) {
writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_of_type);
}
}
@@ -490,37 +486,37 @@ template outputEPub3() {
case "para":
switch (obj.metainfo.is_a) {
case "endnote": assert(section == "endnotes");
- t = xhtml_format.para_seg(_txt, obj, doc_matters, suffix, "epub");
+ t = xhtml_format.para_seg(_txt, obj, doc.matters, suffix, "epub");
epubWrite.doc_epub3[segment_filename] ~= t[0];
break;
case "glossary": assert(section == "glossary");
- t = xhtml_format.para_seg(_txt, obj, doc_matters, suffix, "epub");
+ t = xhtml_format.para_seg(_txt, obj, doc.matters, suffix, "epub");
epubWrite.doc_epub3[segment_filename] ~= t[0];
epubWrite.doc_epub3_endnotes[segment_filename] ~= t[1];
break;
case "bibliography": assert(section == "bibliography");
- t = xhtml_format.para_seg(_txt, obj, doc_matters, suffix, "epub");
+ t = xhtml_format.para_seg(_txt, obj, doc.matters, suffix, "epub");
epubWrite.doc_epub3[segment_filename] ~= t[0];
epubWrite.doc_epub3_endnotes[segment_filename] ~= t[1];
break;
case "bookindex": assert(section == "bookindex");
- t = xhtml_format.para_seg(_txt, obj, doc_matters, suffix, "epub");
+ t = xhtml_format.para_seg(_txt, obj, doc.matters, suffix, "epub");
epubWrite.doc_epub3[segment_filename] ~= t[0];
epubWrite.doc_epub3_endnotes[segment_filename] ~= t[1];
break;
case "blurb": assert(section == "blurb");
- t = xhtml_format.para_seg(_txt, obj, doc_matters, suffix, "epub");
+ t = xhtml_format.para_seg(_txt, obj, doc.matters, suffix, "epub");
epubWrite.doc_epub3[segment_filename] ~= t[0];
epubWrite.doc_epub3_endnotes[segment_filename] ~= t[1];
break;
case "tail": assert(section == "tail");
- t = xhtml_format.para_seg(_txt, obj, doc_matters, suffix, "epub");
+ t = xhtml_format.para_seg(_txt, obj, doc.matters, suffix, "epub");
epubWrite.doc_epub3[segment_filename] ~= t[0];
epubWrite.doc_epub3_endnotes[segment_filename] ~= t[1];
break;
default:
{ /+ debug +/
- if (doc_matters.opt.action.debug_do_epub) {
+ if (doc.matters.opt.action.debug_do_epub) {
writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a);
}
}
@@ -529,7 +525,7 @@ template outputEPub3() {
break;
default:
{ /+ debug +/
- if (doc_matters.opt.action.debug_do_epub) {
+ if (doc.matters.opt.action.debug_do_epub) {
writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_of_type);
}
}
@@ -540,7 +536,7 @@ template outputEPub3() {
break;
default:
{ /+ debug +/
- if (doc_matters.opt.action.debug_do_epub) {
+ if (doc.matters.opt.action.debug_do_epub) {
writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_of_part);
}
}
@@ -597,9 +593,9 @@ template outputEPub3() {
/+ epub specific documents +/
epubWrite.mimetypes = epub3_mimetypes;
epubWrite.meta_inf_container_xml = epub3_container_xml;
- epubWrite.oebps_toc_nav_xhtml = doc_abstraction.epub3_oebps_toc_nav_xhtml(doc_matters);
- epubWrite.oebps_content_opf = doc_abstraction.epub3_oebps_content(doc_matters, oepbs_content_parts);
- epubWrite.epub3_write_output_files(doc_matters);
+ epubWrite.oebps_toc_nav_xhtml = doc.epub3_oebps_toc_nav_xhtml;
+ epubWrite.oebps_content_opf = doc.epub3_oebps_content(oepbs_content_parts);
+ epubWrite.epub3_write_output_files(doc.matters);
}
@system void epub3_write_output_files(W,M)(
W epub_write,