aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/sisudoc/io_out/html.d
diff options
context:
space:
mode:
Diffstat (limited to 'src/sisudoc/io_out/html.d')
-rw-r--r--src/sisudoc/io_out/html.d177
1 files changed, 83 insertions, 94 deletions
diff --git a/src/sisudoc/io_out/html.d b/src/sisudoc/io_out/html.d
index d9aaa58..5ca320c 100644
--- a/src/sisudoc/io_out/html.d
+++ b/src/sisudoc/io_out/html.d
@@ -6,7 +6,7 @@
- Author: Ralph Amissah
[ralph.amissah@gmail.com]
- - Copyright: (C) 2015 - 2024 Ralph Amissah, All Rights Reserved.
+ - Copyright: (C) 2015 - 2025 Ralph Amissah, All Rights Reserved.
- License: AGPL 3 or later:
@@ -50,36 +50,31 @@
module sisudoc.io_out.html;
@safe:
template outputHTML() {
- import
- std.file,
- std.outbuffer,
- std.uri,
- std.conv : to;
- import
- sisudoc.io_out,
- sisudoc.io_out.rgx,
- sisudoc.meta.rgx_files,
- sisudoc.io_out.rgx_xhtml,
- sisudoc.io_out.create_zip_file,
- sisudoc.io_out.xmls,
- sisudoc.io_out.xmls_css;
+ import std.file;
+ import std.outbuffer;
+ import std.uri;
+ import std.conv : to;
+ import sisudoc.io_out;
+ import sisudoc.io_out.rgx;
+ import sisudoc.meta.rgx_files;
+ import sisudoc.io_out.rgx_xhtml;
+ import sisudoc.io_out.create_zip_file;
+ import sisudoc.io_out.xmls;
+ import sisudoc.io_out.xmls_css;
mixin outputXHTMLs;
- void scroll(D,M)(
- const D doc_abstraction,
- M doc_matters,
- ) {
+ void scroll(D)(D doc) {
mixin spineRgxOut;
mixin spineRgxXHTML;
auto xhtml_format = outputXHTMLs();
static auto rgx = RgxO();
static auto rgx_xhtml = RgxXHTML();
string[] doc_html;
- string[] doc;
+ string[] doc_out;
string suffix = ".html";
string previous_section = "";
string delimit = "";
- foreach (section; doc_matters.has.keys_seq.scroll) {
- foreach (obj; doc_abstraction[section]) {
+ foreach (section; doc.matters.has.keys_seq.scroll) {
+ foreach (obj; doc.abstraction[section]) {
delimit = xhtml_format.div_delimit(section, previous_section);
string _txt = xhtml_format.special_characters_breaks_indents_bullets(obj);
switch (obj.metainfo.is_of_part) {
@@ -88,14 +83,14 @@ template outputHTML() {
case "para":
switch (obj.metainfo.is_a) {
case "heading":
- doc_html ~= delimit ~ xhtml_format.heading_scroll(_txt, obj, doc_matters, suffix);
+ doc_html ~= delimit ~ xhtml_format.heading_scroll(_txt, obj, doc.matters, suffix);
break;
case "toc":
- doc_html ~= xhtml_format.para_scroll(_txt, obj, doc_matters, suffix);
+ doc_html ~= xhtml_format.para_scroll(_txt, obj, doc.matters, suffix);
break;
default:
{ /+ debug +/
- if (doc_matters.opt.action.debug_do_html) {
+ if (doc.matters.opt.action.debug_do_html) {
writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a);
}
}
@@ -104,7 +99,7 @@ template outputHTML() {
break;
default:
{ /+ debug +/
- if (doc_matters.opt.action.debug_do_html) {
+ if (doc.matters.opt.action.debug_do_html) {
writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_of_type);
}
}
@@ -116,14 +111,14 @@ template outputHTML() {
case "para":
switch (obj.metainfo.is_a) {
case "heading":
- doc_html ~= delimit ~ xhtml_format.heading_scroll(_txt, obj, doc_matters, suffix);
+ doc_html ~= delimit ~ xhtml_format.heading_scroll(_txt, obj, doc.matters, suffix);
break;
case "para":
- doc_html ~= xhtml_format.para_scroll(_txt, obj, doc_matters, suffix);
+ doc_html ~= xhtml_format.para_scroll(_txt, obj, doc.matters, suffix);
break;
default:
{ /+ debug +/
- if (doc_matters.opt.action.debug_do_html) {
+ if (doc.matters.opt.action.debug_do_html) {
writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a);
}
}
@@ -133,28 +128,28 @@ template outputHTML() {
case "block":
switch (obj.metainfo.is_a) {
case "quote":
- doc_html ~= xhtml_format.quote_scroll(_txt, obj, doc_matters);
+ doc_html ~= xhtml_format.quote_scroll(_txt, obj, doc.matters);
break;
case "group":
- doc_html ~= xhtml_format.group_scroll(_txt, obj, doc_matters);
+ doc_html ~= xhtml_format.group_scroll(_txt, obj, doc.matters);
break;
case "block":
- doc_html ~= xhtml_format.block_scroll(_txt, obj, doc_matters);
+ doc_html ~= xhtml_format.block_scroll(_txt, obj, doc.matters);
break;
case "poem":
break;
case "verse":
- doc_html ~= xhtml_format.verse_scroll(_txt, obj, doc_matters, suffix);
+ doc_html ~= xhtml_format.verse_scroll(_txt, obj, doc.matters, suffix);
break;
case "code":
- doc_html ~= xhtml_format.code(_txt, obj, doc_matters);
+ doc_html ~= xhtml_format.code(_txt, obj, doc.matters);
break;
case "table":
- doc_html ~= xhtml_format.table(_txt, obj, doc_matters);
+ doc_html ~= xhtml_format.table(_txt, obj, doc.matters);
break;
default:
{ /+ debug +/
- if (doc_matters.opt.action.debug_do_html) {
+ if (doc.matters.opt.action.debug_do_html) {
writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a);
}
}
@@ -163,7 +158,7 @@ template outputHTML() {
break;
default:
{ /+ debug +/
- if (doc_matters.opt.action.debug_do_html) {
+ if (doc.matters.opt.action.debug_do_html) {
writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_of_type);
}
}
@@ -176,29 +171,29 @@ template outputHTML() {
case "para":
switch (obj.metainfo.is_a) {
case "heading":
- doc_html ~= delimit ~ xhtml_format.heading_scroll(_txt, obj, doc_matters, suffix);
+ doc_html ~= delimit ~ xhtml_format.heading_scroll(_txt, obj, doc.matters, suffix);
break;
case "endnote": assert(section == "endnotes");
- doc_html ~= xhtml_format.para_scroll(_txt, obj, doc_matters, suffix);
+ doc_html ~= xhtml_format.para_scroll(_txt, obj, doc.matters, suffix);
break;
case "glossary": assert(section == "glossary");
- doc_html ~= xhtml_format.para_scroll(_txt, obj, doc_matters, suffix);
+ doc_html ~= xhtml_format.para_scroll(_txt, obj, doc.matters, suffix);
break;
case "bibliography": assert(section == "bibliography");
- doc_html ~= xhtml_format.para_scroll(_txt, obj, doc_matters, suffix);
+ doc_html ~= xhtml_format.para_scroll(_txt, obj, doc.matters, suffix);
break;
case "bookindex": assert(section == "bookindex");
- doc_html ~= xhtml_format.para_scroll(_txt, obj, doc_matters, suffix);
+ doc_html ~= xhtml_format.para_scroll(_txt, obj, doc.matters, suffix);
break;
case "blurb": assert(section == "blurb");
- doc_html ~= xhtml_format.para_scroll(_txt, obj, doc_matters, suffix);
+ doc_html ~= xhtml_format.para_scroll(_txt, obj, doc.matters, suffix);
break;
case "tail": assert(section == "tail");
- doc_html ~= xhtml_format.para_scroll(_txt, obj, doc_matters, suffix);
+ doc_html ~= xhtml_format.para_scroll(_txt, obj, doc.matters, suffix);
break;
default:
{ /+ debug +/
- if (doc_matters.opt.action.debug_do_html) {
+ if (doc.matters.opt.action.debug_do_html) {
writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a);
}
}
@@ -207,7 +202,7 @@ template outputHTML() {
break;
default:
{ /+ debug +/
- if (doc_matters.opt.action.debug_do_html) {
+ if (doc.matters.opt.action.debug_do_html) {
writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_of_type);
}
}
@@ -218,7 +213,7 @@ template outputHTML() {
break;
default:
{ /+ debug +/
- if (doc_matters.opt.action.debug_do_html) {
+ if (doc.matters.opt.action.debug_do_html) {
writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_of_part);
writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a);
writeln(__FILE__, ":", __LINE__, ": ", obj.text);
@@ -228,18 +223,18 @@ template outputHTML() {
}
}
}
- doc = xhtml_format.html_head(doc_matters, "scroll")
+ doc_out = xhtml_format.html_head(doc.matters, "scroll")
~ doc_html
~ xhtml_format.dom_close
- ~ xhtml_format.tail(doc_matters);
- scroll_write_output(doc, doc_matters);
+ ~ xhtml_format.tail(doc.matters);
+ scroll_write_output(doc_out, doc.matters);
}
- @trusted void scroll_write_output(D,M)(
- D doc,
+ @trusted void scroll_write_output(O,M)(
+ O doc_out,
M doc_matters,
) {
debug(asserts) {
- static assert(is(typeof(doc) == string[]));
+ static assert(is(typeof(doc_out) == string[]));
}
auto pth_html = spinePathsHTML!()(doc_matters.output_path, doc_matters.src.language);
try {
@@ -248,7 +243,7 @@ template outputHTML() {
}
{
auto f = File(pth_html.fn_scroll(doc_matters.src.filename), "w");
- foreach (o; doc) {
+ foreach (o; doc_out) {
f.writeln(o);
}
}
@@ -271,10 +266,7 @@ template outputHTML() {
writeln(" ", pth_html.fn_scroll(doc_matters.src.filename));
}
}
- void seg(D,M)(
- const D doc_abstraction,
- M doc_matters,
- ) {
+ void seg(D)(D doc) {
mixin spineRgxOut;
mixin spineRgxXHTML;
static auto rgx = RgxO();
@@ -282,15 +274,14 @@ template outputHTML() {
auto xhtml_format = outputXHTMLs();
string[][string] doc_html;
string[][string] doc_html_endnotes;
- string[] doc;
string segment_filename;
string[] top_level_headings = ["","","",""];
string previous_seg_filename = "";
string suffix = ".html";
string previous_section = "";
string delimit = "";
- 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]) {
delimit = xhtml_format.div_delimit(section, previous_section);
string _txt = xhtml_format.special_characters_breaks_indents_bullets(obj);
if (obj.metainfo.is_a == "heading") {
@@ -318,33 +309,33 @@ template outputHTML() {
top_level_headings[3] = "";
goto default;
default:
- Tuple!(string, string[]) t = xhtml_format.heading_seg(_txt, obj, doc_matters, suffix, "seg");
+ Tuple!(string, string[]) t = xhtml_format.heading_seg(_txt, obj, doc.matters, suffix, "seg");
top_level_headings[obj.metainfo.heading_lev_markup] = t[0];
break;
}
break;
case 4:
segment_filename = obj.tags.segment_anchor_tag_epub;
- doc_html[segment_filename] ~= xhtml_format.html_head(doc_matters, "seg");
- auto navigation_bar = xhtml_format.nav_pre_next_svg(obj, doc_matters);
+ doc_html[segment_filename] ~= xhtml_format.html_head(doc.matters, "seg");
+ auto navigation_bar = xhtml_format.nav_pre_next_svg(obj, doc.matters);
doc_html[segment_filename] ~= navigation_bar.toc_pre_next;
previous_seg_filename = segment_filename;
foreach (top_level_heading; top_level_headings) {
doc_html[segment_filename] ~= top_level_heading;
}
- Tuple!(string, string[]) t = xhtml_format.heading_seg(_txt, obj, doc_matters, suffix, "seg");
+ Tuple!(string, string[]) t = xhtml_format.heading_seg(_txt, obj, doc.matters, suffix, "seg");
doc_html[segment_filename] ~= t[0].to!string;
- doc_html[segment_filename] ~= xhtml_format.lev4_heading_subtoc(obj, doc_matters);
+ doc_html[segment_filename] ~= xhtml_format.lev4_heading_subtoc(obj, doc.matters);
doc_html_endnotes[segment_filename] ~= t[1];
break;
case 5: .. case 7:
- Tuple!(string, string[]) t = xhtml_format.heading_seg(_txt, obj, doc_matters, suffix, "seg");
+ Tuple!(string, string[]) t = xhtml_format.heading_seg(_txt, obj, doc.matters, suffix, "seg");
doc_html[segment_filename] ~= t[0].to!string;
doc_html_endnotes[segment_filename] ~= t[1];
break;
case 8: .. case 9:
{ /+ debug +/
- if (doc_matters.opt.action.debug_do_html) {
+ if (doc.matters.opt.action.debug_do_html) {
writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a, ": ", obj.metainfo.heading_lev_markup);
writeln(__FILE__, ":", __LINE__, ": ", obj.text);
}
@@ -352,7 +343,7 @@ template outputHTML() {
break;
default:
{ /+ debug +/
- if (doc_matters.opt.action.debug_do_html) {
+ if (doc.matters.opt.action.debug_do_html) {
writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a, ": ", obj.metainfo.heading_lev_markup);
}
}
@@ -367,12 +358,12 @@ template outputHTML() {
case "para":
switch (obj.metainfo.is_a) {
case "toc":
- t = xhtml_format.para_seg(_txt, obj, doc_matters, suffix, "seg");
+ t = xhtml_format.para_seg(_txt, obj, doc.matters, suffix, "seg");
doc_html[segment_filename] ~= t[0].to!string;
break;
default:
{ /+ debug +/
- if (doc_matters.opt.action.debug_do_html) {
+ if (doc.matters.opt.action.debug_do_html) {
writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a);
}
}
@@ -381,7 +372,7 @@ template outputHTML() {
break;
default:
{ /+ debug +/
- if (doc_matters.opt.action.debug_do_html) {
+ if (doc.matters.opt.action.debug_do_html) {
writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a);
}
}
@@ -393,13 +384,13 @@ template outputHTML() {
case "para":
switch (obj.metainfo.is_a) {
case "para":
- t = xhtml_format.para_seg(_txt, obj, doc_matters, suffix, "seg");
+ t = xhtml_format.para_seg(_txt, obj, doc.matters, suffix, "seg");
doc_html[segment_filename] ~= t[0].to!string;
doc_html_endnotes[segment_filename] ~= t[1];
break;
default:
{ /+ debug +/
- if (doc_matters.opt.action.debug_do_html) {
+ if (doc.matters.opt.action.debug_do_html) {
writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a);
}
}
@@ -409,24 +400,24 @@ template outputHTML() {
case "block":
switch (obj.metainfo.is_a) {
case "quote":
- t = xhtml_format.quote_seg(_txt, obj, doc_matters, suffix, "seg");
+ t = xhtml_format.quote_seg(_txt, obj, doc.matters, suffix, "seg");
goto default;
case "group":
- t = xhtml_format.group_seg(_txt, obj, doc_matters, suffix, "seg");
+ t = xhtml_format.group_seg(_txt, obj, doc.matters, suffix, "seg");
goto default;
case "block":
- t = xhtml_format.block_seg(_txt, obj, doc_matters, suffix, "seg");
+ t = xhtml_format.block_seg(_txt, obj, doc.matters, suffix, "seg");
goto default;
case "poem":
break;
case "verse":
- t = xhtml_format.verse_seg(_txt, obj, doc_matters, suffix, "seg");
+ t = xhtml_format.verse_seg(_txt, obj, doc.matters, suffix, "seg");
goto default;
case "code":
- doc_html[segment_filename] ~= xhtml_format.code(_txt, obj, doc_matters);
+ doc_html[segment_filename] ~= xhtml_format.code(_txt, obj, doc.matters);
break;
case "table":
- doc_html[segment_filename] ~= xhtml_format.table(_txt, obj, doc_matters);
+ doc_html[segment_filename] ~= xhtml_format.table(_txt, obj, doc.matters);
doc_html_endnotes[segment_filename] ~= "";
break;
default:
@@ -438,7 +429,7 @@ template outputHTML() {
doc_html[segment_filename] ~= t[0].to!string;
doc_html_endnotes[segment_filename] ~= t[1];
} else { /+ debug +/
- if (doc_matters.opt.action.debug_do_html) {
+ if (doc.matters.opt.action.debug_do_html) {
writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a);
}
}
@@ -447,7 +438,7 @@ template outputHTML() {
break;
default:
{ /+ debug +/
- if (doc_matters.opt.action.debug_do_html) {
+ if (doc.matters.opt.action.debug_do_html) {
writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_of_type);
}
}
@@ -460,37 +451,37 @@ template outputHTML() {
case "para":
switch (obj.metainfo.is_a) {
case "endnote": assert(section == "endnotes");
- t = xhtml_format.para_seg(_txt, obj, doc_matters, suffix, "seg");
+ t = xhtml_format.para_seg(_txt, obj, doc.matters, suffix, "seg");
doc_html[segment_filename] ~= t[0];
break;
case "glossary": assert(section == "glossary");
- t = xhtml_format.para_seg(_txt, obj, doc_matters, suffix, "seg");
+ t = xhtml_format.para_seg(_txt, obj, doc.matters, suffix, "seg");
doc_html[segment_filename] ~= t[0];
doc_html_endnotes[segment_filename] ~= t[1];
break;
case "bibliography": assert(section == "bibliography");
- t = xhtml_format.para_seg(_txt, obj, doc_matters, suffix, "seg");
+ t = xhtml_format.para_seg(_txt, obj, doc.matters, suffix, "seg");
doc_html[segment_filename] ~= t[0];
doc_html_endnotes[segment_filename] ~= t[1];
break;
case "bookindex": assert(section == "bookindex");
- t = xhtml_format.para_seg(_txt, obj, doc_matters, suffix, "seg");
+ t = xhtml_format.para_seg(_txt, obj, doc.matters, suffix, "seg");
doc_html[segment_filename] ~= t[0];
doc_html_endnotes[segment_filename] ~= t[1];
break;
case "blurb": assert(section == "blurb");
- t = xhtml_format.para_seg(_txt, obj, doc_matters, suffix, "seg");
+ t = xhtml_format.para_seg(_txt, obj, doc.matters, suffix, "seg");
doc_html[segment_filename] ~= t[0];
doc_html_endnotes[segment_filename] ~= t[1];
break;
case "tail": assert(section == "tail");
- t = xhtml_format.para_seg(_txt, obj, doc_matters, suffix, "seg");
+ t = xhtml_format.para_seg(_txt, obj, doc.matters, suffix, "seg");
doc_html[segment_filename] ~= t[0];
doc_html_endnotes[segment_filename] ~= t[1];
break;
default:
{ /+ debug +/
- if (doc_matters.opt.action.debug_do_html) {
+ if (doc.matters.opt.action.debug_do_html) {
writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a);
}
}
@@ -499,7 +490,7 @@ template outputHTML() {
break;
default:
{ /+ debug +/
- if (doc_matters.opt.action.debug_do_html) {
+ if (doc.matters.opt.action.debug_do_html) {
writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_of_type);
}
}
@@ -510,7 +501,7 @@ template outputHTML() {
break;
default:
{ /+ debug +/
- if (doc_matters.opt.action.debug_do_html) {
+ if (doc.matters.opt.action.debug_do_html) {
writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_of_part);
}
}
@@ -519,7 +510,7 @@ template outputHTML() {
}
}
}
- seg_write_output(doc_html, doc_html_endnotes, doc_matters);
+ seg_write_output(doc_html, doc_html_endnotes, doc.matters);
}
@trusted void seg_write_output(D,E,M)( // @system?
D doc_html,
@@ -587,9 +578,7 @@ template outputHTML() {
// Handle error
}
}
- @trusted void images_cp(M)( // @system
- M doc_matters,
- ) {
+ @trusted void images_cp(M)(M doc_matters) { // @system
{ /+ (copy html images) +/
auto pth_html = spinePathsHTML!()(doc_matters.output_path, doc_matters.src.language);
if (!exists(pth_html.image)) {