aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/sdp/output_html.d
diff options
context:
space:
mode:
authorRalph Amissah <ralph@amissah.com>2017-05-09 13:01:06 -0400
committerRalph Amissah <ralph@amissah.com>2019-04-10 15:14:14 -0400
commit60d6073bcfc4fa91253428094813de0dac41a2b4 (patch)
treecef8e223469724d9e42dea81d6ded5ffc75a9be2 /src/sdp/output_html.d
parentmodules, collective imports (diff)
0.16.0 files/modules re-arrangeddoc-reform_v0.0.16
Diffstat (limited to 'src/sdp/output_html.d')
-rw-r--r--src/sdp/output_html.d465
1 files changed, 0 insertions, 465 deletions
diff --git a/src/sdp/output_html.d b/src/sdp/output_html.d
deleted file mode 100644
index 41d68dd..0000000
--- a/src/sdp/output_html.d
+++ /dev/null
@@ -1,465 +0,0 @@
-module sdp.output_html;
-template outputHTML() {
- private import
- std.algorithm,
- std.array,
- std.container,
- std.digest.sha,
- std.exception,
- std.file,
- std.getopt,
- std.json,
- std.outbuffer,
- std.path,
- std.process,
- std.range,
- std.regex,
- std.stdio,
- std.string,
- std.traits,
- std.typecons,
- std.uni,
- std.utf,
- std.zip,
- std.conv : to;
- import
- sdp.create_zip_file,
- sdp.defaults,
- sdp.output_rgx,
- sdp.output_xmls,
- sdp.output_xmls_css,
- sdp.paths_output;
- mixin outputXHTMLs;
-
- void scroll(D,I)(
- auto return ref const D doc_abstraction,
- auto return ref I doc_matters,
- ) {
- mixin SiSUoutputRgxInit;
- auto xhtml_format = outputXHTMLs();
- auto rgx = Rgx();
- string[] doc_html;
- string[] doc;
- string suffix = ".html";
- foreach (part; doc_matters.keys_seq.scroll) {
- foreach (obj; doc_abstraction[part]) {
- string _txt = xhtml_format.special_characters(obj, obj.text);
- switch (obj.use) {
- case "frontmatter":
- switch (obj.is_of) {
- case "para":
- switch (obj.is_a) {
- case "heading":
- doc_html ~= xhtml_format.heading_scroll(obj, _txt, suffix);
- break;
- case "toc":
- doc_html ~= xhtml_format.para_scroll(obj, _txt, suffix);
- 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_of);
- }
- break;
- }
- break;
- case "body":
- switch (obj.is_of) {
- case "para":
- switch (obj.is_a) {
- case "heading":
- doc_html ~= xhtml_format.heading_scroll(obj, _txt, suffix);
- break;
- case "para":
- doc_html ~= xhtml_format.para_scroll(obj, _txt, suffix);
- break;
- default:
- if ((doc_matters.opt_action_bool["debug"])) {
- writeln(__FILE__, ":", __LINE__, ": ", obj.is_a);
- }
- break;
- }
- break;
- case "block":
- switch (obj.is_a) {
- case "quote":
- doc_html ~= xhtml_format.quote_scroll(obj, _txt);
- break;
- case "group":
- doc_html ~= xhtml_format.group_scroll(obj, _txt);
- break;
- case "block":
- doc_html ~= xhtml_format.block_scroll(obj, _txt);
- break;
- case "poem":
- break;
- case "verse":
- doc_html ~= xhtml_format.verse_scroll(obj, _txt, suffix);
- break;
- case "code":
- doc_html ~= xhtml_format.code(obj, _txt);
- break;
- case "table":
- doc_html ~= xhtml_format.table(obj, _txt);
- 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_of);
- }
- break;
- }
- break;
- case "backmatter":
- switch (obj.is_of) {
- case "para":
- switch (obj.is_a) {
- case "heading":
- doc_html ~= xhtml_format.heading_scroll(obj, _txt, suffix);
- break;
- case "endnote":
- doc_html ~= xhtml_format.para_scroll(obj, _txt, suffix);
- break;
- case "glossary":
- doc_html ~= xhtml_format.para_scroll(obj, _txt, suffix);
- break;
- case "bibliography":
- doc_html ~= xhtml_format.para_scroll(obj, _txt, suffix);
- break;
- case "bookindex":
- doc_html ~= xhtml_format.para_scroll(obj, _txt, suffix);
- break;
- case "blurb":
- doc_html ~= xhtml_format.para_scroll(obj, _txt, suffix);
- 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_of);
- }
- break;
- }
- break;
- case "comment":
- break;
- default:
- if ((doc_matters.opt_action_bool["debug"])) {
- writeln(__FILE__, ":", __LINE__, ": ", obj.use);
- writeln(__FILE__, ":", __LINE__, ": ", obj.is_a);
- writeln(__FILE__, ":", __LINE__, ": ", obj.text);
- }
- break;
- }
- }
- }
- doc = xhtml_format.html_scroll_head(doc_matters) ~ doc_html ~ xhtml_format.tail;
- scroll_write_output(doc_matters, doc);
- }
- void scroll_write_output(M,C)(
- M doc_matters,
- C doc,
- ) {
- debug(asserts) {
- static assert(is(typeof(doc) == string[]));
- }
- string fn_src = doc_matters.source_filename;
- auto src_path_info = doc_matters.src_path_info;
- string fn_rel_pth = doc_matters.source_filename;
- string lng = doc_matters.language;
- auto pth_html = SiSUpathsHTML!()(src_path_info, lng);
- try {
- if (!exists(pth_html.base)) {
- pth_html.base.mkdirRecurse;
- }
- auto f = File(pth_html.fn_scroll(fn_src), "w");
- foreach (o; doc) {
- f.writeln(o);
- }
- }
- catch (ErrnoException ex) {
- // Handle error
- }
- }
- void seg(D,I)(
- auto return ref const D doc_abstraction,
- auto return ref I doc_matters,
- ) {
- mixin SiSUoutputRgxInit;
- auto rgx = Rgx();
- auto xhtml_format = outputXHTMLs();
- string[][string] doc_html;
- string[][string] doc_html_endnotes;
- string[] doc;
- string segment_filename;
- string[] top_level_headings = ["","","",""];
- string suffix = ".html";
- foreach (part; doc_matters.keys_seq.seg) {
- foreach (obj; doc_abstraction[part]) {
- string _txt = xhtml_format.special_characters(obj, obj.text);
- if (obj.is_a == "heading") {
- switch (obj.heading_lev_markup) {
- case 0: .. case 3:
- /+ fill buffer, and replace with new levels from 1 to 3 +/
- switch (obj.heading_lev_markup) {
- case 0:
- top_level_headings[0] = "";
- top_level_headings[1] = "";
- top_level_headings[2] = "";
- top_level_headings[3] = "";
- goto default;
- case 1:
- top_level_headings[1] = "";
- top_level_headings[2] = "";
- top_level_headings[3] = "";
- goto default;
- case 2:
- top_level_headings[2] = "";
- top_level_headings[3] = "";
- goto default;
- case 3:
- top_level_headings[3] = "";
- goto default;
- default:
- auto t = xhtml_format.heading_seg(obj, _txt, suffix);
- top_level_headings[obj.heading_lev_markup] = t[0];
- break;
- }
- break;
- case 4:
- segment_filename = obj.segment_anchor_tag;
- doc_html[segment_filename] ~= xhtml_format.html_seg_head(doc_matters);
- foreach (top_level_heading; top_level_headings) {
- // writeln(top_level_heading);
- doc_html[segment_filename] ~= top_level_heading;
- }
- auto t = xhtml_format.heading_seg(obj, _txt, suffix);
- doc_html[segment_filename] ~= to!string(t[0]);
- doc_html_endnotes[segment_filename] ~= t[1];
- break;
- case 5: .. case 7:
- auto t = xhtml_format.heading_seg(obj, _txt, suffix);
- doc_html[segment_filename] ~= to!string(t[0]);
- doc_html_endnotes[segment_filename] ~= t[1];
- break;
- case 8: .. case 9:
- if ((doc_matters.opt_action_bool["debug"])) {
- writeln(__FILE__, ":", __LINE__, ": ", obj.is_a, ": ", obj.heading_lev_markup);
- writeln(__FILE__, ":", __LINE__, ": ", obj.text);
- }
- break;
- default:
- if ((doc_matters.opt_action_bool["debug"])) {
- writeln(__FILE__, ":", __LINE__, ": ", obj.is_a, ": ", obj.heading_lev_markup);
- }
- break;
- }
- } else {
- switch (obj.use) {
- case "frontmatter":
- switch (obj.is_of) {
- case "para":
- switch (obj.is_a) {
- case "toc":
- auto t = xhtml_format.para_seg(obj, _txt, suffix);
- doc_html[segment_filename] ~= to!string(t[0]);
- 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);
- }
- break;
- }
- break;
- case "body":
- switch (obj.is_of) {
- case "para":
- switch (obj.is_a) {
- case "para":
- auto t = xhtml_format.para_seg(obj, _txt, suffix);
- doc_html[segment_filename] ~= to!string(t[0]);
- doc_html_endnotes[segment_filename] ~= t[1];
- break;
- default:
- if ((doc_matters.opt_action_bool["debug"])) {
- writeln(__FILE__, ":", __LINE__, ": ", obj.is_a);
- }
- break;
- }
- break;
- case "block":
- switch (obj.is_a) {
- case "quote":
- auto t = xhtml_format.quote_seg(obj, _txt, suffix);
- doc_html[segment_filename] ~= to!string(t[0]);
- doc_html_endnotes[segment_filename] ~= t[1];
- break;
- case "group":
- auto t = xhtml_format.group_seg(obj, _txt, suffix);
- doc_html[segment_filename] ~= to!string(t[0]);
- doc_html_endnotes[segment_filename] ~= t[1];
- break;
- case "block":
- auto t = xhtml_format.block_seg(obj, _txt, suffix);
- doc_html[segment_filename] ~= to!string(t[0]);
- doc_html_endnotes[segment_filename] ~= t[1];
- break;
- case "poem":
- break;
- case "verse":
- auto t = xhtml_format.verse_seg(obj, _txt, suffix);
- doc_html[segment_filename] ~= to!string(t[0]);
- doc_html_endnotes[segment_filename] ~= t[1];
- break;
- case "code":
- doc_html[segment_filename] ~= xhtml_format.code(obj, _txt);
- break;
- case "table":
- doc_html[segment_filename] ~= xhtml_format.table(obj, _txt);
- doc_html_endnotes[segment_filename] ~= "";
- 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_of);
- }
- break;
- }
- break;
- case "backmatter":
- switch (obj.is_of) {
- case "para":
- switch (obj.is_a) {
- case "endnote":
- auto t = xhtml_format.para_seg(obj, _txt, suffix);
- doc_html[segment_filename] ~= t[0];
- break;
- case "glossary":
- auto t = xhtml_format.para_seg(obj, _txt, suffix);
- doc_html[segment_filename] ~= t[0];
- doc_html_endnotes[segment_filename] ~= t[1];
- break;
- case "bibliography":
- auto t = xhtml_format.para_seg(obj, _txt, suffix);
- doc_html[segment_filename] ~= t[0];
- doc_html_endnotes[segment_filename] ~= t[1];
- break;
- case "bookindex":
- auto t = xhtml_format.para_seg(obj, _txt, suffix);
- doc_html[segment_filename] ~= t[0];
- doc_html_endnotes[segment_filename] ~= t[1];
- break;
- case "blurb":
- auto t = xhtml_format.para_seg(obj, _txt, suffix);
- doc_html[segment_filename] ~= t[0];
- doc_html_endnotes[segment_filename] ~= t[1];
- 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_of);
- }
- break;
- }
- break;
- case "comment":
- break;
- default:
- if ((doc_matters.opt_action_bool["debug"])) {
- writeln(__FILE__, ":", __LINE__, ": ", obj.use);
- }
- break;
- }
- }
- }
- }
- seg_write_output(doc_matters, doc_html, doc_html_endnotes);
- }
- void seg_write_output(M,D,E)(
- M doc_matters,
- D doc_html,
- E doc_html_endnotes,
- ) {
- debug(asserts) {
- static assert(is(typeof(doc_html) == string[][string]));
- }
- mixin SiSUoutputRgxInit;
- auto rgx = Rgx();
- auto src_path_info = doc_matters.src_path_info;
- string fn_rel_pth = doc_matters.source_filename;
- string lng = doc_matters.language;
- auto pth_html = SiSUpathsHTML!()(src_path_info, lng);
- auto xhtml_format = outputXHTMLs();
- auto m = doc_matters.source_filename.matchFirst(rgx.src_fn);
- try {
- if (!exists(pth_html.seg(doc_matters.source_filename))) {
- pth_html.seg(doc_matters.source_filename).mkdirRecurse;
- }
- 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);
- }
- foreach (docseg; doc_html_endnotes[seg_filename]) {
- f.writeln(docseg);
- }
- f.writeln(xhtml_format.tail);
- }
- }
- catch (ErrnoException ex) {
- // handle error
- }
- }
- void css(M)(
- auto return ref M doc_matters,
- ) {
- auto css = SiSUcss();
- auto pth_html = SiSUpathsHTML!()(doc_matters.src_path_info, doc_matters.language);
- try {
- if (!exists(pth_html.css)) {
- (pth_html.css).mkdirRecurse;
- }
- auto f = File(pth_html.fn_css, "w");
- f.writeln(css.html_css);
- }
- catch (ErrnoException ex) {
- // Handle error
- }
- }
-}