aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/sdp/output_html.d
diff options
context:
space:
mode:
Diffstat (limited to 'src/sdp/output_html.d')
-rw-r--r--src/sdp/output_html.d286
1 files changed, 163 insertions, 123 deletions
diff --git a/src/sdp/output_html.d b/src/sdp/output_html.d
index 1d55033..3af61ba 100644
--- a/src/sdp/output_html.d
+++ b/src/sdp/output_html.d
@@ -23,32 +23,9 @@ template outputHTML() {
output_xhtmls;
mixin outputXHTMLs;
- void scroll_write_output_file(Fn,C)(
- Fn fn_src,
- C doc,
- ) {
- debug(asserts){
- static assert(is(typeof(fn_src) == string));
- static assert(is(typeof(doc) == string[]));
- }
- mixin SiSUpaths;
- auto pth_html = HtmlPaths();
- try {
- if (!exists(pth_html.base)) {
- mkdirRecurse(pth_html.base);
- }
- auto f = File(pth_html.fn_scroll(fn_src), "w");
- foreach (o; doc) {
- f.writeln(o);
- }
- }
- catch (ErrnoException ex) {
- // Handle error
- }
- }
- void scroll(C,T)(
- auto ref const C contents,
- auto ref T doc_matters,
+ void scroll(D,I)(
+ auto ref const D doc_abstraction,
+ auto ref I doc_matters,
) {
mixin SiSUrgxInit;
auto xhtml_format = outputXHTMLs();
@@ -56,8 +33,9 @@ template outputHTML() {
string[] doc_html;
string[] doc;
foreach (part; doc_matters.keys_seq_scroll) {
- foreach (obj; contents[part]) {
- if (obj.use == "frontmatter") {
+ foreach (obj; doc_abstraction[part]) {
+ switch (obj.use) {
+ case "frontmatter":
switch (obj.is_of) {
case "para":
switch (obj.is_a) {
@@ -76,11 +54,12 @@ template outputHTML() {
break;
default:
if ((doc_matters.opt_action_bool["debug"])) {
- writeln(__FILE__, ":", __LINE__, ": ", obj.is_a);
+ writeln(__FILE__, ":", __LINE__, ": ", obj.is_of);
}
break;
}
- } else if (obj.use == "body") {
+ break;
+ case "body":
switch (obj.is_of) {
case "para":
switch (obj.is_a) {
@@ -132,7 +111,8 @@ template outputHTML() {
}
break;
}
- } else if (obj.use == "backmatter") {
+ break;
+ case "backmatter":
switch (obj.is_of) {
case "para":
switch (obj.is_a) {
@@ -163,48 +143,50 @@ template outputHTML() {
break;
default:
if ((doc_matters.opt_action_bool["debug"])) {
- writeln(__FILE__, ":", __LINE__, ": ", obj.is_a);
+ writeln(__FILE__, ":", __LINE__, ": ", obj.is_of);
}
break;
}
+ break;
+ case "comment":
+ break;
+ default:
+ if ((doc_matters.opt_action_bool["debug"])) {
+ writeln(__FILE__, ":", __LINE__, ": ", obj.use);
+ }
+ break;
}
}
}
doc = xhtml_format.scroll_head(doc_matters.dochead_meta) ~ doc_html ~ xhtml_format.tail;
- scroll_write_output_file(doc_matters.source_filename, doc);
+ scroll_write_output(doc_matters.source_filename, doc);
}
- void seg_write_output_files(M,C)(
- M doc_matters,
- C doc_html,
+ void scroll_write_output(Fn,C)(
+ Fn fn_src,
+ C doc,
) {
debug(asserts){
- static assert(is(typeof(doc_html) == string[][string]));
+ static assert(is(typeof(fn_src) == string));
+ static assert(is(typeof(doc) == string[]));
}
- mixin SiSUrgxInit;
- auto rgx = Rgx();
mixin SiSUpaths;
auto pth_html = HtmlPaths();
- auto xhtml_format = outputXHTMLs();
- auto m = matchFirst(doc_matters.source_filename, rgx.src_fn);
try {
- if (!exists(pth_html.seg(doc_matters.source_filename))) {
- mkdirRecurse(pth_html.seg(doc_matters.source_filename));
+ if (!exists(pth_html.base)) {
+ mkdirRecurse(pth_html.base);
}
- foreach (seg_filename; doc_matters.segnames) {
- auto f = File(pth_html.fn_seg(doc_matters.source_filename, seg_filename), "w");
- foreach (docseg; doc_html[seg_filename]) {
- f.writeln(docseg);
- }
- f.writeln(xhtml_format.tail); // needed for each lev4
+ auto f = File(pth_html.fn_scroll(fn_src), "w");
+ foreach (o; doc) {
+ f.writeln(o);
}
}
catch (ErrnoException ex) {
- // handle error
+ // Handle error
}
}
- void seg(C,M)(
- auto ref const C contents,
- auto ref M doc_matters,
+ void seg(D,I)(
+ auto ref const D doc_abstraction,
+ auto ref I doc_matters,
) {
mixin SiSUrgxInit;
auto rgx = Rgx();
@@ -214,7 +196,7 @@ template outputHTML() {
string segment_filename;
string[] top_level_headings = ["","","",""];
foreach (part; doc_matters.keys_seq_seg) {
- foreach (obj; contents[part]) {
+ foreach (obj; doc_abstraction[part]) {
if (obj.is_a == "heading") { // all headings: frontmatter, body & backmatter
switch (obj.heading_lev_markup) {
case 0: .. case 3:
@@ -239,13 +221,13 @@ template outputHTML() {
top_level_headings[3] = "";
goto default;
default:
- top_level_headings[obj.heading_lev_markup] = xhtml_format.heading(obj); // should probably have different css tagging (fontsize etc)
+ top_level_headings[obj.heading_lev_markup] = xhtml_format.heading(obj);
break;
}
break;
case 4:
segment_filename = obj.segment_anchor_tag;
- doc_html[segment_filename] ~= xhtml_format.seg_head(doc_matters.dochead_meta); // consider placing seg_head here as can more easily populate it with lev4 info
+ doc_html[segment_filename] ~= xhtml_format.seg_head(doc_matters.dochead_meta);
foreach (top_level_heading; top_level_headings) {
doc_html[segment_filename] ~= top_level_heading;
}
@@ -254,107 +236,165 @@ template outputHTML() {
case 5: .. case 7:
doc_html[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_html[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_html[segment_filename] ~= xhtml_format.para(obj);
+ switch (obj.is_a) {
+ case "toc":
+ doc_html[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_a);
+ }
break;
}
break;
- case "block":
- switch (obj.is_a) {
- case "poem": // double check why both poem & verse
- break;
- case "verse":
- doc_html[segment_filename] ~= xhtml_format.nugget(obj);
- break;
- case "group":
- doc_html[segment_filename] ~= xhtml_format.nugget(obj);
+ case "body":
+ switch (obj.is_of) {
+ case "para":
+ switch (obj.is_a) {
+ case "para":
+ doc_html[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_html[segment_filename] ~= xhtml_format.nugget(obj);
- break;
- case "quote":
- doc_html[segment_filename] ~= xhtml_format.nugget(obj);
- break;
- case "table":
- doc_html[segment_filename] ~= xhtml_format.para(obj);
- break;
- case "code":
- doc_html[segment_filename] ~= xhtml_format.code(obj);
+ switch (obj.is_a) {
+ case "poem":
+ break;
+ case "verse":
+ doc_html[segment_filename] ~= xhtml_format.nugget(obj);
+ break;
+ case "group":
+ doc_html[segment_filename] ~= xhtml_format.nugget(obj);
+ break;
+ case "block":
+ doc_html[segment_filename] ~= xhtml_format.nugget(obj);
+ break;
+ case "quote":
+ doc_html[segment_filename] ~= xhtml_format.nugget(obj);
+ break;
+ case "table":
+ doc_html[segment_filename] ~= xhtml_format.para(obj);
+ break;
+ case "code":
+ doc_html[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_html[segment_filename] ~= xhtml_format.endnote(obj);
- break;
- case "glossary":
- doc_html[segment_filename] ~= xhtml_format.para(obj);
- break;
- case "bibliography":
- doc_html[segment_filename] ~= xhtml_format.para(obj);
- break;
- case "bookindex":
- doc_html[segment_filename] ~= xhtml_format.para(obj);
- break;
- case "blurb":
- doc_html[segment_filename] ~= xhtml_format.para(obj);
+ case "backmatter":
+ switch (obj.is_of) {
+ case "para":
+ switch (obj.is_a) {
+ case "endnote":
+ doc_html[segment_filename] ~= xhtml_format.endnote(obj);
+ break;
+ case "glossary":
+ doc_html[segment_filename] ~= xhtml_format.para(obj);
+ break;
+ case "bibliography":
+ doc_html[segment_filename] ~= xhtml_format.para(obj);
+ break;
+ case "bookindex":
+ doc_html[segment_filename] ~= xhtml_format.para(obj);
+ break;
+ case "blurb":
+ doc_html[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;
}
}
}
}
- seg_write_output_files(doc_matters, doc_html);
+ seg_write_output(doc_matters, doc_html);
+ }
+ void seg_write_output(M,C)(
+ M doc_matters,
+ C doc_html,
+ ) {
+ debug(asserts){
+ static assert(is(typeof(doc_html) == string[][string]));
+ }
+ mixin SiSUrgxInit;
+ auto rgx = Rgx();
+ mixin SiSUpaths;
+ auto pth_html = HtmlPaths();
+ auto xhtml_format = outputXHTMLs();
+ auto m = matchFirst(doc_matters.source_filename, rgx.src_fn);
+ try {
+ if (!exists(pth_html.seg(doc_matters.source_filename))) {
+ mkdirRecurse(pth_html.seg(doc_matters.source_filename));
+ }
+ foreach (seg_filename; doc_matters.segnames) {
+ auto f = File(pth_html.fn_seg(doc_matters.source_filename, seg_filename), "w");
+ foreach (docseg; doc_html[seg_filename]) {
+ f.writeln(docseg);
+ }
+ f.writeln(xhtml_format.tail); // needed for each lev4
+ }
+ }
+ catch (ErrnoException ex) {
+ // handle error
+ }
}
auto html_css() {
string css;