From 2301a8251d111ca2e020f524ce036c11e4306a14 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Wed, 9 Nov 2016 17:52:33 -0500 Subject: 0.9.0 document sections --- src/sdp.d | 72 +++++++-- src/sdp/ao_abstract_doc_source.d | 323 ++++++++++++++++++++++++++++++------- src/sdp/ao_conf_make_meta_native.d | 12 +- src/sdp/ao_defaults.d | 7 +- src/sdp/ao_output_debugs.d | 167 ++++++++++--------- src/sdp/ao_rgx.d | 3 + src/sdp/output_html.d | 33 ++-- src/sdp/output_hub.d | 16 +- 8 files changed, 449 insertions(+), 184 deletions(-) (limited to 'src') diff --git a/src/sdp.d b/src/sdp.d index c13250d..63df077 100755 --- a/src/sdp.d +++ b/src/sdp.d @@ -196,21 +196,68 @@ void main(string[] args) { /+ ↓ document abstraction: process document, return abstraction as tuple +/ auto t = abs.abstract_doc_source(content_body, dochead_make, dochead_meta); static assert(!isTypeTuple!(t)); - auto doc_ao_contents = t[0]; // head ~ toc ~ contents ~ endnotes_seg ~ [glossary] ~ bibliography ~ bookindex; + auto doc_ao_contents = t[0]; // head ~ toc ~ contents ~ endnotes_seg ~ glossary ~ bibliography ~ bookindex ~blurb; auto doc_ao_bookindex_unordered_hashes = t[1]; // redundant? auto doc_ao_biblio = t[2]; // redundant? + string[][string] document_section_keys_sequenced = [ + "seg": [ + "head", + "toc_seg", + "body", + ], + "scroll": [ + "head", + "toc_scroll", + "body", + ] + ]; + /+ seg +/ + if (doc_ao_contents["endnotes_seg"].length > 1) { + document_section_keys_sequenced["seg"] = + document_section_keys_sequenced["seg"] ~= "endnotes_seg"; + } + if (doc_ao_contents["glossary"].length > 1) { + document_section_keys_sequenced["seg"] = + document_section_keys_sequenced["seg"] ~= "glossary"; + } + if (doc_ao_contents["bibliography"].length > 1) { + document_section_keys_sequenced["seg"] = + document_section_keys_sequenced["seg"] ~= "bibliography"; + } + if (doc_ao_contents["bookindex_seg"].length > 1) { + document_section_keys_sequenced["seg"] = + document_section_keys_sequenced["seg"] ~= "bookindex_seg"; + } + if (doc_ao_contents["blurb"].length > 1) { + document_section_keys_sequenced["seg"] = + document_section_keys_sequenced["seg"] ~= "blurb"; + } + /+ scroll +/ + if (doc_ao_contents["endnotes_scroll"].length > 1) { + document_section_keys_sequenced["scroll"] = + document_section_keys_sequenced["scroll"] ~= "endnotes_scroll"; + } + if (doc_ao_contents["glossary"].length > 1) { + document_section_keys_sequenced["scroll"] = + document_section_keys_sequenced["scroll"] ~= "glossary"; + } + if (doc_ao_contents["bibliography"].length > 1) { + document_section_keys_sequenced["scroll"] = + document_section_keys_sequenced["scroll"] ~= "bibliography"; + } + if (doc_ao_contents["bookindex_scroll"].length > 1) { + document_section_keys_sequenced["scroll"] = + document_section_keys_sequenced["scroll"] ~= "bookindex_scroll"; + } + if (doc_ao_contents["blurb"].length > 1) { + document_section_keys_sequenced["scroll"] = + document_section_keys_sequenced["scroll"] ~= "blurb"; + } /+ ↓ debugs +/ - debug(checkdoc) { // checkbook & dumpdoc - auto doc_ao_contents_view = ( - doc_ao_contents["head"] ~ - doc_ao_contents["toc_seg"] ~ - doc_ao_contents["body"] ~ - doc_ao_contents["endnotes_seg"] ~ - doc_ao_contents["bibliography"] ~ - doc_ao_contents["bookindex_seg"] - ); + debug(checkdoc) { dbg.abstract_doc_source_debugs( - doc_ao_contents_view, + doc_ao_contents, + document_section_keys_sequenced, doc_ao_bookindex_unordered_hashes, // redundant? doc_ao_biblio, // redundant? dochead_make, @@ -222,8 +269,7 @@ void main(string[] args) { /+ ↓ output hub +/ output.hub( doc_ao_contents, - doc_ao_bookindex_unordered_hashes, // redundant? - doc_ao_biblio, // redundant? + document_section_keys_sequenced, dochead_make, dochead_meta, fn_src, diff --git a/src/sdp/ao_abstract_doc_source.d b/src/sdp/ao_abstract_doc_source.d index 8d2ff70..421c094 100644 --- a/src/sdp/ao_abstract_doc_source.d +++ b/src/sdp/ao_abstract_doc_source.d @@ -18,8 +18,9 @@ template SiSUdocAbstraction() { /+ initialize +/ auto rgx = Rgx(); ObjComposite[][string] the_table_of_contents_section; - ObjComposite[] the_document_head_section, the_document_body_section, the_bibliography_section; + ObjComposite[] the_document_head_section, the_document_body_section, the_bibliography_section, the_glossary_section, the_blurb_section; string[string] an_object, processing; + string an_object_key; string[] anchor_tags; string segment_object_belongs_to; auto set_abstract_object = ObjectAbstractSet(); @@ -93,8 +94,10 @@ template SiSUdocAbstraction() { destroy(biblio_arr_json); } line_occur = [ - "heading" : 0, - "para" : 0, + "heading" : 0, + "para" : 0, + "glossary" : 0, + "blurb" : 0, ]; auto type = flags_type_init; void tell_lo(int obj_cite_number, in char[] line) { @@ -150,6 +153,22 @@ template SiSUdocAbstraction() { "h_3": regex(r"^(none)"), "h_4": regex(r"^(none)") ]; + an_object["glossary_nugget"] = ""; + an_object["blurb_nugget"] = ""; + auto toc_head = + set_abstract_object.contents_heading( + "Table of Contents", // nugget/object + "", // attrib + 0, // obj_cite_number + ["toc"], // anchor tag + "1", // lev + 4, // lev_markup_number + 2, // lev_collapsed_number + ); + the_table_of_contents_section = [ + "seg": [toc_head], + "scroll": [toc_head], + ]; /+ abstraction init ↑ +/ /+ ↓ loop markup document/text line by line +/ srcDocLoop: @@ -196,11 +215,140 @@ template SiSUdocAbstraction() { && (!matchFirst(line, rgx.comment))) { /+ within section (block object): biblio +/ _biblio_block_(line, type, bib_entry, biblio_entry_str_json, biblio_arr_json); + type["glossary_section"] = State.off; + type["biblio_section"] = State.on; + type["blurb_section"] = State.off; debug(bibliobuild) { writeln("- ", biblio_entry_str_json); writeln("-> ", biblio_arr_json.length); } continue; + } else if ((matchFirst(line, rgx.heading_glossary) + || (type["glossary_section"] == State.on)) + && (!matchFirst(line, rgx.heading)) + && (!matchFirst(line, rgx.comment))) { + /+ within section (block object): glossary +/ + debug(glossary) { + writeln(__LINE__); + writeln(line); + } + // _glossary_block_(line, type); + type["glossary_section"] = State.on; + type["biblio_section"] = State.off; + type["blurb_section"] = State.off; + indent=[ + "hang_position" : "0", + "base_position" : "0", + ]; + bullet = false; + type["para"] = State.on; + line_occur["para"] = State.off; + an_object_key="glossary_nugget"; // + if (matchFirst(line, rgx.heading_glossary)) { + the_glossary_section ~= + set_abstract_object.contents_heading( + "Glossary", // nugget/object + "", // attrib + 0, // obj_cite_number + [""], // anchor tag + "B", // lev + 1, // lev_markup_number + 1, // lev_collapsed_number + ); + the_glossary_section ~= + set_abstract_object.contents_heading( + "Glossary", // nugget/object + "", // attrib + 0, // obj_cite_number + ["glossary"], // anchor tag + "1", // lev + 4, // lev_markup_number + 2, // lev_collapsed_number + ); + // } else if (matchFirst(line, rgx.heading)) { + // _heading_matched_(line, line_occur, an_object, an_object_key, lv, collapsed_lev, type, dochead_meta_aa); // levels? + } else { + _para_match_(line, an_object, an_object_key, indent, bullet, type, line_occur); + the_glossary_section ~= + set_abstract_object.contents_para( + "para", // an_object["is"], + to!string(line), // an_object["substantive"], + "", // attrib + 0, // obj_cite_number, + indent, + bullet + ); + } + type["obj_cite_number_status"] = TriState.off; + continue; + } else if ((matchFirst(line, rgx.heading_blurb) + || (type["blurb_section"] == State.on)) + && (!matchFirst(line, rgx.heading)) + && (!matchFirst(line, rgx.comment))) { + /+ within section (block object): blurb +/ + debug(blurb) { + writeln(__LINE__); + writeln(line); + } + // _blurb_block_(line, type); + type["glossary_section"] = State.off; + type["biblio_section"] = State.off; + type["blurb_section"] = State.on; + indent=[ + "hang_position" : "0", + "base_position" : "0", + ]; + bullet = false; + type["para"] = State.on; + line_occur["para"] = State.off; + an_object_key="blurb_nugget"; + if (matchFirst(line, rgx.heading_blurb)) { + the_blurb_section ~= + set_abstract_object.contents_heading( + "Blurb", // nugget/object + "", // attrib + 0, // obj_cite_number + [""], // anchor tag + "B", // lev + 1, // lev_markup_number + 1, // lev_collapsed_number + ); + the_blurb_section ~= + set_abstract_object.contents_heading( + "Blurb", // nugget/object + "", // attrib + 0, // obj_cite_number + ["blurb"], // anchor tag + "1", // lev + 4, // lev_markup_number + 2, // lev_collapsed_number + ); + } else if (matchFirst(line, rgx.heading)) { + _heading_matched_(line, line_occur, an_object, an_object_key, lv, collapsed_lev, type, dochead_meta_aa); + the_blurb_section ~= + set_abstract_object.contents_heading( + to!string(line), // an_object["substantive"], + "", // attrib + 0, // obj_cite_number + [""], // anchor tag + to!string(an_object["lev"]), + to!int(an_object["lev_markup_number"]), + to!int(an_object["lev_collapsed_number"]), + ); + } else { + _para_match_(line, an_object, an_object_key, indent, bullet, type, line_occur); + the_blurb_section ~= + set_abstract_object.contents_para( + "para", // an_object["is"], + to!string(line), // an_object["substantive"], + "", // attrib + obj_cite_number, + indent, + bullet + ); + } + type["obj_cite_number_status"] = TriState.off; + continue; } else if (type["poem"] == TriState.on) { /+ within block object: poem +/ _poem_block_(line, an_object, type, counter, obj_cite_number_poem, dochead_make_aa); @@ -270,14 +418,15 @@ template SiSUdocAbstraction() { _book_index_(line, book_idx_tmp, an_object, type); } else { /+ not book_index +/ + an_object_key="body_nugget"; if (auto m = matchFirst(line, rgx.comment)) { /+ matched comment +/ debug(comment) { writeln(line); } - an_object["body_nugget"] ~= line ~= "\n"; + an_object[an_object_key] ~= line ~= "\n"; the_document_body_section ~= - set_abstract_object.contents_comment(strip(an_object["body_nugget"])); + set_abstract_object.contents_comment(strip(an_object[an_object_key])); _common_reset_(line_occur, an_object, type); processing.remove("verse"); ++counter; @@ -308,24 +457,25 @@ template SiSUdocAbstraction() { +/ if (matchFirst(line, rgx.heading)) { /+ heading match +/ - _heading_matched_(line, line_occur, an_object, lv, collapsed_lev, type, dochead_meta_aa); + _heading_matched_(line, line_occur, an_object, an_object_key, lv, collapsed_lev, type, dochead_meta_aa); } else if (line_occur["para"] == State.off) { /+ para match +/ - _para_match_(line, an_object, indent, bullet, type, line_occur); + an_object_key="body_nugget"; + _para_match_(line, an_object, an_object_key, indent, bullet, type, line_occur); } } else if (line_occur["heading"] > State.off) { /+ heading +/ debug(heading) { // heading writeln(line); } - an_object["body_nugget"] ~= line ~= "\n"; + an_object[an_object_key] ~= line ~= "\n"; ++line_occur["heading"]; } else if (line_occur["para"] > State.off) { /+ paragraph +/ debug(para) { writeln(line); } - an_object["body_nugget"] ~= line; + an_object[an_object_key] ~= line; ++line_occur["para"]; } } @@ -363,8 +513,9 @@ template SiSUdocAbstraction() { bookindex_unordered_hashes = bkidx_hash(an_object["bookindex_nugget"], obj_cite_number); an_object["is"] = "heading"; + an_object_key="body_nugget"; auto substantive_object_and_anchor_tags_tuple = - obj_im.obj_inline_markup_and_anchor_tags(an_object, dochead_make_aa); // tuple this with anchor tags? + obj_im.obj_inline_markup_and_anchor_tags(an_object, an_object_key, dochead_make_aa); // tuple this with anchor tags? an_object["substantive"] = substantive_object_and_anchor_tags_tuple[0]; anchor_tags = substantive_object_and_anchor_tags_tuple[1]; if (to!int(an_object["lev_markup_number"]) == 4) { @@ -390,7 +541,7 @@ template SiSUdocAbstraction() { an_object["is"] ); // heading an_object["attrib"] = - obj_att.obj_attributes(an_object["is"], an_object["body_nugget"], _node); + obj_att.obj_attributes(an_object["is"], an_object[an_object_key], _node); ++heading_pointer; debug(segments) { writeln(an_object["lev_markup_number"]); @@ -433,11 +584,11 @@ template SiSUdocAbstraction() { an_object["is"] ); auto substantive_object_and_anchor_tags_tuple = - obj_im.obj_inline_markup_and_anchor_tags(an_object, dochead_make_aa); + obj_im.obj_inline_markup_and_anchor_tags(an_object, an_object_key, dochead_make_aa); // ... an_object["substantive"] = substantive_object_and_anchor_tags_tuple[0]; anchor_tags = substantive_object_and_anchor_tags_tuple[1]; an_object["attrib"] = - obj_att.obj_attributes(an_object["is"], an_object["body_nugget"], _node); + obj_att.obj_attributes(an_object["is"], an_object[an_object_key], _node); the_document_body_section ~= set_abstract_object.contents_para( an_object["is"], @@ -470,6 +621,12 @@ template SiSUdocAbstraction() { if (((the_document_body_section[$-1].is_a == "para") || (the_document_body_section[$-1].is_a == "heading")) && (counter-1 > previous_count)) { + if ((the_document_body_section[$-1].is_a == "heading") + && (the_document_body_section[$-1].heading_attrib.lev_markup_number < 5)) { + type["biblio_section"] = State.off; + type["glossary_section"] = State.off; + type["blurb_section"] = State.off; + } if (match(the_document_body_section[$-1].object, rgx.inline_notes_delimiter_al_regular_number_note)) { previous_count=the_document_body_section.length -1; @@ -494,7 +651,7 @@ template SiSUdocAbstraction() { * book index +/ // TODO FIGURE OUT, you need this possibility - // obj_im.obj_inline_markup_and_anchor_tags("doc_end_reset", "", dochead_make_aa); + // obj_im.obj_inline_markup_and_anchor_tags("doc_end_reset", an_object_key, "", dochead_make_aa); debug(toc) { writefln( "%s %s", @@ -520,6 +677,46 @@ template SiSUdocAbstraction() { writeln(o); } } + if (an_object["glossary_nugget"].length == 0) { + writeln("no gloss"); + the_glossary_section ~= + set_abstract_object.contents_heading( + "(skip) there is no Glossary section", // nugget/object + "", // attrib + 0, // obj_cite_number + [""], // anchor tag + "B", // lev + 1, // lev_markup_number + 1, // lev_collapsed_number + ); + } else { + writeln("gloss"); + } + debug(glossary) { + foreach (gloss; the_glossary_section) { + writeln(gloss.object); + } + } + if (an_object["blurb_nugget"].length == 0) { + writeln("no blurb"); + the_blurb_section ~= + set_abstract_object.contents_heading( + "(skip) there is no Blurb section", // nugget/object + "", // attrib + 0, // obj_cite_number + [""], // anchor tag + "B", // lev + 1, // lev_markup_number + 1, // lev_collapsed_number + ); + } else { + writeln("blurb"); + } + debug(blurb) { + foreach (blurb; the_blurb_section) { + writeln(blurb.object); + } + } auto biblio_unsorted_incomplete = biblio_arr_json.dup; // destroy(biblio_arr_json); auto biblio = Bibliography(); @@ -613,10 +810,11 @@ template SiSUdocAbstraction() { "body": the_document_body_section, "endnotes_seg": the_endnotes_section["seg"], "endnotes_scroll": the_endnotes_section["scroll"], - // "glossary": the_glossary_section, // TODO + "glossary": the_glossary_section, "bibliography": the_bibliography_section, "bookindex_scroll": the_bookindex_section["scroll"], "bookindex_seg": the_bookindex_section["seg"], + "blurb": the_blurb_section, ]; auto t = tuple( document_the, @@ -850,7 +1048,7 @@ template SiSUdocAbstraction() { debug(code) { // code (curly) line writeln(line); } - an_object["body_nugget"] ~= line ~= "\n"; // code (curly) line + an_object[an_object_key] ~= line ~= "\n"; // code (curly) line } } else if (type["tic_code"] == TriState.on) { if (matchFirst(line, rgx.block_tic_close)) { @@ -864,7 +1062,7 @@ template SiSUdocAbstraction() { debug(code) { // code (tic) line writeln(line); } - an_object["body_nugget"] ~= line ~= "\n"; // code (tic) line + an_object[an_object_key] ~= line ~= "\n"; // code (tic) line } } } @@ -896,6 +1094,8 @@ template SiSUdocAbstraction() { ) { if (matchFirst(line, rgx.heading_biblio)) { type["biblio_section"] = TriState.on; + type["blurb_section"] = State.off; + type["glossary_section"] = State.off; } if (line.empty) { debug { @@ -1014,7 +1214,7 @@ template SiSUdocAbstraction() { ) { if (type["curly_poem"] == TriState.on) { if (matchFirst(line, rgx.block_curly_poem_close)) { - an_object["body_nugget"]="verse"; // check that this is as you please + an_object[an_object_key]="verse"; // check that this is as you please debug(poem) { // poem (curly) close writefln( "* [poem curly] %s", @@ -1022,7 +1222,7 @@ template SiSUdocAbstraction() { ); } if (processing.length > 0) { - an_object["body_nugget"] = processing["verse"]; + an_object[an_object_key] = processing["verse"]; } debug(poem) { // poem (curly) close writeln(__LINE__); @@ -1036,16 +1236,16 @@ template SiSUdocAbstraction() { debug(poem) { // poem (curly) close writeln( obj_cite_number, - an_object["body_nugget"] + an_object[an_object_key] ); } an_object["is"] = "verse"; auto substantive_object_and_anchor_tags_tuple = - obj_im.obj_inline_markup_and_anchor_tags(an_object, dochead_make_aa); + obj_im.obj_inline_markup_and_anchor_tags(an_object, an_object_key, dochead_make_aa); an_object["substantive"] = substantive_object_and_anchor_tags_tuple[0]; anchor_tags = substantive_object_and_anchor_tags_tuple[1]; an_object["attrib"] = - obj_att.obj_attributes(an_object["is"], an_object["body_nugget"], _node); + obj_att.obj_attributes(an_object["is"], an_object[an_object_key], _node); the_document_body_section ~= set_abstract_object.contents_block( an_object["is"], @@ -1074,12 +1274,12 @@ template SiSUdocAbstraction() { } if (type["verse_new"] == State.on) { verse_line=1; - an_object["body_nugget"] = processing["verse"]; + an_object[an_object_key] = processing["verse"]; debug(poem) { // poem verse writefln( "* %s curly\n%s", obj_cite_number, - an_object["body_nugget"] + an_object[an_object_key] ); } processing.remove("verse"); @@ -1093,11 +1293,11 @@ template SiSUdocAbstraction() { an_object["is"] ); auto substantive_object_and_anchor_tags_tuple = - obj_im.obj_inline_markup_and_anchor_tags(an_object, dochead_make_aa); + obj_im.obj_inline_markup_and_anchor_tags(an_object, an_object_key, dochead_make_aa); an_object["substantive"] = substantive_object_and_anchor_tags_tuple[0]; anchor_tags = substantive_object_and_anchor_tags_tuple[1]; an_object["attrib"] = - obj_att.obj_attributes(an_object["is"], an_object["body_nugget"], _node); + obj_att.obj_attributes(an_object["is"], an_object[an_object_key], _node); the_document_body_section ~= set_abstract_object.contents_block( an_object["is"], @@ -1112,7 +1312,7 @@ template SiSUdocAbstraction() { } } else if (type["tic_poem"] == TriState.on) { if (auto m = matchFirst(line, rgx.block_tic_close)) { // tic_poem_close - an_object["body_nugget"]="verse"; // check that this is as you please + an_object[an_object_key]="verse"; // check that this is as you please debug(poem) { // poem (curly) close writefln( "* [poem tic] %s", @@ -1120,7 +1320,7 @@ template SiSUdocAbstraction() { ); } if (processing.length > 0) { // needs looking at - an_object["body_nugget"] = processing["verse"]; + an_object[an_object_key] = processing["verse"]; } if (an_object.length > 0) { debug(poem) { // poem (tic) close @@ -1130,11 +1330,11 @@ template SiSUdocAbstraction() { processing.remove("verse"); an_object["is"] = "verse"; auto substantive_object_and_anchor_tags_tuple = - obj_im.obj_inline_markup_and_anchor_tags(an_object, dochead_make_aa); + obj_im.obj_inline_markup_and_anchor_tags(an_object, an_object_key, dochead_make_aa); an_object["substantive"] = substantive_object_and_anchor_tags_tuple[0]; anchor_tags = substantive_object_and_anchor_tags_tuple[1]; an_object["attrib"] = - obj_att.obj_attributes(an_object["is"], an_object["body_nugget"], _node); + obj_att.obj_attributes(an_object["is"], an_object[an_object_key], _node); the_document_body_section ~= set_abstract_object.contents_block( an_object["is"], @@ -1162,12 +1362,12 @@ template SiSUdocAbstraction() { } if (type["verse_new"] == State.on) { verse_line=1; - an_object["body_nugget"] = processing["verse"]; + an_object[an_object_key] = processing["verse"]; debug(poem) { // poem (tic) close writefln( "* %s tic\n%s", obj_cite_number, - an_object["body_nugget"] + an_object[an_object_key] ); } processing.remove("verse"); @@ -1182,11 +1382,11 @@ template SiSUdocAbstraction() { an_object["is"] ); auto substantive_object_and_anchor_tags_tuple = - obj_im.obj_inline_markup_and_anchor_tags(an_object, dochead_make_aa); + obj_im.obj_inline_markup_and_anchor_tags(an_object, an_object_key, dochead_make_aa); an_object["substantive"] = substantive_object_and_anchor_tags_tuple[0]; anchor_tags = substantive_object_and_anchor_tags_tuple[1]; an_object["attrib"] = - obj_att.obj_attributes(an_object["is"], an_object["body_nugget"], _node); + obj_att.obj_attributes(an_object["is"], an_object[an_object_key], _node); the_document_body_section ~= set_abstract_object.contents_block( an_object["is"], @@ -1218,7 +1418,7 @@ template SiSUdocAbstraction() { debug(group) { // group writeln(line); } - an_object["body_nugget"] ~= line ~= "\n"; // build group array (or string) + an_object[an_object_key] ~= line ~= "\n"; // build group array (or string) } } else if (type["tic_group"] == TriState.on) { if (matchFirst(line, rgx.block_tic_close)) { @@ -1232,7 +1432,7 @@ template SiSUdocAbstraction() { debug(group) { // group writeln(line); } - an_object["body_nugget"] ~= line ~= "\n"; // build group array (or string) + an_object[an_object_key] ~= line ~= "\n"; // build group array (or string) } } } @@ -1253,7 +1453,7 @@ template SiSUdocAbstraction() { debug(block) { // block writeln(line); } - an_object["body_nugget"] ~= line ~= "\n"; // build block array (or string) + an_object[an_object_key] ~= line ~= "\n"; // build block array (or string) } } else if (type["tic_block"] == TriState.on) { if (matchFirst(line, rgx.block_tic_close)) { @@ -1267,7 +1467,7 @@ template SiSUdocAbstraction() { debug(block) { // block writeln(line); } - an_object["body_nugget"] ~= line ~= "\n"; // build block array (or string) + an_object[an_object_key] ~= line ~= "\n"; // build block array (or string) } } } @@ -1288,7 +1488,7 @@ template SiSUdocAbstraction() { debug(quote) { // quote writeln(line); } - an_object["body_nugget"] ~= line ~= "\n"; // build quote array (or string) + an_object[an_object_key] ~= line ~= "\n"; // build quote array (or string) } } else if (type["tic_quote"] == TriState.on) { if (matchFirst(line, rgx.block_tic_close)) { @@ -1302,7 +1502,7 @@ template SiSUdocAbstraction() { debug(quote) { // quote writeln(line); } - an_object["body_nugget"] ~= line ~= "\n"; // build quote array (or string) + an_object[an_object_key] ~= line ~= "\n"; // build quote array (or string) } } } @@ -1323,7 +1523,7 @@ template SiSUdocAbstraction() { debug(table) { // table writeln(line); } - an_object["body_nugget"] ~= line ~= "\n"; // build table array (or string) + an_object[an_object_key] ~= line ~= "\n"; // build table array (or string) } } else if (type["tic_table"] == TriState.on) { if (matchFirst(line, rgx.block_tic_close)) { @@ -1337,7 +1537,7 @@ template SiSUdocAbstraction() { debug(table) { // table writeln(line); } - an_object["body_nugget"] ~= line ~= "\n"; // build table array (or string) + an_object[an_object_key] ~= line ~= "\n"; // build table array (or string) } } } @@ -1381,11 +1581,11 @@ template SiSUdocAbstraction() { an_object["is"] ); auto substantive_object_and_anchor_tags_tuple = - obj_im.obj_inline_markup_and_anchor_tags(an_object, dochead_make_aa); + obj_im.obj_inline_markup_and_anchor_tags(an_object, an_object_key, dochead_make_aa); an_object["substantive"] = substantive_object_and_anchor_tags_tuple[0]; anchor_tags = substantive_object_and_anchor_tags_tuple[1]; an_object["attrib"] = - obj_att.obj_attributes(an_object["is"], an_object["body_nugget"], _node); + obj_att.obj_attributes(an_object["is"], an_object[an_object_key], _node); the_document_body_section ~= set_abstract_object.contents_block_code( an_object["is"], @@ -1442,11 +1642,11 @@ template SiSUdocAbstraction() { an_object["is"] ); auto substantive_object_and_anchor_tags_tuple = - obj_im.obj_inline_markup_and_anchor_tags(an_object, dochead_make_aa); + obj_im.obj_inline_markup_and_anchor_tags(an_object, an_object_key, dochead_make_aa); an_object["substantive"] = substantive_object_and_anchor_tags_tuple[0]; anchor_tags = substantive_object_and_anchor_tags_tuple[1]; an_object["attrib"] = - obj_att.obj_attributes(an_object["is"], an_object["body_nugget"], _node); + obj_att.obj_attributes(an_object["is"], an_object[an_object_key], _node); the_document_body_section ~= set_abstract_object.contents_block( an_object["is"], @@ -1477,11 +1677,11 @@ template SiSUdocAbstraction() { an_object["is"] ); auto substantive_object_and_anchor_tags_tuple = - obj_im.obj_inline_markup_and_anchor_tags(an_object, dochead_make_aa); + obj_im.obj_inline_markup_and_anchor_tags(an_object, an_object_key, dochead_make_aa); an_object["substantive"] = substantive_object_and_anchor_tags_tuple[0]; anchor_tags = substantive_object_and_anchor_tags_tuple[1]; an_object["attrib"] = - obj_att.obj_attributes(an_object["is"], an_object["body_nugget"], _node); + obj_att.obj_attributes(an_object["is"], an_object[an_object_key], _node); the_document_body_section ~= set_abstract_object.contents_block( an_object["is"], @@ -1511,11 +1711,11 @@ template SiSUdocAbstraction() { an_object["is"] ); auto substantive_object_and_anchor_tags_tuple = - obj_im.obj_inline_markup_and_anchor_tags(an_object, dochead_make_aa); + obj_im.obj_inline_markup_and_anchor_tags(an_object, an_object_key, dochead_make_aa); an_object["substantive"] = substantive_object_and_anchor_tags_tuple[0]; anchor_tags = substantive_object_and_anchor_tags_tuple[1]; an_object["attrib"] = - obj_att.obj_attributes(an_object["is"], an_object["body_nugget"], _node); + obj_att.obj_attributes(an_object["is"], an_object[an_object_key], _node); the_document_body_section ~= set_abstract_object.contents_block( an_object["is"], @@ -1546,11 +1746,11 @@ template SiSUdocAbstraction() { an_object["is"] ); auto substantive_object_and_anchor_tags_tuple = - obj_im.obj_inline_markup_and_anchor_tags(an_object, dochead_make_aa); + obj_im.obj_inline_markup_and_anchor_tags(an_object, an_object_key, dochead_make_aa); an_object["substantive"] = substantive_object_and_anchor_tags_tuple[0]; anchor_tags = substantive_object_and_anchor_tags_tuple[1]; an_object["attrib"] = - obj_att.obj_attributes(an_object["is"], an_object["body_nugget"], _node); + obj_att.obj_attributes(an_object["is"], an_object[an_object_key], _node); the_document_body_section ~= set_abstract_object.contents_block( an_object["is"], @@ -1751,6 +1951,7 @@ template SiSUdocAbstraction() { char[] line, ref int[string] line_occur, ref string[string] an_object, + ref string an_object_key, ref int[string] lv, ref int[string] collapsed_lev, ref int[string] type, @@ -1759,17 +1960,21 @@ template SiSUdocAbstraction() { if (auto m = match(line, rgx.heading)) { /+ heading match +/ type["heading"] = State.on; - type["biblio_section"] = State.off; + if (match(line, rgx.heading_seg_and_above)) { + type["biblio_section"] = State.off; + type["glossary_section"] = State.off; + type["blurb_section"] = State.off; + } type["para"] = State.off; ++line_occur["heading"]; - an_object["body_nugget"] ~= line ~= "\n"; + an_object[an_object_key] ~= line ~= "\n"; an_object["lev"] ~= m.captures[1]; assertions_doc_structure(an_object, lv); // includes most of the logic for collapsed levels switch (an_object["lev"]) { case "A": - an_object["body_nugget"]=replaceFirst(an_object["body_nugget"], + an_object[an_object_key]=replaceFirst(an_object[an_object_key], rgx.variable_doc_title, (dochead_meta_aa["title"]["full"] ~ ",")); - an_object["body_nugget"]=replaceFirst(an_object["body_nugget"], + an_object[an_object_key]=replaceFirst(an_object[an_object_key], rgx.variable_doc_author, dochead_meta_aa["creator"]["author"]); collapsed_lev["h0"] = 1; an_object["lev_collapsed_number"] = @@ -1888,6 +2093,7 @@ template SiSUdocAbstraction() { auto _para_match_( char[] line, ref string[string] an_object, + ref string an_object_key, ref string[string] indent, ref bool bullet, ref int[string] type, @@ -1896,7 +2102,7 @@ template SiSUdocAbstraction() { if (line_occur["para"] == State.off) { /+ para matches +/ type["para"] = State.on; - an_object["body_nugget"] ~= line; + an_object[an_object_key] ~= line; // body_nugget indent=[ "hang_position" : "0", "base_position" : "0", @@ -2120,11 +2326,12 @@ template SiSUdocAbstraction() { string[string] obj_txt; auto obj_inline_markup_and_anchor_tags( string[string] obj_, + string obj_key_, string[string][string] dochead_make_aa ) in { } body { - obj_txt["munge"]=obj_["body_nugget"].dup; + obj_txt["munge"]=obj_[obj_key_].dup; obj_txt["munge"]=(match(obj_["is"], ctRegex!(`verse|code`))) ? obj_txt["munge"] : strip(obj_txt["munge"]); diff --git a/src/sdp/ao_conf_make_meta_native.d b/src/sdp/ao_conf_make_meta_native.d index afcd14e..d95a8dd 100644 --- a/src/sdp/ao_conf_make_meta_native.d +++ b/src/sdp/ao_conf_make_meta_native.d @@ -215,7 +215,7 @@ template SiSUheaderExtractNative() { type["header_make"] = State.on; type["header_meta"] = State.off; ++line_occur["header_make"]; - an_object["nugget"] ~= line ~= "\n"; + an_object["body_nugget"] ~= line ~= "\n"; } else if (matchFirst(line, rgx.native_header)) { /+ matched header_metadata +/ /+ (generic header match and not previously caught by header_make) +/ debug(header1) { /+ writeln(line); +/ } @@ -223,20 +223,20 @@ template SiSUheaderExtractNative() { type["header_make"] = State.off; type["header_meta"] = State.on; ++line_occur["header_meta"]; - an_object["nugget"] ~= line ~= "\n"; + an_object["body_nugget"] ~= line ~= "\n"; } else if (type["header_make"] == State.on && (line_occur["header_make"] > State.off)) { /+ header_make flag set +/ if (matchFirst(line, rgx.native_header_sub)) { /+ sub-header +/ debug(header1) { /+ writeln(line); +/ } ++line_occur["header_make"]; - an_object["nugget"] ~= line ~= "\n"; + an_object["body_nugget"] ~= line ~= "\n"; } } else if (type["header_meta"] == State.on && (line_occur["header_meta"] > State.off)) { /+ header_metadata flag set +/ if (matchFirst(line, rgx.native_header_sub)) { /+ sub-header +/ debug(header1) { /+ writeln(line); +/ } ++line_occur["header_meta"]; - an_object["nugget"] ~= line ~= "\n"; + an_object["body_nugget"] ~= line ~= "\n"; } } return an_object; @@ -249,7 +249,7 @@ template SiSUheaderExtractNative() { line_occur["header_make"] = State.off; line_occur["header_meta"] = State.off; type["header"] = State.off; - an_object.remove("nugget"); + an_object.remove("body_nugget"); an_object.remove("is"); an_object.remove("attrib"); } @@ -281,7 +281,7 @@ template SiSUheaderExtractNative() { if (header_line.length == 0) { /+ header_make instructions (current line empty) +/ auto dochead_metadata_and_make = - set_header.header_metadata_and_make_aa(strip(an_object["nugget"]), dochead_meta, dochead_make); + set_header.header_metadata_and_make_aa(strip(an_object["body_nugget"]), dochead_meta, dochead_make); static assert(!isTypeTuple!(dochead_metadata_and_make)); dochead_meta = dochead_metadata_and_make[0]; dochead_make = dochead_metadata_and_make[1]; diff --git a/src/sdp/ao_defaults.d b/src/sdp/ao_defaults.d index a53b827..3255c99 100644 --- a/src/sdp/ao_defaults.d +++ b/src/sdp/ao_defaults.d @@ -320,7 +320,8 @@ template SiSUrgxInitFlags() { "header_meta" : 0, "heading" : 0, "biblio_section" : 0, - // "glossary_section" : 0, // TODO + "glossary_section" : 0, + "blurb_section" : 0, "para" : 0, "blocks" : 0, // 0..2 generic "code" : 0, // 0..2 @@ -383,7 +384,7 @@ template SiSUbiblio() { } template InternalMarkup() { struct InlineMarkup { - auto en_a_o = "【"; auto en_a_c = "】"; // endnote en_a_o: '~{'; en_a_c: '}~' - auto en_b_o = "〖"; auto en_b_c = "〗"; // endnote en_b_o: '~['; en_b_c: ']~' + auto en_a_o = "【"; auto en_a_c = "】"; + auto en_b_o = "〖"; auto en_b_c = "〗"; } } diff --git a/src/sdp/ao_output_debugs.d b/src/sdp/ao_output_debugs.d index eefec9d..3bb8ae2 100644 --- a/src/sdp/ao_output_debugs.d +++ b/src/sdp/ao_output_debugs.d @@ -5,8 +5,9 @@ template SiSUoutputDebugs() { struct SDPoutputDebugs { auto abstract_doc_source_debugs(S)( auto ref const S contents, - string[][string][string] bookindex_unordered_hashes, - JSONValue[] biblio, + string[][string] document_section_keys_sequenced, + string[][string][string] bookindex_unordered_hashes, // redundant, consider + JSONValue[] biblio, // redundant, consider string[string][string] dochead_make, string[string][string] dochead_meta, string fn_src, @@ -44,17 +45,18 @@ template SiSUoutputDebugs() { __FILE__, __LINE__, ); - foreach (obj; contents) { - if (obj.use == "content") { - if (obj.is_a == "heading") { - writefln( - "%s node: %s heading: %s %s", - obj.obj_cite_number, - obj.node, - obj.lev_markup_number, - obj.object, - ); - } else { + foreach (key; document_section_keys_sequenced["seg"]) { + foreach (obj; contents[key]) { + if (obj.use == "content") { + if (obj.is_a == "heading") { + writefln( + "%s node: %s heading: %s %s", + obj.obj_cite_number, + obj.node, + obj.lev_markup_number, + obj.object, + ); + } } } } @@ -271,53 +273,65 @@ template SiSUoutputDebugs() { __FILE__, __LINE__, ); - foreach (obj; contents) { - if (obj.is_a == "heading") { - writefln( - "%s~ [%s] %s %s", - obj.heading_attrib.lev, - obj.obj_cite_number, - obj.anchor_tags, - obj.object - ); + foreach (key; document_section_keys_sequenced["seg"]) { + foreach (obj; contents[key]) { + if (obj.is_a == "heading") { + writefln( + "%s~ [%s] %s %s", + obj.heading_attrib.lev, + obj.obj_cite_number, + obj.anchor_tags, + // "[", obj["is"], "] ", + obj.object + ); + } } } } debug(heading) { // heading string spc; - foreach (o; contents) { - if (o.is_a == "heading") { - switch (o.heading_attrib.lev_markup_number) { - case 0: - spc=""; - break; - case 1: - spc=" "; - break; - case 2: - spc=" "; - break; - case 3: - spc=" "; - break; - case 4: - spc=" "; - break; - case 5: - spc=" "; - break; - case 6: - spc=" "; - break; - case 7: - spc=" "; - break; - case 8: - spc=" "; - break; - default: - spc=""; - break; + foreach (key; document_section_keys_sequenced["seg"]) { + foreach (o; contents[key]) { + if (o.is_a == "heading") { + switch (o.heading_attrib.lev_markup_number) { + case 0: + spc=""; + break; + case 1: + spc=" "; + break; + case 2: + spc=" "; + break; + case 3: + spc=" "; + break; + case 4: + spc=" "; + break; + case 5: + spc=" "; + break; + case 6: + spc=" "; + break; + case 7: + spc=" "; + break; + case 8: + spc=" "; + break; + default: + spc=""; + break; + } + writefln( + "%s* %s\n (markup level: %s; collapsed level: %s)", + spc, + strip(o.object), + o.heading_attrib.lev_markup_number, + o.heading_attrib.lev_collapsed_number + ); } writefln( "%s* %s\n (markup level: %s; collapsed level: %s)", @@ -340,41 +354,50 @@ template SiSUoutputDebugs() { __FILE__, __LINE__, ); - foreach (obj; contents) { - if (obj.is_a == "heading") { - writefln( - "%s~ [%s] %s", - obj.heading_attrib.lev, - obj.obj_cite_number, - obj.object - ); + foreach (key; document_section_keys_sequenced["seg"]) { + foreach (obj; contents[key]) { + if (obj.is_a == "heading") { + writefln( + "%s~ [%s] %s", + obj.heading_attrib.lev, + obj.obj_cite_number, + // "[", obj["is"], "] ", + obj.object + ); + } } } } debug(checkdoc) { - foreach (obj; contents) { - if (obj.use == "content") { - if (!empty(obj.obj_cite_number)) { - check["last_obj_cite_number"] = obj.obj_cite_number; + foreach (key; document_section_keys_sequenced["seg"]) { + foreach (obj; contents[key]) { + if (obj.use == "content") { + if (!empty(obj.obj_cite_number)) { + check["last_obj_cite_number"] = obj.obj_cite_number; + } } } } } writefln( - "%s\n\"%s\", %s\n%s\n%s\n%s%s\n%s%s\n%s%s\n%s:%s", + "%s\n\"%s\", %s\n%s\n%s\n%s%s\n%s%s\n%s%s\n%s%s\n%s%s\n%s%s\n%s:%s\n", "-------------------------------", dochead_meta["title"]["full"], dochead_meta["creator"]["author"], "-------------------------------", fn_src, "length contents array: ", - contents.length, + contents["body"].length, "last obj_cite_number: ", check["last_obj_cite_number"], - "length bookindex: ", - bookindex_unordered_hashes.length, + "length glossary: ", + contents["glossary"].length, "length biblio: ", - biblio.length, + contents["bibliography"].length, + "length bookindex: ", + contents["bookindex_seg"].length, + "length blurb: ", + contents["blurb"].length, __FILE__, __LINE__, ); diff --git a/src/sdp/ao_rgx.d b/src/sdp/ao_rgx.d index 7d44b85..c58aeca 100644 --- a/src/sdp/ao_rgx.d +++ b/src/sdp/ao_rgx.d @@ -60,6 +60,7 @@ template RgxInit() { /+ heading & paragraph operators +/ static heading_a = ctRegex!(`^:?[A][~] `, "m"); static heading = ctRegex!(`^:?([A-D1-4])[~]([a-z0-9_.-]*[?]?)\s+`,"i"); + static heading_seg_and_above = ctRegex!(`^:?([A-D1])[~]([a-z0-9_.-]*[?]?)\s+`,"i"); static heading_marker = ctRegex!(`^:?([A-D1-4])[~]`); static heading_anchor_tag = ctRegex!(`^:?[A-D1-4][~]([a-z0-9_.-]+) `,"i"); static heading_identify_anchor_tag = ctRegex!(`^:?[A-D1-4][~]\s+(?:(?:(?:chapter|article|section|clause)\s+[0-9.]+)|(?:[0-9]+))`,"i"); // unless dob.obj =~/^:?[A-D1-4]~\s+(?:|(?:chapter|article|section|clause)\s+)([0-9.]+)/i @@ -68,8 +69,10 @@ template RgxInit() { static heading_marker_missing_tag = ctRegex!(`^:?([A-D1-4])[~] `); static heading_title = ctRegex!(`^:?[A-D1-4][~][a-z0-9_.-]*[?]?\s+(.+?)$`); static heading_all = ctRegex!(`^:?([A-D1-4])[~]([a-z0-9_.-]*[?]?)\s+(.+?)$`); // test, particularly [2] name/hashtag which may or may not be, does this affect title [3] + static heading_backmatter = ctRegex!(`^:?1[~][!](glossary|bibliography|biblio|blurb)\s+`,"i"); static heading_biblio = ctRegex!(`^:?(1)[~][!](biblio(?:graphy)?|references?)`); static heading_glossary = ctRegex!(`^:?(1)[~][!](glossary)`); + static heading_blurb = ctRegex!(`^:?(1)[~][!](blurb)`); static para_bullet = ctRegex!(`^_[*] `); static para_bullet_indent = ctRegex!(`^_([1-9])[*] `); static para_indent = ctRegex!(`^_([1-9]) `); diff --git a/src/sdp/output_html.d b/src/sdp/output_html.d index d6a3b8c..ce5684f 100644 --- a/src/sdp/output_html.d +++ b/src/sdp/output_html.d @@ -42,7 +42,7 @@ template SiSUoutputHTML() { ); return o; } - auto scroll_head() { + auto scroll_head_html() { string o; o = format(q"◎ @@ -75,7 +75,7 @@ template SiSUoutputHTML() { ◎"); return o; } - auto scroll_tail() { + auto scroll_tail_html() { string o; o = format(q"◎ @@ -88,54 +88,51 @@ template SiSUoutputHTML() { } void scroll(C)( auto ref const C contents, - string[] document_parts, - string[][string][string] bookindex_unordered_hashes, - JSONValue[] biblio, + string[][string] document_section_keys_sequenced, string[string][string] dochead_make, string[string][string] dochead_meta, string fn_src, bool[string] opt_action_bool ) { auto rgx = Rgx(); - string[] toc; - string[] body_; + string[] body_html; string[] doc; - foreach (part; document_parts) { + foreach (part; document_section_keys_sequenced["scroll"]) { foreach (obj; contents[part]) { if (obj.use == "content") { switch (obj.is_a) { case "heading": - body_ ~= html_heading(obj); + body_html ~= html_heading(obj); break; case "para": - body_ ~= html_para(obj); + body_html ~= html_para(obj); break; case "verse": - body_ ~= html_para(obj); + body_html ~= html_para(obj); break; case "group": - body_ ~= html_para(obj); + body_html ~= html_para(obj); break; case "block": - body_ ~= html_para(obj); + body_html ~= html_para(obj); break; case "quote": - body_ ~= html_para(obj); + body_html ~= html_para(obj); break; case "table": - body_ ~= html_para(obj); + body_html ~= html_para(obj); break; case "code": - body_ ~= html_para(obj); + body_html ~= html_para(obj); break; default: - body_ ~= html_para(obj); + body_html ~= html_para(obj); break; } } } } - doc = scroll_head ~ body_ ~ scroll_tail; + doc = scroll_head_html ~ body_html ~ scroll_tail_html; auto m = matchFirst(fn_src, rgx.src_fn); auto fn = m["fn_base"] ~ ".html"; auto pth_html = "en/html"; diff --git a/src/sdp/output_hub.d b/src/sdp/output_hub.d index db508ff..bdb8480 100644 --- a/src/sdp/output_hub.d +++ b/src/sdp/output_hub.d @@ -6,15 +6,13 @@ template SiSUoutputHub() { struct SDPoutput { void hub(S)( auto ref const S contents, - string[][string][string] bookindex_unordered_hashes, - JSONValue[] biblio, + string[][string] document_section_keys_sequenced, string[string][string] dochead_make, string[string][string] dochead_meta, string fn_src, bool[string] opt_action_bool ) { auto rgx = Rgx(); - string[] document_parts; if (opt_action_bool["source"]) { writeln("sisupod source"); } @@ -27,20 +25,10 @@ template SiSUoutputHub() { if (opt_action_bool["html"]) { mixin SiSUoutputHTML; auto html=SDPoutputHTML(); - document_parts = [ - "head", - "toc_scroll", - "body", - "endnotes_scroll", - "bibliography", - "bookindex_scroll" - ]; html.css_write; html.scroll( contents, - document_parts, - bookindex_unordered_hashes, - biblio, + document_section_keys_sequenced, dochead_make, dochead_meta, fn_src, -- cgit v1.2.3