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.d66
1 files changed, 46 insertions, 20 deletions
diff --git a/src/sdp/output_epub.d b/src/sdp/output_epub.d
index ca11828..c66bf8f 100644
--- a/src/sdp/output_epub.d
+++ b/src/sdp/output_epub.d
@@ -17,9 +17,10 @@ template outputEPub() {
std.typecons,
std.uni,
std.utf,
- defaults;
+ std.conv : to;
import
- ao_rgx,
+ defaults,
+ output_rgx,
output_xhtmls;
mixin InternalMarkup;
mixin outputXHTMLs;
@@ -161,11 +162,12 @@ template outputEPub() {
auto return ref const D doc_abstraction,
auto return ref I doc_matters,
) {
- mixin SiSUrgxInit;
+ mixin SiSUoutputRgxInit;
auto xhtml_format = outputXHTMLs();
auto rgx = Rgx();
// string[] toc;
string[][string] doc_epub;
+ string[][string] doc_epub_endnotes;
string[] doc;
string segment_filename;
string[] top_level_headings = ["","","",""];
@@ -173,6 +175,7 @@ template outputEPub() {
auto meta_inf_container_xml = epub_container_xml;
auto oebps_toc_ncx = epub_oebps_toc(doc_abstraction, doc_matters);
auto oebps_content_opf = epub_oebps_content(doc_abstraction, doc_matters);
+ string suffix = ".xhtml";
foreach (part; doc_matters.keys_seq_seg) {
foreach (obj; doc_abstraction[part]) {
if (obj.is_a == "heading") {
@@ -199,7 +202,8 @@ template outputEPub() {
top_level_headings[3] = "";
goto default;
default:
- top_level_headings[obj.heading_lev_markup] = xhtml_format.heading(obj);
+ auto t = xhtml_format.heading_seg(obj, suffix);
+ top_level_headings[obj.heading_lev_markup] = t[0];
break;
}
break;
@@ -209,10 +213,14 @@ template outputEPub() {
foreach (top_level_heading; top_level_headings) {
doc_epub[segment_filename] ~= top_level_heading;
}
- doc_epub[segment_filename] ~= xhtml_format.heading(obj);
+ auto t = xhtml_format.heading_seg(obj, suffix);
+ doc_epub[segment_filename] ~= t[0];
+ doc_epub_endnotes[segment_filename] ~= t[1];
break;
case 5: .. case 7:
- doc_epub[segment_filename] ~= xhtml_format.heading(obj);
+ auto t = xhtml_format.heading_seg(obj, suffix);
+ doc_epub[segment_filename] ~= t[0];
+ doc_epub_endnotes[segment_filename] ~= t[1];
break;
case 8: .. case 9: // unused numbers, if remain check
if ((doc_matters.opt_action_bool["debug"])) {
@@ -254,7 +262,9 @@ template outputEPub() {
case "para":
switch (obj.is_a) {
case "para":
- doc_epub[segment_filename] ~= xhtml_format.para(obj);
+ auto t = xhtml_format.para_seg(obj, suffix);
+ doc_epub[segment_filename] ~= t[0];
+ doc_epub_endnotes[segment_filename] ~= t[1];
break;
default:
if ((doc_matters.opt_action_bool["debug"])) {
@@ -280,7 +290,9 @@ template outputEPub() {
doc_epub[segment_filename] ~= xhtml_format.nugget(obj);
break;
case "table":
- doc_epub[segment_filename] ~= xhtml_format.para(obj); //
+ auto t = xhtml_format.para_seg(obj, suffix);
+ doc_epub[segment_filename] ~= t[0];
+ doc_epub_endnotes[segment_filename] ~= t[1];
break;
case "code":
doc_epub[segment_filename] ~= xhtml_format.code(obj);
@@ -304,19 +316,28 @@ template outputEPub() {
case "para":
switch (obj.is_a) {
case "endnote":
- doc_epub[segment_filename] ~= xhtml_format.endnote(obj);
+ auto t = xhtml_format.para_seg(obj, suffix);
+ doc_epub[segment_filename] ~= t[0];
break;
case "glossary":
- doc_epub[segment_filename] ~= xhtml_format.para(obj);
+ auto t = xhtml_format.para_seg(obj, suffix);
+ doc_epub[segment_filename] ~= t[0];
+ doc_epub_endnotes[segment_filename] ~= t[1];
break;
case "bibliography":
- doc_epub[segment_filename] ~= xhtml_format.para(obj);
+ auto t = xhtml_format.para_seg(obj, suffix);
+ doc_epub[segment_filename] ~= t[0];
+ doc_epub_endnotes[segment_filename] ~= t[1];
break;
case "bookindex":
- doc_epub[segment_filename] ~= xhtml_format.para(obj);
+ auto t = xhtml_format.para_seg(obj, suffix);
+ doc_epub[segment_filename] ~= t[0];
+ doc_epub_endnotes[segment_filename] ~= t[1];
break;
case "blurb":
- doc_epub[segment_filename] ~= xhtml_format.para(obj);
+ auto t = xhtml_format.para_seg(obj, suffix);
+ doc_epub[segment_filename] ~= t[0];
+ doc_epub_endnotes[segment_filename] ~= t[1];
break;
default:
if ((doc_matters.opt_action_bool["debug"])) {
@@ -346,19 +367,21 @@ template outputEPub() {
epub_write_output_files(
doc_matters,
doc_epub,
+ doc_epub_endnotes,
mimetypes,
meta_inf_container_xml,
oebps_toc_ncx,
oebps_content_opf,
);
}
- void epub_write_output_files(C,EpD,Mt,Mic,Ot,Oc)(
- C doc_matters,
- EpD doc_epub,
- Mt mimetypes,
- Mic meta_inf_container_xml,
- Ot oebps_toc_ncx,
- Oc oebps_content_opf,
+ void epub_write_output_files(M,D,E,Mt,Mic,Ot,Oc)(
+ M doc_matters,
+ D doc_epub,
+ E doc_epub_endnotes,
+ Mt mimetypes,
+ Mic meta_inf_container_xml,
+ Ot oebps_toc_ncx,
+ Oc oebps_content_opf,
) {
debug(asserts){
static assert(is(typeof(doc_epub) == string[][string]));
@@ -387,6 +410,9 @@ template outputEPub() {
foreach (docseg; doc_epub[seg_filename]) {
f.writeln(docseg);
}
+ foreach (docseg; doc_epub_endnotes[seg_filename]) {
+ f.writeln(docseg);
+ }
f.writeln(xhtml_format.tail); // needed for each lev4
}
/+ mimetypes +/