aboutsummaryrefslogtreecommitdiffhomepage
path: root/org/output_xmls.org
diff options
context:
space:
mode:
Diffstat (limited to 'org/output_xmls.org')
-rw-r--r--org/output_xmls.org153
1 files changed, 112 insertions, 41 deletions
diff --git a/org/output_xmls.org b/org/output_xmls.org
index 0cbde63..9a27bc7 100644
--- a/org/output_xmls.org
+++ b/org/output_xmls.org
@@ -416,6 +416,36 @@ auto tail() {
#+END_SRC
*** inline markup
+**** images
+
+#+name: xhtml_format_objects
+#+BEGIN_SRC d
+auto inline_images(O)(
+ auto return ref const O obj,
+ string _txt,
+ string _suffix = ".html",
+ string _xml_type = "seg",
+) {
+ string _img_pth;
+ if (_xml_type == "epub") {
+ _img_pth = "image/";
+ } else if (_xml_type == "scroll") {
+ _img_pth = "../../image/";
+ } else if (_xml_type == "seg") {
+ _img_pth = "../../../image/";
+ }
+ if (_txt.match(rgx.inline_image)) {
+ _txt = (_txt)
+ .replaceAll( // TODO bug where image dimensions (w or h) not given & consequently set to 0; should not be used (calculate earlier, abstraction)
+ rgx.inline_image,
+ ("$1<img src=\""
+ ~ _img_pth
+ ~ "$3\" width=\"$4\" height=\"$5\" naturalsizeflag=\"0\" align=\"bottom\" border=\"0\" /> $6"));
+ }
+ return _txt;
+}
+#+END_SRC
+
**** links
#+name: xhtml_format_objects
@@ -424,11 +454,11 @@ auto inline_links(O)(
auto return ref const O obj,
string _txt,
string _suffix = ".html",
- string seg_scroll = "seg",
+ string _xml_type = "seg",
) {
if (obj.inline_links) {
if ((_txt.match(rgx.mark_internal_site_lnk))
- && (seg_scroll == "scroll")) { // conditions reversed to avoid: gdc compiled program run segfault
+ && (_xml_type == "scroll")) { // conditions reversed to avoid: gdc compiled program run segfault
_txt = (_txt).replaceAll(
rgx.inline_seg_link,
"$1");
@@ -551,6 +581,7 @@ auto inline_markup_scroll(O)(
string _txt,
string _suffix = ".html",
) {
+ _txt = inline_images(obj, _txt, _suffix, "scroll");
_txt = inline_links(obj, _txt, _suffix, "scroll");
_txt = inline_notes_scroll(obj, _txt);
return _txt;
@@ -565,8 +596,10 @@ auto inline_markup_seg(O)(
auto return ref const O obj,
string _txt,
string _suffix = ".html",
+ string _xml_type = "seg",
) {
- _txt = inline_links(obj, _txt, _suffix, "seg");
+ _txt = inline_images(obj, _txt, _suffix, _xml_type);
+ _txt = inline_links(obj, _txt, _suffix, _xml_type);
auto t = inline_notes_seg(obj, _txt);
return t;
}
@@ -696,11 +729,11 @@ auto nav_pre_next_svg(O)(
auto heading(O)(
auto return ref const O obj,
string _txt,
- string _type="html",
+ string _xml_type = "html",
) {
auto tags = _xhtml_anchor_tags(obj.anchor_tags);
string _horizontal_rule = "<hr />";
- if ((_type != "html")
+ if ((_xml_type != "html")
|| (obj.heading_lev_markup == 0 || obj.heading_lev_markup > 4)) {
_horizontal_rule = "";
}
@@ -768,12 +801,12 @@ auto heading_seg(O)(
auto return ref const O obj,
string _txt,
string _suffix = ".html",
- string _type = "html",
+ string _xml_type = "html",
) {
- auto t = inline_markup_seg(obj, _txt, _suffix);
+ auto t = inline_markup_seg(obj, _txt, _suffix, _xml_type);
_txt = t[0];
string[] _endnotes = t[1];
- string o = heading(obj, _txt, _type);
+ string o = heading(obj, _txt, _xml_type);
auto u = tuple(
o,
_endnotes,
@@ -852,8 +885,9 @@ auto para_seg(O)(
auto return ref const O obj,
string _txt,
string _suffix = ".html",
+ string _xml_type = "html",
) {
- auto t = inline_markup_seg(obj, _txt, _suffix);
+ auto t = inline_markup_seg(obj, _txt, _suffix, _xml_type);
_txt = t[0].to!string;
string[] _endnotes = t[1];
string o = para(obj, _txt);
@@ -927,8 +961,9 @@ auto quote_seg(O)(
auto return ref const O obj,
string _txt,
string _suffix = ".html",
+ string _xml_type = "html",
) {
- auto t = inline_markup_seg(obj, _txt, _suffix);
+ auto t = inline_markup_seg(obj, _txt, _suffix, _xml_type);
_txt = t[0].to!string;
string[] _endnotes = t[1];
string o = quote(obj, _txt);
@@ -986,6 +1021,7 @@ auto group_scroll(O)(
auto return ref const O obj,
string _txt,
string _suffix = ".html",
+ string _xml_type = "html",
) {
auto tags = _xhtml_anchor_tags(obj.anchor_tags);
_txt = inline_markup_scroll(obj, _txt, _suffix);
@@ -1002,8 +1038,9 @@ auto group_seg(O)(
auto return ref const O obj,
string _txt,
string _suffix = ".html",
+ string _xml_type = "html",
) {
- auto t = inline_markup_seg(obj, _txt, _suffix);
+ auto t = inline_markup_seg(obj, _txt, _suffix, _xml_type);
_txt = t[0].to!string;
string[] _endnotes = t[1];
string o = group(obj, _txt);
@@ -1057,6 +1094,7 @@ auto block_scroll(O)(
auto return ref const O obj,
string _txt,
string _suffix = ".html",
+ string _xml_type = "html",
) {
auto tags = _xhtml_anchor_tags(obj.anchor_tags);
_txt = inline_markup_scroll(obj, _txt, _suffix);
@@ -1073,8 +1111,9 @@ auto block_seg(O)(
auto return ref const O obj,
string _txt,
string _suffix = ".html",
+ string _xml_type = "html",
) {
- auto t = inline_markup_seg(obj, _txt, _suffix);
+ auto t = inline_markup_seg(obj, _txt, _suffix, _xml_type);
_txt = t[0].to!string;
string[] _endnotes = t[1];
string o = block(obj, _txt);
@@ -1128,6 +1167,7 @@ auto verse_scroll(O)(
auto return ref const O obj,
string _txt,
string _suffix = ".html",
+ string _xml_type = "html",
) {
auto tags = _xhtml_anchor_tags(obj.anchor_tags);
_txt = inline_markup_scroll(obj, _txt, _suffix);
@@ -1144,8 +1184,9 @@ auto verse_seg(O)(
auto return ref const O obj,
string _txt,
string _suffix = ".html",
+ string _xml_type = "html",
) {
- auto t = inline_markup_seg(obj, _txt, _suffix);
+ auto t = inline_markup_seg(obj, _txt, _suffix, _xml_type);
_txt = t[0].to!string;
string[] _endnotes = t[1];
string o = verse(obj, _txt);
@@ -1304,6 +1345,7 @@ template outputHTML() {
<<output_html_scroll>>
<<output_html_seg>>
<<output_html_css>>
+ <<copy_html_images>>
}
#+END_SRC
@@ -1538,7 +1580,7 @@ void seg(D,I)(
top_level_headings[3] = "";
goto default;
default:
- auto t = xhtml_format.heading_seg(obj, _txt, suffix);
+ auto t = xhtml_format.heading_seg(obj, _txt, suffix, "seg");
top_level_headings[obj.heading_lev_markup] = t[0];
break;
}
@@ -1553,13 +1595,13 @@ void seg(D,I)(
// writeln(top_level_heading);
doc_html[segment_filename] ~= top_level_heading;
}
- auto t = xhtml_format.heading_seg(obj, _txt, suffix);
+ auto t = xhtml_format.heading_seg(obj, _txt, suffix, "seg");
doc_html[segment_filename] ~= t[0].to!string;
doc_html[segment_filename] ~= xhtml_format.lev4_heading_subtoc(obj);
doc_html_endnotes[segment_filename] ~= t[1];
break;
case 5: .. case 7:
- auto t = xhtml_format.heading_seg(obj, _txt, suffix);
+ auto t = xhtml_format.heading_seg(obj, _txt, suffix, "seg");
doc_html[segment_filename] ~= t[0].to!string;
doc_html_endnotes[segment_filename] ~= t[1];
break;
@@ -1583,7 +1625,7 @@ void seg(D,I)(
case "para":
switch (obj.is_a) {
case "toc":
- auto t = xhtml_format.para_seg(obj, _txt, suffix);
+ auto t = xhtml_format.para_seg(obj, _txt, suffix, "seg");
doc_html[segment_filename] ~= t[0].to!string;
break;
default:
@@ -1605,7 +1647,7 @@ void seg(D,I)(
case "para":
switch (obj.is_a) {
case "para":
- auto t = xhtml_format.para_seg(obj, _txt, suffix);
+ auto t = xhtml_format.para_seg(obj, _txt, suffix, "seg");
doc_html[segment_filename] ~= t[0].to!string;
doc_html_endnotes[segment_filename] ~= t[1];
break;
@@ -1619,24 +1661,24 @@ void seg(D,I)(
case "block":
switch (obj.is_a) {
case "quote":
- auto t = xhtml_format.quote_seg(obj, _txt, suffix);
+ auto t = xhtml_format.quote_seg(obj, _txt, suffix, "seg");
doc_html[segment_filename] ~= t[0].to!string;
doc_html_endnotes[segment_filename] ~= t[1];
break;
case "group":
- auto t = xhtml_format.group_seg(obj, _txt, suffix);
+ auto t = xhtml_format.group_seg(obj, _txt, suffix, "seg");
doc_html[segment_filename] ~= t[0].to!string;
doc_html_endnotes[segment_filename] ~= t[1];
break;
case "block":
- auto t = xhtml_format.block_seg(obj, _txt, suffix);
+ auto t = xhtml_format.block_seg(obj, _txt, suffix, "seg");
doc_html[segment_filename] ~= t[0].to!string;
doc_html_endnotes[segment_filename] ~= t[1];
break;
case "poem":
break;
case "verse":
- auto t = xhtml_format.verse_seg(obj, _txt, suffix);
+ auto t = xhtml_format.verse_seg(obj, _txt, suffix, "seg");
doc_html[segment_filename] ~= t[0].to!string;
doc_html_endnotes[segment_filename] ~= t[1];
break;
@@ -1667,26 +1709,26 @@ void seg(D,I)(
case "para":
switch (obj.is_a) {
case "endnote": assert(part == "endnotes");
- auto t = xhtml_format.para_seg(obj, _txt, suffix);
+ auto t = xhtml_format.para_seg(obj, _txt, suffix, "seg");
doc_html[segment_filename] ~= t[0];
break;
case "glossary": assert(part == "glossary");
- auto t = xhtml_format.para_seg(obj, _txt, suffix);
+ auto t = xhtml_format.para_seg(obj, _txt, suffix, "seg");
doc_html[segment_filename] ~= t[0];
doc_html_endnotes[segment_filename] ~= t[1];
break;
case "bibliography": assert(part == "bibliography");
- auto t = xhtml_format.para_seg(obj, _txt, suffix);
+ auto t = xhtml_format.para_seg(obj, _txt, suffix, "seg");
doc_html[segment_filename] ~= t[0];
doc_html_endnotes[segment_filename] ~= t[1];
break;
case "bookindex": assert(part == "bookindex_seg");
- auto t = xhtml_format.para_seg(obj, _txt, suffix);
+ auto t = xhtml_format.para_seg(obj, _txt, suffix, "seg");
doc_html[segment_filename] ~= t[0];
doc_html_endnotes[segment_filename] ~= t[1];
break;
case "blurb": assert(part == "blurb");
- auto t = xhtml_format.para_seg(obj, _txt, suffix);
+ auto t = xhtml_format.para_seg(obj, _txt, suffix, "seg");
doc_html[segment_filename] ~= t[0];
doc_html_endnotes[segment_filename] ~= t[1];
break;
@@ -1782,6 +1824,35 @@ void css(M)(
}
#+END_SRC
+** images :images:
+
+#+name: copy_html_images
+#+BEGIN_SRC d
+void images_cp(M)(
+ auto return ref M doc_matters,
+) {
+ { /+ (copy html images) +/
+
+ auto pth_html = SiSUpathsHTML!()(doc_matters.output_path, doc_matters.src.language);
+ if (!exists(pth_html.image)) {
+ pth_html.image.mkdirRecurse;
+ }
+ foreach (image; doc_matters.srcs.image_list) {
+ auto fn_src_in = doc_matters.src_path_info.src_image_root_with_path ~ "/" ~ image;
+ auto fn_src_out = pth_html.image ~ "/" ~ image;
+ debug(images_html) {
+ writeln(fn_src_in, " -> ", fn_src_out);
+ }
+ if (exists(fn_src_in)) {
+ fn_src_in.copy(fn_src_out);
+ } else {
+ writeln("WARNING image not found: ", fn_src_in);
+ }
+ }
+ }
+}
+#+END_SRC
+
* _epub_ [#B] :module:sdp:output_epub3:
|-----------------------+--------------------------+---------------------------+----------------------------------|
@@ -2228,7 +2299,7 @@ void outputEPub3(D,I)(
case "para":
switch (obj.is_a) {
case "toc":
- auto t = xhtml_format.para_seg(obj, _txt, suffix);
+ auto t = xhtml_format.para_seg(obj, _txt, suffix, "epub");
doc_epub3[segment_filename] ~= t[0];
doc_epub3_endnotes[segment_filename] ~= t[1];
break;
@@ -2251,7 +2322,7 @@ void outputEPub3(D,I)(
case "para":
switch (obj.is_a) {
case "para":
- auto t = xhtml_format.para_seg(obj, _txt, suffix);
+ auto t = xhtml_format.para_seg(obj, _txt, suffix, "epub");
doc_epub3[segment_filename] ~= t[0];
doc_epub3_endnotes[segment_filename] ~= t[1];
break;
@@ -2265,24 +2336,24 @@ void outputEPub3(D,I)(
case "block":
switch (obj.is_a) {
case "quote":
- auto t = xhtml_format.quote_seg(obj, _txt, suffix);
+ auto t = xhtml_format.quote_seg(obj, _txt, suffix, "epub");
doc_epub3[segment_filename] ~= t[0].to!string;
doc_epub3_endnotes[segment_filename] ~= t[1];
break;
case "group":
- auto t = xhtml_format.group_seg(obj, _txt, suffix);
+ auto t = xhtml_format.group_seg(obj, _txt, suffix, "epub");
doc_epub3[segment_filename] ~= t[0].to!string;
doc_epub3_endnotes[segment_filename] ~= t[1];
break;
case "block":
- auto t = xhtml_format.block_seg(obj, _txt, suffix);
+ auto t = xhtml_format.block_seg(obj, _txt, suffix, "epub");
doc_epub3[segment_filename] ~= t[0].to!string;
doc_epub3_endnotes[segment_filename] ~= t[1];
break;
case "poem":
break;
case "verse":
- auto t = xhtml_format.verse_seg(obj, _txt, suffix);
+ auto t = xhtml_format.verse_seg(obj, _txt, suffix, "epub");
doc_epub3[segment_filename] ~= t[0].to!string;
doc_epub3_endnotes[segment_filename] ~= t[1];
break;
@@ -2313,26 +2384,26 @@ void outputEPub3(D,I)(
case "para":
switch (obj.is_a) {
case "endnote": assert(part == "endnotes");
- auto t = xhtml_format.para_seg(obj, _txt, suffix);
+ auto t = xhtml_format.para_seg(obj, _txt, suffix, "epub");
doc_epub3[segment_filename] ~= t[0];
break;
case "glossary": assert(part == "glossary");
- auto t = xhtml_format.para_seg(obj, _txt, suffix);
+ auto t = xhtml_format.para_seg(obj, _txt, suffix, "epub");
doc_epub3[segment_filename] ~= t[0];
doc_epub3_endnotes[segment_filename] ~= t[1];
break;
case "bibliography": assert(part == "bibliography");
- auto t = xhtml_format.para_seg(obj, _txt, suffix);
+ auto t = xhtml_format.para_seg(obj, _txt, suffix, "epub");
doc_epub3[segment_filename] ~= t[0];
doc_epub3_endnotes[segment_filename] ~= t[1];
break;
case "bookindex": assert(part == "bookindex_seg");
- auto t = xhtml_format.para_seg(obj, _txt, suffix);
+ auto t = xhtml_format.para_seg(obj, _txt, suffix, "epub");
doc_epub3[segment_filename] ~= t[0];
doc_epub3_endnotes[segment_filename] ~= t[1];
break;
case "blurb": assert(part == "blurb");
- auto t = xhtml_format.para_seg(obj, _txt, suffix);
+ auto t = xhtml_format.para_seg(obj, _txt, suffix, "epub");
doc_epub3[segment_filename] ~= t[0];
doc_epub3_endnotes[segment_filename] ~= t[1];
break;
@@ -2582,13 +2653,13 @@ void epub3_write_output_files(M,D,E,Mt,Mic,Otnx,Otn,Oc)(
debug(epub_output) {
debug(epub_images) {
writeln(
- doc_matters.src_path_info.image_root, image, " -> ",
+ doc_matters.src_path_info.src_image_root_with_path, "/", image, " -> ",
pth_epub3.dbg_doc_oebps_image(doc_matters.src.filename), "/", image
);
}
}
- auto fn_src = doc_matters.src_path_info.image_root ~ image;
- auto fn_out = pth_epub3.doc_oebps_image(doc_matters.src.filename).to!string ~ "/" ~ image;
+ auto fn_src = doc_matters.src_path_info.src_image_root_with_path ~ "/" ~ image;
+ auto fn_out = pth_epub3.doc_oebps_image(doc_matters.src.filename.to!string) ~ "/" ~ image;
if (exists(fn_src)) {
{
auto zip_arc_member_file = new ArchiveMember();