aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/sdp/output_epub.d
diff options
context:
space:
mode:
Diffstat (limited to 'src/sdp/output_epub.d')
-rw-r--r--src/sdp/output_epub.d187
1 files changed, 111 insertions, 76 deletions
diff --git a/src/sdp/output_epub.d b/src/sdp/output_epub.d
index f914f16..f052d97 100644
--- a/src/sdp/output_epub.d
+++ b/src/sdp/output_epub.d
@@ -40,7 +40,7 @@ template outputEPub() {
</container>¶");
return o;
}
- string epub_oebps_content(C,M)(C contents, M doc_matters) {
+ string epub_oebps_content(D,I)(D doc_abstraction, I doc_matters) {
string uuid = "18275d951861c77f78acd05672c9906924c59f18a2e0ba06dad95959693e9bd8"; // TODO shared elsewhere
string content = format(q"¶<?xml version='1.0' encoding='utf-8'?>
<?xml version='1.0' encoding='utf-8'?>
@@ -75,12 +75,12 @@ template outputEPub() {
uuid,
);
foreach (sect; doc_matters.keys_seq_seg) {
- foreach (obj; contents[sect]) {
+ foreach (obj; doc_abstraction[sect]) {
}
}
return content;
}
- string epub_oebps_toc(C,M)(C contents, M doc_matters) {
+ string epub_oebps_toc(D,I)(D doc_abstraction, I doc_matters) {
int counter = 0;
string uuid = "18275d951861c77f78acd05672c9906924c59f18a2e0ba06dad95959693e9bd8"; // TODO shared elsewhere
auto markup = InlineMarkup();
@@ -113,7 +113,7 @@ template outputEPub() {
(doc_matters.dochead_meta["creator"]["author"].empty) ? "" : doc_matters.dochead_meta["creator"]["author"], // author
);
foreach (sect; doc_matters.keys_seq_seg) {
- foreach (obj; contents[sect]) {
+ foreach (obj; doc_abstraction[sect]) {
if (obj.is_a == "heading") {
foreach_reverse (k; 0 .. 7) {
switch (obj.dom_markedup[k]) {
@@ -157,9 +157,9 @@ template outputEPub() {
return toc;
}
- void outputEPub(C,T)(
- auto ref const C contents,
- auto ref T doc_matters,
+ void outputEPub(D,I)(
+ auto ref const D doc_abstraction,
+ auto ref I doc_matters,
) {
mixin SiSUrgxInit;
auto xhtml_format = outputXHTMLs();
@@ -171,10 +171,10 @@ template outputEPub() {
string[] top_level_headings = ["","","",""];
auto mimetypes = epub_mimetypes;
auto meta_inf_container_xml = epub_container_xml;
- auto oebps_toc_ncx = epub_oebps_toc(contents, doc_matters);
- auto oebps_content_opf = epub_oebps_content(contents, doc_matters);
+ auto oebps_toc_ncx = epub_oebps_toc(doc_abstraction, doc_matters);
+ auto oebps_content_opf = epub_oebps_content(doc_abstraction, doc_matters);
foreach (part; doc_matters.keys_seq_seg) {
- foreach (obj; contents[part]) {
+ foreach (obj; doc_abstraction[part]) {
if (obj.is_a == "heading") {
switch (obj.heading_lev_markup) {
case 0: .. case 3:
@@ -214,100 +214,129 @@ template outputEPub() {
case 5: .. case 7:
doc_epub[segment_filename] ~= xhtml_format.heading(obj);
break;
- default:
+ case 8: .. case 9: // unused numbers, if remain check
if ((doc_matters.opt_action_bool["debug"])) {
- writeln(__FILE__, ":", __LINE__, ": ", obj.is_a);
- }
- break;
- }
- } else if (obj.use == "frontmatter") {
- switch (obj.is_of) {
- case "para":
- switch (obj.is_a) {
- case "toc":
- doc_epub[segment_filename] ~= xhtml_format.toc(obj);
- break;
- default:
- // writeln(__FILE__, ":", __LINE__, ": ", obj.is_a);
- break;
+ writeln(__FILE__, ":", __LINE__, ": ", obj.is_a, ": ", obj.heading_lev_markup);
+ writeln(__FILE__, ":", __LINE__, ": ", obj.text); // check
}
break;
default:
- // writeln(__FILE__, ":", __LINE__, ": ", obj.is_a);
+ if ((doc_matters.opt_action_bool["debug"])) {
+ writeln(__FILE__, ":", __LINE__, ": ", obj.is_a, ": ", obj.heading_lev_markup);
+ }
break;
}
- } else if (obj.use == "body") {
- switch (obj.is_of) {
- case "para":
- switch (obj.is_a) {
+ } else {
+ switch (obj.use) {
+ case "frontmatter":
+ switch (obj.is_of) {
case "para":
- doc_epub[segment_filename] ~= xhtml_format.para(obj);
+ switch (obj.is_a) {
+ case "toc":
+ doc_epub[segment_filename] ~= xhtml_format.toc(obj);
+ break;
+ default:
+ if ((doc_matters.opt_action_bool["debug"])) {
+ writeln(__FILE__, ":", __LINE__, ": ", obj.is_a);
+ }
+ break;
+ }
break;
default:
- // writeln(__FILE__, ":", __LINE__, ": ", obj.is_a);
+ if ((doc_matters.opt_action_bool["debug"])) {
+ writeln(__FILE__, ":", __LINE__, ": ", obj.is_of);
+ }
break;
}
break;
- case "block":
- switch (obj.is_a) {
- case "poem": // double check why both poem & verse
- break;
- case "verse":
- doc_epub[segment_filename] ~= xhtml_format.nugget(obj);
- break;
- case "group":
- doc_epub[segment_filename] ~= xhtml_format.nugget(obj);
+ case "body":
+ switch (obj.is_of) {
+ case "para":
+ switch (obj.is_a) {
+ case "para":
+ doc_epub[segment_filename] ~= xhtml_format.para(obj);
+ break;
+ default:
+ if ((doc_matters.opt_action_bool["debug"])) {
+ writeln(__FILE__, ":", __LINE__, ": ", obj.is_a);
+ }
+ break;
+ }
break;
case "block":
- doc_epub[segment_filename] ~= xhtml_format.nugget(obj);
- break;
- case "quote":
- doc_epub[segment_filename] ~= xhtml_format.nugget(obj);
- break;
- case "table":
- doc_epub[segment_filename] ~= xhtml_format.para(obj); //
- break;
- case "code":
- doc_epub[segment_filename] ~= xhtml_format.code(obj);
+ switch (obj.is_a) {
+ case "poem": // double check why both poem & verse
+ break;
+ case "verse":
+ doc_epub[segment_filename] ~= xhtml_format.nugget(obj);
+ break;
+ case "group":
+ doc_epub[segment_filename] ~= xhtml_format.nugget(obj);
+ break;
+ case "block":
+ doc_epub[segment_filename] ~= xhtml_format.nugget(obj);
+ break;
+ case "quote":
+ doc_epub[segment_filename] ~= xhtml_format.nugget(obj);
+ break;
+ case "table":
+ doc_epub[segment_filename] ~= xhtml_format.para(obj); //
+ break;
+ case "code":
+ doc_epub[segment_filename] ~= xhtml_format.code(obj);
+ break;
+ default:
+ if ((doc_matters.opt_action_bool["debug"])) {
+ writeln(__FILE__, ":", __LINE__, ": ", obj.is_a);
+ }
+ break;
+ }
break;
default:
if ((doc_matters.opt_action_bool["debug"])) {
- writeln(__FILE__, ":", __LINE__, ": ", obj.is_a);
+ writeln(__FILE__, ":", __LINE__, ": ", obj.is_of);
}
break;
}
break;
- default:
- // writeln(__FILE__, ":", __LINE__, ": ", obj.is_of);
- break;
- }
- } else if (obj.use == "backmatter") {
- switch (obj.is_of) {
- case "para":
- switch (obj.is_a) {
- case "endnote":
- doc_epub[segment_filename] ~= xhtml_format.endnote(obj);
- break;
- case "glossary":
- doc_epub[segment_filename] ~= xhtml_format.para(obj);
- break;
- case "bibliography":
- doc_epub[segment_filename] ~= xhtml_format.para(obj);
- break;
- case "bookindex":
- doc_epub[segment_filename] ~= xhtml_format.para(obj);
- break;
- case "blurb":
- doc_epub[segment_filename] ~= xhtml_format.para(obj);
+ case "backmatter":
+ switch (obj.is_of) {
+ case "para":
+ switch (obj.is_a) {
+ case "endnote":
+ doc_epub[segment_filename] ~= xhtml_format.endnote(obj);
+ break;
+ case "glossary":
+ doc_epub[segment_filename] ~= xhtml_format.para(obj);
+ break;
+ case "bibliography":
+ doc_epub[segment_filename] ~= xhtml_format.para(obj);
+ break;
+ case "bookindex":
+ doc_epub[segment_filename] ~= xhtml_format.para(obj);
+ break;
+ case "blurb":
+ doc_epub[segment_filename] ~= xhtml_format.para(obj);
+ break;
+ default:
+ if ((doc_matters.opt_action_bool["debug"])) {
+ writeln(__FILE__, ":", __LINE__, ": ", obj.is_a);
+ }
+ break;
+ }
break;
default:
- // writeln(__FILE__, ":", __LINE__, ": ", obj.is_a);
+ if ((doc_matters.opt_action_bool["debug"])) {
+ writeln(__FILE__, ":", __LINE__, ": ", obj.is_of);
+ }
break;
}
break;
+ case "comment":
+ break;
default:
if ((doc_matters.opt_action_bool["debug"])) {
- writeln(__FILE__, ":", __LINE__, ": ", obj.is_a);
+ writeln(__FILE__, ":", __LINE__, ": ", obj.use);
}
break;
}
@@ -372,6 +401,12 @@ template outputEPub() {
/+ OEBPS/content.opf +/
f = File(pth_epub.fn_oebps_content_opf(doc_matters.source_filename), "w");
f.writeln(oebps_content_opf);
+ foreach (image; doc_matters.image_list) {
+ if (exists("_sisu/image/"~ image)) {
+ copy(("_sisu/image/"~ image),
+ ((pth_epub.doc_oebps_image(doc_matters.source_filename)) ~ "/" ~ image));
+ }
+ }
}
catch (ErrnoException ex) {
// Handle error