From f07892081b81ada7c03d90e9f89a00df0866ca30 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Tue, 25 Jul 2017 04:25:16 -0400 Subject: meta_abstraction, work on ocn --- src/sdp/meta/metadoc_from_src.d | 328 +++++++++++++++++++++++----------------- 1 file changed, 189 insertions(+), 139 deletions(-) (limited to 'src/sdp/meta/metadoc_from_src.d') diff --git a/src/sdp/meta/metadoc_from_src.d b/src/sdp/meta/metadoc_from_src.d index d5ff450..82c6249 100644 --- a/src/sdp/meta/metadoc_from_src.d +++ b/src/sdp/meta/metadoc_from_src.d @@ -47,6 +47,8 @@ template SiSUdocAbstraction() { h_text_5, // extra level, drop content_non_header } // header section A-D; header text 1-4 + enum OCNstatus { inc, exc, bkidx, closing, reset, } + enum OCNtype { ocn, non, bkidx, } /+ biblio variables +/ string biblio_tag_name, biblio_tag_entry, st; string[] biblio_arr_json; @@ -67,7 +69,7 @@ template SiSUdocAbstraction() { static auto obj_im = ObjInlineMarkup(); static auto obj_att = ObjAttributes(); /+ ocn +/ - int obj_cite_number, obj_cite_number_; + int obj_cite_digit, obj_cite_digit_, obj_cite_digit_bkidx; auto object_citation_number = OCNemitter(); int[] dom_markedup = [ 0, 0, 0, 0, 0, 0, 0, 0, 0,]; int[] dom_markedup_buffer = [ 0, 0, 0, 0, 0, 0, 0, 0, 0,]; @@ -481,7 +483,7 @@ template SiSUdocAbstraction() { comp_obj_para.bullet = bullet; the_glossary_section ~= comp_obj_para; } - obj_type_status["ocn_status"] = TriState.off; + obj_type_status["ocn_status"] = OCNstatus.inc; } continue; } else if (line.matchFirst(rgx.heading_blurb) @@ -574,7 +576,7 @@ template SiSUdocAbstraction() { comp_obj_para.bullet = bullet; the_blurb_section ~= comp_obj_para; } - obj_type_status["ocn_status"] = TriState.off; + obj_type_status["ocn_status"] = OCNstatus.inc; } continue; } else if (obj_type_status["quote"] == TriState.on) { @@ -621,7 +623,7 @@ template SiSUdocAbstraction() { /+ poem to verse exceptions! +/ object_reset(an_object); processing.remove("verse"); - obj_cite_number_poem["start"] = obj_cite_number.to!string; + obj_cite_number_poem["start"] = obj_cite_digit.to!string; } _start_block_(line, obj_type_status, obj_cite_number_poem); continue; @@ -730,7 +732,7 @@ template SiSUdocAbstraction() { an_object, the_document_body_section, bookindex_unordered_hashes, - obj_cite_number, + obj_cite_digit, comp_obj_heading, cntr, obj_type_status, @@ -751,9 +753,9 @@ template SiSUdocAbstraction() { if ((obj_type_status["heading"] == State.on) && (line_occur["heading"] > State.off)) { /+ heading object (current line empty) +/ - obj_cite_number = (an_object["lev_markup_number"].to!int == 0) - ? (ocn_emit(3)) - : (obj_cite_number = ocn_emit(obj_type_status["ocn_status"])); + obj_cite_digit = (an_object["lev_markup_number"].to!int == 0) + ? (ocn_emit(OCNstatus.reset)) + : (obj_cite_digit = ocn_emit(obj_type_status["ocn_status"])); an_object["is"] = "heading"; an_object_key="body_nugget"; auto substantive_object_and_anchor_tags_tuple = @@ -766,7 +768,7 @@ template SiSUdocAbstraction() { anchor_tag_ = anchor_tags[0]; } else if (an_object["lev_markup_number"].to!int > 4) { segment_anchor_tag_that_object_belongs_to = anchor_tag_; - segment_anchor_tag_that_object_belongs_to_uri = anchor_tag_ ~ ".fnSuffix#" ~ obj_cite_number.to!string; + segment_anchor_tag_that_object_belongs_to_uri = anchor_tag_ ~ ".fnSuffix#" ~ obj_cite_digit.to!string; } else if (an_object["lev_markup_number"].to!int < 4) { string segn; switch (an_object["lev_markup_number"].to!int) { @@ -794,9 +796,9 @@ template SiSUdocAbstraction() { an_object["bookindex_nugget"] = ("bookindex_nugget" in an_object) ? an_object["bookindex_nugget"] : ""; bookindex_unordered_hashes = - bookindex_extract_hash.bookindex_nugget_hash(an_object["bookindex_nugget"], obj_cite_number, segment_anchor_tag_that_object_belongs_to); + bookindex_extract_hash.bookindex_nugget_hash(an_object["bookindex_nugget"], obj_cite_digit, segment_anchor_tag_that_object_belongs_to); /+ (incrementally build toc) table of contents here! +/ - _anchor_tag=to!string(obj_cite_number); + _anchor_tag=to!string(obj_cite_digit); the_table_of_contents_section = obj_im.table_of_contents_gather_headings( an_object, dochead_make_aa, @@ -817,7 +819,7 @@ template SiSUdocAbstraction() { an_object["lev_markup_number"], // string an_object["lev_collapsed_number"], // string segment_anchor_tag_that_object_belongs_to, // string - obj_cite_number, // int + obj_cite_digit, // int cntr, // int heading_ptr, // int lv_ancestors_txt, // string[] @@ -844,17 +846,17 @@ template SiSUdocAbstraction() { } else if ((obj_type_status["para"] == State.on) && (line_occur["para"] > State.off)) { /+ paragraph object (current line empty) +/ - obj_cite_number = ocn_emit(obj_type_status["ocn_status"]); + obj_cite_digit = ocn_emit(obj_type_status["ocn_status"]); an_object["bookindex_nugget"] = ("bookindex_nugget" in an_object) ? an_object["bookindex_nugget"] : ""; bookindex_unordered_hashes = - bookindex_extract_hash.bookindex_nugget_hash(an_object["bookindex_nugget"], obj_cite_number, segment_anchor_tag_that_object_belongs_to); + bookindex_extract_hash.bookindex_nugget_hash(an_object["bookindex_nugget"], obj_cite_digit, segment_anchor_tag_that_object_belongs_to); an_object["is"] = "para"; auto comp_obj_heading = node_construct.node_location_emitter( content_non_header, segment_anchor_tag_that_object_belongs_to, - obj_cite_number, + obj_cite_digit, cntr, heading_ptr-1, an_object["is"], @@ -869,8 +871,8 @@ template SiSUdocAbstraction() { comp_obj_para.is_of = "para"; comp_obj_para.is_a = "para"; comp_obj_para.text = an_object["substantive"].to!string.strip; - comp_obj_para.ocn = obj_cite_number; - comp_obj_para.obj_cite_number = (obj_cite_number==0) ? "" : obj_cite_number.to!string; + comp_obj_para.ocn = obj_cite_digit; + comp_obj_para.obj_cite_number = (obj_cite_digit==0) ? "" : obj_cite_digit.to!string; comp_obj_para.indent_hang = indent["hang_position"]; comp_obj_para.indent_base = indent["base_position"]; comp_obj_para.bullet = bullet; @@ -921,7 +923,7 @@ template SiSUdocAbstraction() { note_section.gather_notes_for_endnote_section( the_document_body_section, segment_anchor_tag_that_object_belongs_to, - to!int(i), + (i).to!int, ); } } @@ -936,7 +938,7 @@ template SiSUdocAbstraction() { note_section.gather_notes_for_endnote_section( the_document_body_section, segment_anchor_tag_that_object_belongs_to, - to!int(the_document_body_section.length-1), + (the_document_body_section.length-1).to!int, ); } } @@ -946,10 +948,10 @@ template SiSUdocAbstraction() { } /+ ← closed: loop markup document/text line by line +/ /+ ↓ post loop markup document/text +/ auto en_tuple = - note_section.endnote_objects(obj_cite_number, opt_action); + note_section.endnote_objects(obj_cite_digit, opt_action); static assert(!isTypeTuple!(en_tuple)); auto the_endnotes_section = en_tuple[0]; - obj_cite_number = en_tuple[1]; + obj_cite_digit = en_tuple[1]; debug(endnotes) { writefln( "%s %s", @@ -1074,13 +1076,13 @@ template SiSUdocAbstraction() { auto bi_tuple = bi.bookindex_build_abstraction_section( bookindex_unordered_hashes, - obj_cite_number, + obj_cite_digit, opt_action, ); destroy(bookindex_unordered_hashes); static assert(!isTypeTuple!(bi_tuple)); auto the_bookindex_section = bi_tuple[0]; - obj_cite_number = bi_tuple[1]; + obj_cite_digit = bi_tuple[1]; debug(bookindex) { foreach (bi_entry; the_bookindex_section["seg"]) { writeln(bi_entry); @@ -1468,6 +1470,9 @@ template SiSUdocAbstraction() { debug(dom) { writeln(obj.text); } + obj_cite_digit = ocn_emit(OCNstatus.inc); + obj.ocn = obj_cite_digit; + obj.obj_cite_number = obj_cite_digit.to!string; if (obj.heading_lev_markup <= 4) { segnames_0_4 ~= obj.segment_anchor_tag; if (obj.heading_lev_markup == 4) { @@ -1489,6 +1494,10 @@ template SiSUdocAbstraction() { obj = obj_dom_set_collapsed_tags(obj, dom_collapsed, obj.heading_lev_collapsed); } obj = obj_heading_ancestors(obj, lv_ancestors_txt); + } else if (obj.is_a == "glossary") { + obj_cite_digit = ocn_emit(OCNstatus.inc); + obj.ocn = obj_cite_digit; + obj.obj_cite_number = obj_cite_digit.to!string; } } } @@ -1499,6 +1508,9 @@ template SiSUdocAbstraction() { debug(dom) { writeln(obj.text); } + obj_cite_digit = ocn_emit(OCNstatus.inc); + obj.ocn = obj_cite_digit; + obj.obj_cite_number = obj_cite_digit.to!string; if (obj.heading_lev_markup <= 4) { segnames_0_4 ~= obj.segment_anchor_tag; if (obj.heading_lev_markup == 4) { @@ -1520,10 +1532,17 @@ template SiSUdocAbstraction() { obj = obj_dom_set_collapsed_tags(obj, dom_collapsed, obj.heading_lev_collapsed); } obj = obj_heading_ancestors(obj, lv_ancestors_txt); + } else if (obj.is_a == "bibliography") { + obj_cite_digit = ocn_emit(OCNstatus.inc); + obj.ocn = obj_cite_digit; + obj.obj_cite_number = obj_cite_digit.to!string; } } } /+ optional only one 1~ level +/ + int ocn_ = obj_cite_digit; + int ocn_bkidx_ = 0; + int ocn_bidx_; if (the_bookindex_section["scroll"].length > 1) { /+ scroll +/ dom_markedup_buffer = dom_markedup.dup; @@ -1532,6 +1551,9 @@ template SiSUdocAbstraction() { if (obj.is_a == "heading") { debug(dom) { } + obj_cite_digit = ocn_emit(OCNstatus.inc); + obj.ocn = obj_cite_digit; + obj.obj_cite_number = obj_cite_digit.to!string; if (obj.heading_lev_markup <= 4) { segnames_0_4 ~= obj.segment_anchor_tag; if (obj.heading_lev_markup == 4) { @@ -1553,6 +1575,10 @@ template SiSUdocAbstraction() { obj = obj_dom_set_collapsed_tags(obj, dom_collapsed, obj.heading_lev_collapsed); } obj = obj_heading_ancestors(obj, lv_ancestors_txt); + } else if (obj.is_a == "bookindex") { + obj_cite_digit_bkidx = ocn_emit(OCNstatus.bkidx); + obj.obj_cite_number_bkidx = obj_cite_digit_bkidx.to!string; // FIX need to distinguish from regular ocn + obj.obj_cite_number_type = OCNtype.bkidx; } } /+ seg +/ @@ -1563,6 +1589,8 @@ template SiSUdocAbstraction() { debug(dom) { writeln(obj.text); } + obj.ocn = ++ocn_; + obj.obj_cite_number = obj.ocn.to!string; if (obj.heading_lev_markup <= 4) { segnames_0_4 ~= obj.segment_anchor_tag; if (obj.heading_lev_markup == 4) { @@ -1584,8 +1612,14 @@ template SiSUdocAbstraction() { obj = obj_dom_set_collapsed_tags(obj, dom_collapsed, obj.heading_lev_collapsed); } obj = obj_heading_ancestors(obj, lv_ancestors_txt); + } else if (obj.is_a == "bookindex") { + ocn_bidx_ = ++ocn_bkidx_; + obj.obj_cite_number_bkidx = ocn_bidx_.to!string; // FIX need to distinguish from regular ocn + obj.obj_cite_number_type = OCNtype.bkidx; } } + assert(obj_cite_digit == ocn_); + assert(obj_cite_digit_bkidx == ocn_bidx_); } /+ optional only one 1~ level +/ if (the_blurb_section.length > 1) { @@ -1594,6 +1628,9 @@ template SiSUdocAbstraction() { debug(dom) { writeln(obj.text); } + obj_cite_digit = ocn_emit(OCNstatus.inc); + obj.ocn = obj_cite_digit; + obj.obj_cite_number = obj_cite_digit.to!string; if (obj.heading_lev_markup <= 4) { segnames_0_4 ~= obj.segment_anchor_tag; if (obj.heading_lev_markup == 4) { @@ -1615,6 +1652,10 @@ template SiSUdocAbstraction() { obj = obj_dom_set_collapsed_tags(obj, dom_collapsed, obj.heading_lev_collapsed); } obj = obj_heading_ancestors(obj, lv_ancestors_txt); + } else if (obj.is_a == "blurb") { + obj_cite_digit = ocn_emit(OCNstatus.exc); + obj.obj_cite_number_non = obj_cite_digit.to!string; + obj.obj_cite_number_type = OCNtype.non; } } } @@ -1710,8 +1751,8 @@ template SiSUdocAbstraction() { destroy(bookindex_unordered_hashes); destroy(an_object); biblio_arr_json = []; - obj_cite_number=0; - obj_cite_number_=0; + obj_cite_digit=0; + obj_cite_digit_=0; html_segnames_ptr=0; html_segnames_ptr_cntr=0; content_non_header = "8"; @@ -1785,11 +1826,11 @@ template SiSUdocAbstraction() { } else { if (obj_type_status["ocn_status_off_for_multiple_objects"] == TriState.off) { if (line.matchFirst(rgx.obj_cite_number_off)) { - obj_type_status["ocn_status"] = TriState.on; + obj_type_status["ocn_status"] = OCNstatus.exc; } else if (line.matchFirst(rgx.obj_cite_number_off_dh)) { - obj_type_status["ocn_status"] = TriState.closing; + obj_type_status["ocn_status"] = OCNstatus.closing; } else { - obj_type_status["ocn_status"] = TriState.off; + obj_type_status["ocn_status"] = OCNstatus.inc; } } else { obj_type_status["ocn_status"] = @@ -1799,7 +1840,7 @@ template SiSUdocAbstraction() { } else if ((!line.empty) && (obj_type_status["ocn_status_off_for_multiple_objects"] > TriState.off)) { if (line.matchFirst(rgx.obj_cite_number_off_block_close)) { obj_type_status["ocn_status_off_for_multiple_objects"] = TriState.off; - obj_type_status["ocn_status"] = TriState.off; + obj_type_status["ocn_status"] = OCNstatus.inc; debug(ocnoff) { writeln(line); } @@ -1842,7 +1883,7 @@ template SiSUdocAbstraction() { ); } obj_cite_number_poem["start"] = - obj_cite_number.to!string; + obj_cite_digit.to!string; obj_type_status["blocks"] = TriState.on; obj_type_status["verse_new"] = State.on; obj_type_status["poem"] = TriState.on; @@ -1921,7 +1962,7 @@ template SiSUdocAbstraction() { line ); } - obj_cite_number_poem["start"] = obj_cite_number.to!string; + obj_cite_number_poem["start"] = obj_cite_digit.to!string; obj_type_status["blocks"] = TriState.on; obj_type_status["verse_new"] = State.on; obj_type_status["poem"] = TriState.on; @@ -2138,14 +2179,14 @@ template SiSUdocAbstraction() { writeln(__LINE__); writefln( "* %s %s", - obj_cite_number, + obj_cite_digit, line ); } if (an_object.length > 0) { debug(poem) { // poem (curly) close writeln( - obj_cite_number, + obj_cite_digit, an_object[an_object_key] ); } @@ -2159,8 +2200,8 @@ template SiSUdocAbstraction() { comp_obj_block.of_section = "body"; comp_obj_block.is_of = "block"; comp_obj_block.is_a = "verse"; - comp_obj_block.ocn = obj_cite_number; - comp_obj_block.obj_cite_number = (obj_cite_number==0) ? "" : obj_cite_number.to!string; + comp_obj_block.ocn = obj_cite_digit; + comp_obj_block.obj_cite_number = (obj_cite_digit==0) ? "" : obj_cite_digit.to!string; comp_obj_block.text = an_object["substantive"]; comp_obj_block.inline_notes_reg = substantive_obj_misc_tuple[sObj.notes_reg]; comp_obj_block.inline_notes_star = substantive_obj_misc_tuple[sObj.notes_star]; @@ -2172,14 +2213,14 @@ template SiSUdocAbstraction() { ++cntr; } obj_cite_number_poem["end"] = - obj_cite_number.to!string; + obj_cite_digit.to!string; obj_type_status["blocks"] = TriState.closing; obj_type_status["poem"] = TriState.closing; obj_type_status["curly_poem"] = TriState.off; } else { processing["verse"] ~= line ~= "\n"; if (obj_type_status["verse_new"] == State.on) { - obj_cite_number = + obj_cite_digit = ocn_emit(obj_type_status["ocn_status"]); obj_type_status["verse_new"] = State.off; } else if (line.matchFirst(rgx.newline_eol_delimiter_only)) { @@ -2193,7 +2234,7 @@ template SiSUdocAbstraction() { debug(poem) { // poem verse writefln( "* %s curly\n%s", - obj_cite_number, + obj_cite_digit, an_object[an_object_key] ); } @@ -2202,7 +2243,7 @@ template SiSUdocAbstraction() { auto comp_obj_location = node_construct.node_location_emitter( content_non_header, segment_anchor_tag_that_object_belongs_to, - obj_cite_number, + obj_cite_digit, cntr, heading_ptr-1, an_object["is"] @@ -2216,8 +2257,8 @@ template SiSUdocAbstraction() { comp_obj_block.of_section = "body"; comp_obj_block.is_of = "block"; comp_obj_block.is_a = "verse"; - comp_obj_block.ocn = obj_cite_number; - comp_obj_block.obj_cite_number = (obj_cite_number==0) ? "" : obj_cite_number.to!string; + comp_obj_block.ocn = obj_cite_digit; + comp_obj_block.obj_cite_number = (obj_cite_digit==0) ? "" : obj_cite_digit.to!string; comp_obj_block.text = an_object["substantive"]; comp_obj_block.inline_notes_reg = substantive_obj_misc_tuple[sObj.notes_reg]; comp_obj_block.inline_notes_star = substantive_obj_misc_tuple[sObj.notes_star]; @@ -2243,7 +2284,7 @@ template SiSUdocAbstraction() { if (an_object.length > 0) { debug(poem) { // poem (tic) close writeln(__LINE__); - writeln(obj_cite_number, line); + writeln(obj_cite_digit, line); } processing.remove("verse"); an_object["is"] = "verse"; @@ -2256,14 +2297,14 @@ template SiSUdocAbstraction() { comp_obj_block.of_section = "body"; comp_obj_block.is_of = "block"; comp_obj_block.is_a = "verse"; - comp_obj_block.ocn = obj_cite_number; - comp_obj_block.obj_cite_number = (obj_cite_number==0) ? "" : obj_cite_number.to!string; + comp_obj_block.ocn = obj_cite_digit; + comp_obj_block.obj_cite_number = (obj_cite_digit==0) ? "" : obj_cite_digit.to!string; comp_obj_block.text = an_object["substantive"]; comp_obj_block.inline_notes_reg = substantive_obj_misc_tuple[sObj.notes_reg]; comp_obj_block.inline_notes_star = substantive_obj_misc_tuple[sObj.notes_star]; comp_obj_block.inline_links = substantive_obj_misc_tuple[sObj.links]; the_document_body_section ~= comp_obj_block; - obj_cite_number_poem["end"] = obj_cite_number.to!string; + obj_cite_number_poem["end"] = obj_cite_digit.to!string; object_reset(an_object); processing.remove("verse"); ++cntr; @@ -2274,7 +2315,7 @@ template SiSUdocAbstraction() { } else { processing["verse"] ~= line ~= "\n"; if (obj_type_status["verse_new"] == State.on) { - obj_cite_number = + obj_cite_digit = ocn_emit(obj_type_status["ocn_status"]); obj_type_status["verse_new"] = State.off; } else if (line.matchFirst(rgx.newline_eol_delimiter_only)) { @@ -2288,7 +2329,7 @@ template SiSUdocAbstraction() { debug(poem) { // poem (tic) close writefln( "* %s tic\n%s", - obj_cite_number, + obj_cite_digit, an_object[an_object_key] ); } @@ -2298,7 +2339,7 @@ template SiSUdocAbstraction() { node_construct.node_location_emitter( content_non_header, segment_anchor_tag_that_object_belongs_to, - obj_cite_number, + obj_cite_digit, cntr, heading_ptr-1, an_object["is"] @@ -2312,8 +2353,8 @@ template SiSUdocAbstraction() { comp_obj_block.of_section = "body"; comp_obj_block.is_of = "block"; comp_obj_block.is_a = "verse"; - comp_obj_block.ocn = obj_cite_number; - comp_obj_block.obj_cite_number = (obj_cite_number==0) ? "" : obj_cite_number.to!string; + comp_obj_block.ocn = obj_cite_digit; + comp_obj_block.obj_cite_number = (obj_cite_digit==0) ? "" : obj_cite_digit.to!string; comp_obj_block.text = an_object["substantive"]; comp_obj_block.inline_notes_reg = substantive_obj_misc_tuple[sObj.notes_reg]; comp_obj_block.inline_notes_star = substantive_obj_misc_tuple[sObj.notes_star]; @@ -2408,7 +2449,7 @@ template SiSUdocAbstraction() { line, an_object, the_document_body_section, - obj_cite_number, + obj_cite_digit, comp_obj_heading, cntr, obj_type_status, @@ -2584,20 +2625,20 @@ template SiSUdocAbstraction() { char[] line, return ref string[string] an_object, return ref ObjGenericComposite[] the_document_body_section, - return ref int obj_cite_number, + return ref int obj_cite_digit, return ref ObjGenericComposite _comp_obj_heading, return ref int cntr, return ref int[string] obj_type_status, string[string][string] dochead_make_aa, ) { comp_obj_block = comp_obj_block.init; - obj_cite_number = + obj_cite_digit = ocn_emit(obj_type_status["ocn_status"]); auto comp_obj_location = node_construct.node_location_emitter( content_non_header, segment_anchor_tag_that_object_belongs_to, - obj_cite_number, + obj_cite_digit, cntr, heading_ptr-1, "table" @@ -2606,8 +2647,8 @@ template SiSUdocAbstraction() { auto substantive_obj_misc_tuple = obj_im.obj_inline_markup_and_anchor_tags_and_misc(an_object, "body_nugget", dochead_make_aa); an_object["substantive"] = substantive_obj_misc_tuple[sObj.content]; - comp_obj_block.ocn = obj_cite_number; - comp_obj_block.obj_cite_number = (obj_cite_number==0) ? "" : obj_cite_number.to!string; + comp_obj_block.ocn = obj_cite_digit; + comp_obj_block.obj_cite_number = (obj_cite_digit==0) ? "" : obj_cite_digit.to!string; comp_obj_block = table_instructions(comp_obj_block, an_object["table_head"]); comp_obj_block = table_substantive_munge_special(comp_obj_block, an_object["substantive"]); the_document_body_section ~= comp_obj_block; @@ -2621,7 +2662,7 @@ template SiSUdocAbstraction() { return ref string[string] an_object, return ref ObjGenericComposite[] the_document_body_section, return ref string[][string][string] bookindex_unordered_hashes, - return ref int obj_cite_number, + return ref int obj_cite_digit, return ref ObjGenericComposite _comp_obj_heading, return ref int cntr, return ref int[string] obj_type_status, @@ -2639,14 +2680,14 @@ template SiSUdocAbstraction() { ); assertions_flag_types_block_status_none_or_closed(obj_type_status); if (obj_type_status["quote"] == TriState.closing) { - obj_cite_number = + obj_cite_digit = ocn_emit(obj_type_status["ocn_status"]); an_object["bookindex_nugget"] = ("bookindex_nugget" in an_object) ? an_object["bookindex_nugget"] : ""; bookindex_unordered_hashes = bookindex_extract_hash.bookindex_nugget_hash( an_object["bookindex_nugget"], - obj_cite_number, + obj_cite_digit, segment_anchor_tag_that_object_belongs_to ); an_object["is"] = "quote"; @@ -2654,7 +2695,7 @@ template SiSUdocAbstraction() { node_construct.node_location_emitter( content_non_header, segment_anchor_tag_that_object_belongs_to, - obj_cite_number, + obj_cite_digit, cntr, heading_ptr-1, an_object["is"] @@ -2668,8 +2709,8 @@ template SiSUdocAbstraction() { comp_obj_block.of_section = "body"; comp_obj_block.is_of = "block"; comp_obj_block.is_a = "quote"; - comp_obj_block.ocn = obj_cite_number; - comp_obj_block.obj_cite_number = (obj_cite_number==0) ? "" : obj_cite_number.to!string; + comp_obj_block.ocn = obj_cite_digit; + comp_obj_block.obj_cite_number = (obj_cite_digit==0) ? "" : obj_cite_digit.to!string; comp_obj_block.text = an_object["substantive"]; comp_obj_block.inline_notes_reg = substantive_obj_misc_tuple[sObj.notes_reg]; comp_obj_block.inline_notes_star = substantive_obj_misc_tuple[sObj.notes_star]; @@ -2681,14 +2722,14 @@ template SiSUdocAbstraction() { processing.remove("verse"); ++cntr; } else if (obj_type_status["group"] == TriState.closing) { - obj_cite_number = + obj_cite_digit = ocn_emit(obj_type_status["ocn_status"]); an_object["bookindex_nugget"] = ("bookindex_nugget" in an_object) ? an_object["bookindex_nugget"] : ""; bookindex_unordered_hashes = bookindex_extract_hash.bookindex_nugget_hash( an_object["bookindex_nugget"], - obj_cite_number, + obj_cite_digit, segment_anchor_tag_that_object_belongs_to ); an_object["is"] = "group"; @@ -2696,7 +2737,7 @@ template SiSUdocAbstraction() { node_construct.node_location_emitter( content_non_header, segment_anchor_tag_that_object_belongs_to, - obj_cite_number, + obj_cite_digit, cntr, heading_ptr-1, an_object["is"] @@ -2710,8 +2751,8 @@ template SiSUdocAbstraction() { comp_obj_block.of_section = "body"; comp_obj_block.is_of = "block"; comp_obj_block.is_a = "group"; - comp_obj_block.ocn = obj_cite_number; - comp_obj_block.obj_cite_number = (obj_cite_number==0) ? "" : obj_cite_number.to!string; + comp_obj_block.ocn = obj_cite_digit; + comp_obj_block.obj_cite_number = (obj_cite_digit==0) ? "" : obj_cite_digit.to!string; comp_obj_block.text = an_object["substantive"]; comp_obj_block.inline_notes_reg = substantive_obj_misc_tuple[sObj.notes_reg]; comp_obj_block.inline_notes_star = substantive_obj_misc_tuple[sObj.notes_star]; @@ -2723,13 +2764,13 @@ template SiSUdocAbstraction() { processing.remove("verse"); ++cntr; } else if (obj_type_status["block"] == TriState.closing) { - obj_cite_number = ocn_emit(obj_type_status["ocn_status"]); + obj_cite_digit = ocn_emit(obj_type_status["ocn_status"]); an_object["bookindex_nugget"] = ("bookindex_nugget" in an_object) ? an_object["bookindex_nugget"] : ""; bookindex_unordered_hashes = bookindex_extract_hash.bookindex_nugget_hash( an_object["bookindex_nugget"], - obj_cite_number, + obj_cite_digit, segment_anchor_tag_that_object_belongs_to ); an_object["is"] = "block"; @@ -2737,7 +2778,7 @@ template SiSUdocAbstraction() { node_construct.node_location_emitter( content_non_header, segment_anchor_tag_that_object_belongs_to, - obj_cite_number, + obj_cite_digit, cntr, heading_ptr-1, an_object["is"] @@ -2750,8 +2791,8 @@ template SiSUdocAbstraction() { comp_obj_block.of_section = "body"; comp_obj_block.is_of = "block"; comp_obj_block.is_a = "block"; - comp_obj_block.ocn = obj_cite_number; - comp_obj_block.obj_cite_number = (obj_cite_number==0) ? "" : obj_cite_number.to!string; + comp_obj_block.ocn = obj_cite_digit; + comp_obj_block.obj_cite_number = (obj_cite_digit==0) ? "" : obj_cite_digit.to!string; comp_obj_block.text = an_object["substantive"]; comp_obj_block.inline_notes_reg = substantive_obj_misc_tuple[sObj.notes_reg]; comp_obj_block.inline_notes_star = substantive_obj_misc_tuple[sObj.notes_star]; @@ -2768,7 +2809,7 @@ template SiSUdocAbstraction() { bookindex_unordered_hashes = bookindex_extract_hash.bookindex_nugget_hash( an_object["bookindex_nugget"], - obj_cite_number, + obj_cite_digit, segment_anchor_tag_that_object_belongs_to ); an_object["is"] = "verse"; @@ -2776,7 +2817,7 @@ template SiSUdocAbstraction() { node_construct.node_location_emitter( content_non_header, segment_anchor_tag_that_object_belongs_to, - obj_cite_number, + obj_cite_digit, cntr, heading_ptr-1, an_object["is"] @@ -2786,7 +2827,7 @@ template SiSUdocAbstraction() { comp_obj_poem_ocn.of_section = "body"; comp_obj_poem_ocn.is_of = "block"; comp_obj_poem_ocn.is_a = "poem"; - comp_obj_poem_ocn.ocn = obj_cite_number; + comp_obj_poem_ocn.ocn = obj_cite_digit; comp_obj_poem_ocn.obj_cite_number = (obj_cite_number_poem["start"], obj_cite_number_poem["end"]); comp_obj_poem_ocn.text = ""; the_document_body_section ~= comp_obj_poem_ocn; @@ -2795,14 +2836,14 @@ template SiSUdocAbstraction() { object_reset(an_object); processing.remove("verse"); } else if (obj_type_status["code"] == TriState.closing) { - obj_cite_number = + obj_cite_digit = ocn_emit(obj_type_status["ocn_status"]); an_object["bookindex_nugget"] = ("bookindex_nugget" in an_object) ? an_object["bookindex_nugget"] : ""; bookindex_unordered_hashes = bookindex_extract_hash.bookindex_nugget_hash( an_object["bookindex_nugget"], - obj_cite_number, + obj_cite_digit, segment_anchor_tag_that_object_belongs_to ); an_object["is"] = "code"; @@ -2810,7 +2851,7 @@ template SiSUdocAbstraction() { node_construct.node_location_emitter( content_non_header, segment_anchor_tag_that_object_belongs_to, - obj_cite_number, + obj_cite_digit, cntr, heading_ptr-1, an_object["is"] @@ -2824,8 +2865,8 @@ template SiSUdocAbstraction() { comp_obj_code.of_section = "body"; comp_obj_code.is_of = "block"; comp_obj_code.is_a = "code"; - comp_obj_code.ocn = obj_cite_number; - comp_obj_code.obj_cite_number = (obj_cite_number==0) ? "" : obj_cite_number.to!string; + comp_obj_code.ocn = obj_cite_digit; + comp_obj_code.obj_cite_number = (obj_cite_digit==0) ? "" : obj_cite_digit.to!string; comp_obj_code.text = an_object["substantive"]; comp_obj_code.inline_notes_reg = substantive_obj_misc_tuple[sObj.notes_reg]; comp_obj_code.inline_notes_star = substantive_obj_misc_tuple[sObj.notes_star]; @@ -2838,14 +2879,14 @@ template SiSUdocAbstraction() { ++cntr; } else if (obj_type_status["table"] == TriState.closing) { comp_obj_block = comp_obj_block.init; - obj_cite_number = + obj_cite_digit = ocn_emit(obj_type_status["ocn_status"]); an_object["bookindex_nugget"] = ("bookindex_nugget" in an_object) ? an_object["bookindex_nugget"] : ""; bookindex_unordered_hashes = bookindex_extract_hash.bookindex_nugget_hash( an_object["bookindex_nugget"], - obj_cite_number, + obj_cite_digit, segment_anchor_tag_that_object_belongs_to ); an_object["is"] = "table"; @@ -2853,7 +2894,7 @@ template SiSUdocAbstraction() { node_construct.node_location_emitter( content_non_header, segment_anchor_tag_that_object_belongs_to, - obj_cite_number, + obj_cite_digit, cntr, heading_ptr-1, an_object["is"] @@ -2862,8 +2903,8 @@ template SiSUdocAbstraction() { obj_im.obj_inline_markup_and_anchor_tags_and_misc(an_object, an_object_key, dochead_make_aa); an_object["substantive"] = substantive_obj_misc_tuple[sObj.content]; comp_obj_block = comp_obj_block.init; - comp_obj_block.ocn = obj_cite_number; - comp_obj_block.obj_cite_number = (obj_cite_number==0) ? "" : obj_cite_number.to!string; + comp_obj_block.ocn = obj_cite_digit; + comp_obj_block.obj_cite_number = (obj_cite_digit==0) ? "" : obj_cite_digit.to!string; comp_obj_block = table_instructions(comp_obj_block, an_object["table_head"]); comp_obj_block = table_substantive_munge(comp_obj_block, an_object["substantive"]); the_document_body_section ~= comp_obj_block; @@ -3517,19 +3558,31 @@ template SiSUdocAbstraction() { /+ abstraction functions ↑ +/ /+ ↓ abstraction function emitters +/ pure struct OCNemitter { - int obj_cite_number, obj_cite_number_; + int ocn_, ocn_in, ocn_in_, ocn_out_, ocn_bkidx_; int ocn_emitter(int ocn_status_flag) - in { assert(ocn_status_flag <= 3); } + in { assert(ocn_status_flag <= OCNstatus.reset); } body { - if (ocn_status_flag == 3) { - obj_cite_number = obj_cite_number_ = 1; - } else { - obj_cite_number=(ocn_status_flag == 0) - ? ++obj_cite_number_ - : 0; + switch(ocn_status_flag) { + case OCNstatus.reset: + ocn_ = ocn_in_ = ocn_out_ = 1; + ocn_bkidx_ = 0; + break; + case OCNstatus.inc: + ocn_ = ++ocn_in_; + break; + case OCNstatus.exc: + ocn_ = ++ocn_out_; + break; + case OCNstatus.bkidx: + ocn_ = ++ocn_bkidx_; + break; + case OCNstatus.closing: + break; + default: + ocn_ = 0; } - assert(obj_cite_number >= 0); - return obj_cite_number; + assert(ocn_ >= 0); + return ocn_; } invariant() { } @@ -4583,19 +4636,19 @@ template SiSUdocAbstraction() { string[] bi_main_terms_split_arr; string[][string][string] bookindex_nugget_hash(BI,N,S)( BI bookindex_section, - N obj_cite_number, + N obj_cite_digit, S segment_anchor_tag, ) in { debug(asserts) { static assert(is(typeof(bookindex_section) == string)); - static assert(is(typeof(obj_cite_number) == int)); + static assert(is(typeof(obj_cite_digit) == int)); } debug(bookindexraw) { if (!bookindex_section.empty) { writeln( "* [bookindex] ", - "[", obj_cite_number.to!string, ": ", segment_anchor_tag, "] ", bookindex_section + "[", obj_cite_digit.to!string, ": ", segment_anchor_tag, "] ", bookindex_section ); } } @@ -4613,12 +4666,12 @@ template SiSUdocAbstraction() { ) { main_term = m.captures[1].strip; obj_cite_number_offset = m.captures[2].to!int; - obj_cite_number_endpoint=(obj_cite_number + obj_cite_number_offset); - obj_cite_numbers ~= (obj_cite_number.to!string ~ "-" ~ to!string(obj_cite_number_endpoint) + obj_cite_number_endpoint=(obj_cite_digit + obj_cite_number_offset); + obj_cite_numbers ~= (obj_cite_digit.to!string ~ "-" ~ to!string(obj_cite_number_endpoint) ~ ":" ~ segment_anchor_tag); } else { main_term = bi_main_term_and_rest[0].strip; - obj_cite_numbers ~= obj_cite_number.to!string + obj_cite_numbers ~= obj_cite_digit.to!string ~ ":" ~ segment_anchor_tag; } bi[main_term]["_a"] ~= obj_cite_numbers; @@ -4632,12 +4685,12 @@ template SiSUdocAbstraction() { if (auto m = sub_terms_bits.match(rgx.bi_term_and_obj_cite_numbers_match)) { sub_term = m.captures[1].strip; obj_cite_number_offset = m.captures[2].to!int; - obj_cite_number_endpoint=(obj_cite_number + obj_cite_number_offset); - obj_cite_numbers ~= (obj_cite_number.to!string ~ " - " ~ to!string(obj_cite_number_endpoint) + obj_cite_number_endpoint=(obj_cite_digit + obj_cite_number_offset); + obj_cite_numbers ~= (obj_cite_digit.to!string ~ " - " ~ to!string(obj_cite_number_endpoint) ~ ":" ~ segment_anchor_tag); } else { sub_term = sub_terms_bits.strip; - obj_cite_numbers ~= to!string(obj_cite_number) + obj_cite_numbers ~= to!string(obj_cite_digit) ~ ":" ~ segment_anchor_tag; } if (!empty(sub_term)) { @@ -4718,12 +4771,12 @@ template SiSUdocAbstraction() { } auto bookindex_build_abstraction_section(BI,N,B)( BI bookindex_unordered_hashes, - N obj_cite_number, + N obj_cite_digit, B opt_action, ) { debug(asserts) { static assert(is(typeof(bookindex_unordered_hashes) == string[][string][string])); - static assert(is(typeof(obj_cite_number) == int)); + static assert(is(typeof(obj_cite_digit) == int)); static assert(is(typeof(opt_action) == bool[string])); } mixin SiSUnode; @@ -4762,7 +4815,6 @@ template SiSUdocAbstraction() { comp_obj_heading.inline_links = true; bookindex_section["scroll"] ~= comp_obj_heading_; bookindex_section["seg"] ~= comp_obj_heading_; - ++obj_cite_number; ++mkn; comp_obj_heading_ = comp_obj_heading_.init; comp_obj_heading_.of_part = "backmatter"; @@ -4782,7 +4834,6 @@ template SiSUdocAbstraction() { comp_obj_heading_.anchor_tags = ["bookindex"]; bookindex_section["scroll"] ~= comp_obj_heading_; bookindex_section["seg"] ~= comp_obj_heading_; - ++obj_cite_number; ++mkn; import std.array : appender; auto buffer = appender!(char[])(); @@ -4847,8 +4898,8 @@ template SiSUdocAbstraction() { comp_obj_para.is_of = "para"; comp_obj_para.is_a = "bookindex"; comp_obj_para.text = bi_tmp_scroll.to!string.strip; - comp_obj_para.ocn = obj_cite_number; - comp_obj_para.obj_cite_number = (obj_cite_number==0) ? "" : to!string(obj_cite_number); + comp_obj_para.ocn = 0; + comp_obj_para.obj_cite_number = ""; comp_obj_para.anchor_tags = bi_tmp_tags; comp_obj_para.indent_hang = 0; comp_obj_para.indent_base = 1; @@ -4857,7 +4908,6 @@ template SiSUdocAbstraction() { bookindex_section["scroll"] ~= comp_obj_para; comp_obj_para.text = bi_tmp_seg.to!string.strip; bookindex_section["seg"] ~= comp_obj_para; - ++obj_cite_number; ++mkn; } } else { // no book index, (figure out what to do here) @@ -4873,7 +4923,7 @@ template SiSUdocAbstraction() { bookindex_section["scroll"] ~= comp_obj_heading_; bookindex_section["seg"] ~= comp_obj_heading_; } - auto t = tuple(bookindex_section, obj_cite_number); + auto t = tuple(bookindex_section, obj_cite_digit); return t; } } @@ -4954,7 +5004,7 @@ template SiSUdocAbstraction() { return endnotes_; } private auto endnote_objects( - int obj_cite_number, + int obj_cite_digit, bool[string] opt_action, ) in { @@ -4985,7 +5035,7 @@ template SiSUdocAbstraction() { comp_obj_heading_.parent_ocn = 1; comp_obj_heading_.parent_lev_markup = 0; the_endnotes_section ~= comp_obj_heading_; - ++obj_cite_number; + ++obj_cite_digit; ++mkn; comp_obj_heading_ = comp_obj_heading_.init; comp_obj_heading_.of_part = "backmatter"; @@ -5003,7 +5053,7 @@ template SiSUdocAbstraction() { comp_obj_heading_.parent_lev_markup = 0; comp_obj_heading_.anchor_tags = ["endnotes"]; the_endnotes_section ~= comp_obj_heading_; - ++obj_cite_number; + ++obj_cite_digit; ++mkn; } else { comp_obj_heading_ = comp_obj_heading_.init; @@ -5043,7 +5093,7 @@ template SiSUdocAbstraction() { the_endnotes_section ~= comp_obj_endnote_; } } - auto t = tuple(the_endnotes_section, obj_cite_number); + auto t = tuple(the_endnotes_section, obj_cite_digit); return t; } } @@ -5150,13 +5200,13 @@ template SiSUdocAbstraction() { /+ +/ struct NodeStructureMetadata { int lv, lv0, lv1, lv2, lv3, lv4, lv5, lv6, lv7; - int obj_cite_number; + int obj_cite_digit; int[string] p_; // p_ parent_ static auto rgx = Rgx(); ObjGenericComposite node_location_emitter(Lv,Ta,N,C,P,I)( Lv lev_markup_number, Ta segment_anchor_tag, - N obj_cite_number_, + N obj_cite_digit_, C cntr_, P ptr_, I is_ @@ -5165,18 +5215,18 @@ template SiSUdocAbstraction() { debug(asserts) { static assert(is(typeof(lev_markup_number) == string)); static assert(is(typeof(segment_anchor_tag) == string)); - static assert(is(typeof(obj_cite_number_) == int)); + static assert(is(typeof(obj_cite_digit_) == int)); static assert(is(typeof(cntr_) == int)); static assert(is(typeof(ptr_) == int)); static assert(is(typeof(is_) == string)); } assert(is_ != "heading"); - assert(obj_cite_number_.to!int >= 0); + assert(obj_cite_digit_.to!int >= 0); } body { assert(is_ != "heading"); // should not be necessary - assert(obj_cite_number_.to!int >= 0); // should not be necessary - int obj_cite_number = obj_cite_number_.to!int; + assert(obj_cite_digit_.to!int >= 0); // should not be necessary + int obj_cite_digit = obj_cite_digit_.to!int; if (lv7 > State.off) { p_["lev_markup_number"] = DocStructMarkupHeading.h_text_4; p_["obj_cite_number"] = lv7; @@ -5193,7 +5243,7 @@ template SiSUdocAbstraction() { ObjGenericComposite comp_obj_location; comp_obj_location = comp_obj_location.init; comp_obj_location.is_a = is_; - comp_obj_location.ocn = obj_cite_number_; + comp_obj_location.ocn = obj_cite_digit_; comp_obj_location.segment_anchor_tag = segment_anchor_tag.to!string; comp_obj_location.parent_ocn = p_["obj_cite_number"]; comp_obj_location.parent_lev_markup = p_["lev_markup_number"]; @@ -5217,7 +5267,7 @@ template SiSUdocAbstraction() { Lm lev_markup_number, Lc lev_collapsed_number, Ta segment_anchor_tag, - N obj_cite_number_, + N obj_cite_digit_, C cntr_, P ptr_, LA lv_ancestors_txt, @@ -5234,7 +5284,7 @@ template SiSUdocAbstraction() { static assert(is(typeof(lev_markup_number) == string)); static assert(is(typeof(lev_collapsed_number) == string)); static assert(is(typeof(segment_anchor_tag) == string)); - static assert(is(typeof(obj_cite_number_) == int)); + static assert(is(typeof(obj_cite_digit_) == int)); static assert(is(typeof(cntr_) == int)); static assert(is(typeof(ptr_) == int)); static assert(is(typeof(lv_ancestors_txt) == string[])); @@ -5242,30 +5292,30 @@ template SiSUdocAbstraction() { static assert(is(typeof(html_segnames_ptr) == int)); } assert(is_ == "heading"); - assert(to!int(obj_cite_number_) >= 0); + assert((obj_cite_digit_).to!int >= 0); assert( lev_markup_number.match(rgx.levels_numbered), - ("not a valid heading level: " ~ lev_markup_number ~ " at " ~ obj_cite_number_.to!string) + ("not a valid heading level: " ~ lev_markup_number ~ " at " ~ obj_cite_digit_.to!string) ); if (lev_markup_number.match(rgx.levels_numbered)) { if (lev_markup_number.to!int == 0) { - assert(obj_cite_number_.to!int == 1); + assert(obj_cite_digit_.to!int == 1); } } } body { - int obj_cite_number = obj_cite_number_.to!int; + int obj_cite_digit = obj_cite_digit_.to!int; switch (lev_markup_number.to!int) { case 0: lv = DocStructMarkupHeading.h_sect_A; - lv0 = obj_cite_number; + lv0 = obj_cite_digit; lv1=0; lv2=0; lv3=0; lv4=0; lv5=0; lv6=0; lv7=0; p_["lev_markup_number"] = 0; p_["obj_cite_number"] = 0; break; case 1: lv = DocStructMarkupHeading.h_sect_B; - lv1 = obj_cite_number; + lv1 = obj_cite_digit; lv2=0; lv3=0; lv4=0; lv5=0; lv6=0; lv7=0; p_["lev_markup_number"] = DocStructMarkupHeading.h_sect_A; @@ -5273,7 +5323,7 @@ template SiSUdocAbstraction() { break; case 2: lv = DocStructMarkupHeading.h_sect_C; - lv2 = obj_cite_number; + lv2 = obj_cite_digit; lv3=0; lv4=0; lv5=0; lv6=0; lv7=0; p_["lev_markup_number"] = DocStructMarkupHeading.h_sect_B; @@ -5281,7 +5331,7 @@ template SiSUdocAbstraction() { break; case 3: lv = DocStructMarkupHeading.h_sect_D; - lv3=obj_cite_number; + lv3=obj_cite_digit; lv4=0; lv5=0; lv6=0; lv7=0; p_["lev_markup_number"] = DocStructMarkupHeading.h_sect_C; @@ -5289,7 +5339,7 @@ template SiSUdocAbstraction() { break; case 4: lv = DocStructMarkupHeading.h_text_1; - lv4 = obj_cite_number; + lv4 = obj_cite_digit; lv5=0; lv6=0; lv7=0; if (lv3 > State.off) { p_["lev_markup_number"] = @@ -5311,7 +5361,7 @@ template SiSUdocAbstraction() { break; case 5: lv = DocStructMarkupHeading.h_text_2; - lv5 = obj_cite_number; + lv5 = obj_cite_digit; lv6=0; lv7=0; p_["lev_markup_number"] = DocStructMarkupHeading.h_text_1; @@ -5319,7 +5369,7 @@ template SiSUdocAbstraction() { break; case 6: lv = DocStructMarkupHeading.h_text_3; - lv6 = obj_cite_number; + lv6 = obj_cite_digit; lv7=0; p_["lev_markup_number"] = DocStructMarkupHeading.h_text_2; @@ -5327,7 +5377,7 @@ template SiSUdocAbstraction() { break; case 7: lv = DocStructMarkupHeading.h_text_4; - lv7 = obj_cite_number; + lv7 = obj_cite_digit; p_["lev_markup_number"] = DocStructMarkupHeading.h_text_3; p_["obj_cite_number"] = lv6; @@ -5342,8 +5392,8 @@ template SiSUdocAbstraction() { _comp_obj_heading_.is_of = "para"; _comp_obj_heading_.is_a = "heading"; _comp_obj_heading_.text = _text.to!string.strip; - _comp_obj_heading_.ocn = obj_cite_number_; - _comp_obj_heading_.obj_cite_number = (obj_cite_number==0) ? "" : obj_cite_number.to!string; + _comp_obj_heading_.ocn = obj_cite_digit_; + _comp_obj_heading_.obj_cite_number = (obj_cite_digit==0) ? "" : obj_cite_digit.to!string; _comp_obj_heading_.segment_anchor_tag = segment_anchor_tag.to!string; _comp_obj_heading_.marked_up_level = lev; _comp_obj_heading_.heading_lev_markup = (!(lev_markup_number.empty) ? lev_markup_number.to!int : 0); -- cgit v1.2.3