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 --- org/ao_abstract_doc_source.org | 364 +++++++++++++++++++++++++++++++------ org/ao_conf_make_meta.org | 12 +- org/ao_defaults.org | 9 +- org/ao_output_debugs.org | 169 +++++++++-------- org/output.org | 49 ++--- org/sdp.org | 79 ++++++-- 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 +- views/version.txt | 2 +- 15 files changed, 945 insertions(+), 372 deletions(-) diff --git a/org/ao_abstract_doc_source.org b/org/ao_abstract_doc_source.org index 4b6adb1..6b1906d 100644 --- a/org/ao_abstract_doc_source.org +++ b/org/ao_abstract_doc_source.org @@ -45,8 +45,9 @@ mixin InternalMarkup; /+ 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(); @@ -125,8 +126,10 @@ scope(exit) { #+name: abs_init_rest #+BEGIN_SRC d 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) { @@ -182,6 +185,22 @@ auto heading_match_rgx = [ "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], +]; #+END_SRC ** _2. loop: process document body_ [+6] :loop: @@ -248,6 +267,9 @@ if ((matchFirst(line, rgx.heading_biblio) && (!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); @@ -255,6 +277,159 @@ if ((matchFirst(line, rgx.heading_biblio) continue; #+END_SRC +****** TODO within section: glossary :glossary: + +if there is a glossary section you need to: +- extract it +- create standard headings +- markup contents in standard way like regular paragraphs + - need indentation and regular paragraph inline markup +- reconstitute the document with the glossary section following the endnotes + +#+name: abs_in_loop_body_non_code_obj +#+BEGIN_SRC d +} 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; +#+END_SRC + +****** TODO within section: blurb :blurb: + +if there is a blurb section you need to: +- extract it +- create standard headings (or use line provided in 1~ heading) +- markup contents in standard way like regular paragraphs + - need regular paragraph inline markup +- reconstitute the document with the blurb section at the very end of the doucment + +#+name: abs_in_loop_body_non_code_obj +#+BEGIN_SRC d +} 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; +#+END_SRC + +***** in block group [+1] :block:active: ****** within block group: poem :poem: #+name: abs_in_loop_body_non_code_obj @@ -385,14 +560,15 @@ if ((matchFirst(line, rgx.book_index)) #+name: abs_in_loop_body_not_block_obj #+BEGIN_SRC d + 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; @@ -429,10 +605,11 @@ if ((matchFirst(line, rgx.book_index)) +/ 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); } #+END_SRC @@ -445,7 +622,7 @@ if ((matchFirst(line, rgx.book_index)) debug(heading) { // heading writeln(line); } - an_object["body_nugget"] ~= line ~= "\n"; + an_object[an_object_key] ~= line ~= "\n"; ++line_occur["heading"]; #+END_SRC @@ -458,7 +635,7 @@ if ((matchFirst(line, rgx.book_index)) debug(para) { writeln(line); } - an_object["body_nugget"] ~= line; + an_object[an_object_key] ~= line; ++line_occur["para"]; } } @@ -511,8 +688,9 @@ if ((type["heading"] == State.on) 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) { @@ -538,7 +716,7 @@ if ((type["heading"] == State.on) 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"]); @@ -587,11 +765,11 @@ if ((type["heading"] == State.on) 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"], @@ -629,6 +807,12 @@ if (the_document_body_section.length > 0) { 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; @@ -658,7 +842,7 @@ debug(objectrelated2) { // check * 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); #+END_SRC *** document sections @@ -699,9 +883,59 @@ debug(endnotes) { } #+END_SRC -**** glossary section? +**** TODO glossary section? -**** TODO [#B] bibliography section (objects) :bibliography: +#+name: abs_post +#+BEGIN_SRC d +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); + } +} +#+END_SRC + +**** TODO blurb section? + +#+name: abs_post +#+BEGIN_SRC d +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); + } +} +#+END_SRC + +**** DONE [#B] bibliography section (objects) :bibliography: #+name: abs_post #+BEGIN_SRC d @@ -856,10 +1090,11 @@ auto document_the = [ "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, ]; #+END_SRC @@ -1160,7 +1395,7 @@ void _code_block_( 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)) { @@ -1174,7 +1409,7 @@ void _code_block_( 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 } } } @@ -1277,6 +1512,8 @@ void _biblio_block_( ) { 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 { @@ -1403,7 +1640,7 @@ void _poem_block_( ) { 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", @@ -1411,7 +1648,7 @@ void _poem_block_( ); } if (processing.length > 0) { - an_object["body_nugget"] = processing["verse"]; + an_object[an_object_key] = processing["verse"]; } debug(poem) { // poem (curly) close writeln(__LINE__); @@ -1425,16 +1662,16 @@ void _poem_block_( 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"], @@ -1463,12 +1700,12 @@ void _poem_block_( } 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"); @@ -1482,11 +1719,11 @@ void _poem_block_( 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"], @@ -1501,7 +1738,7 @@ void _poem_block_( } } 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", @@ -1509,7 +1746,7 @@ void _poem_block_( ); } 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 @@ -1519,11 +1756,11 @@ void _poem_block_( 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"], @@ -1551,12 +1788,12 @@ void _poem_block_( } 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"); @@ -1571,11 +1808,11 @@ void _poem_block_( 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"], @@ -1613,7 +1850,7 @@ void _group_block_( 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)) { @@ -1627,7 +1864,7 @@ void _group_block_( 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) } } } @@ -1654,7 +1891,7 @@ void _block_block_( 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)) { @@ -1668,7 +1905,7 @@ void _block_block_( 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) } } } @@ -1695,7 +1932,7 @@ void _quote_block_( 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)) { @@ -1709,7 +1946,7 @@ void _quote_block_( 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) } } } @@ -1736,7 +1973,7 @@ void _table_block_( 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)) { @@ -1750,7 +1987,7 @@ void _table_block_( 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) } } } @@ -1800,11 +2037,11 @@ void _block_flag_line_empty_( 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"], @@ -1861,11 +2098,11 @@ void _block_flag_line_empty_( 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"], @@ -1896,11 +2133,11 @@ void _block_flag_line_empty_( 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"], @@ -1930,11 +2167,11 @@ void _block_flag_line_empty_( 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"], @@ -1965,11 +2202,11 @@ void _block_flag_line_empty_( 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"], @@ -2195,6 +2432,7 @@ auto _heading_matched_( 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, @@ -2203,17 +2441,21 @@ auto _heading_matched_( 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"] = @@ -2338,6 +2580,7 @@ auto _heading_matched_( 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, @@ -2346,7 +2589,7 @@ auto _para_match_( 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", @@ -2595,11 +2838,12 @@ struct ObjInlineMarkup { #+BEGIN_SRC d 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/org/ao_conf_make_meta.org b/org/ao_conf_make_meta.org index 91630c0..d3413de 100644 --- a/org/ao_conf_make_meta.org +++ b/org/ao_conf_make_meta.org @@ -401,7 +401,7 @@ private auto native_header_extract( 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); +/ } @@ -409,20 +409,20 @@ private auto native_header_extract( 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; @@ -441,7 +441,7 @@ auto header_reset_states_common( 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"); } @@ -479,7 +479,7 @@ private auto headerNativeToAA(in char[] src_header) { 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/org/ao_defaults.org b/org/ao_defaults.org index 17d04b8..045e1e3 100644 --- a/org/ao_defaults.org +++ b/org/ao_defaults.org @@ -357,6 +357,8 @@ template SiSUrgxInitFlags() { "header_meta" : 0, "heading" : 0, "biblio_section" : 0, + "glossary_section" : 0, + "blurb_section" : 0, "para" : 0, "blocks" : 0, // 0..2 generic "code" : 0, // 0..2 @@ -431,8 +433,8 @@ template SiSUbiblio() { #+BEGIN_SRC d 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 = "〗"; } } #+END_SRC @@ -535,6 +537,7 @@ static native_subhead_make = ctRegex!(`^(?:cover_image|home_button_ /+ 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 @@ -543,8 +546,10 @@ static heading_extract_unnamed_anchor_tag = ctRegex!(`^:?[A-D1-4][~]\s+((?:[0-9] 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/org/ao_output_debugs.org b/org/ao_output_debugs.org index 4b5af0c..b13bdce 100644 --- a/org/ao_output_debugs.org +++ b/org/ao_output_debugs.org @@ -55,17 +55,18 @@ debug(parent) { __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, + ); + } } } } @@ -324,59 +325,71 @@ debug(anchor) { __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 + ); + } } } } #+END_SRC -** (headings) :headings: +** (headings) :headings: #+name: ao_output_debugs #+BEGIN_SRC d 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)", @@ -401,14 +414,17 @@ debug(headings) { __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 + ); + } } } } @@ -427,10 +443,12 @@ debug(summary) { #+name: ao_output_debugs_summary #+BEGIN_SRC d 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; + } } } } @@ -442,20 +460,24 @@ debug(checkdoc) { #+name: ao_output_debugs_summary #+BEGIN_SRC d 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__, ); @@ -606,8 +628,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, diff --git a/org/output.org b/org/output.org index a9ad6fd..073e56f 100644 --- a/org/output.org +++ b/org/output.org @@ -78,7 +78,7 @@ auto html_para(O)( #+name: output_html #+BEGIN_SRC d -auto scroll_head() { +auto scroll_head_html() { string o; o = format(q"◎ @@ -111,7 +111,7 @@ auto scroll_head() { ◎"); return o; } -auto scroll_tail() { +auto scroll_tail_html() { string o; o = format(q"◎ @@ -130,54 +130,51 @@ auto scroll_tail() { #+BEGIN_SRC d 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"; @@ -1522,15 +1519,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"); } @@ -1543,20 +1538,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, diff --git a/org/sdp.org b/org/sdp.org index a3e67a2..c1157eb 100644 --- a/org/sdp.org +++ b/org/sdp.org @@ -24,7 +24,7 @@ struct Version { int minor; int patch; } -enum ver = Version(0, 8, 0); +enum ver = Version(0, 9, 0); #+END_SRC * sdp.d sisu document parser :sdp.d: @@ -360,27 +360,79 @@ string[string][string] dochead_meta = header_make_and_meta_tuple[1]; /+ ↓ 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? #+END_SRC + +#+NAME: sdp_each_file_do_document_abstraction +#+BEGIN_SRC d +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"; +} +#+END_SRC + **** TODO debug (document parts, checkdoc) :debug:checkdoc: #+NAME: sdp_each_file_do_debugs_checkdoc #+BEGIN_SRC d /+ ↓ 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, @@ -398,8 +450,7 @@ debug(checkdoc) { // checkbook & dumpdoc /+ ↓ 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.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, diff --git a/views/version.txt b/views/version.txt index 4ac5253..80a3477 100644 --- a/views/version.txt +++ b/views/version.txt @@ -4,4 +4,4 @@ struct Version { int minor; int patch; } -enum ver = Version(0, 8, 0); +enum ver = Version(0, 9, 0); -- cgit v1.2.3