From 313ddb0ac605838eaca89054ff80a0402a8c6313 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Fri, 2 Dec 2016 14:44:39 -0500 Subject: 0.9.3 start work on node pointers, a way to go --- src/sdp/ao_abstract_doc_source.d | 338 ++++++++++++++++++++------------------- src/sdp/ao_object_setter.d | 48 ++++-- src/sdp/ao_output_debugs.d | 85 +++------- src/sdp/output_html.d | 4 +- src/sdp/output_hub.d | 1 + 5 files changed, 228 insertions(+), 248 deletions(-) (limited to 'src/sdp') diff --git a/src/sdp/ao_abstract_doc_source.d b/src/sdp/ao_abstract_doc_source.d index cc39ea1..7dbc573 100644 --- a/src/sdp/ao_abstract_doc_source.d +++ b/src/sdp/ao_abstract_doc_source.d @@ -22,7 +22,7 @@ template SiSUdocAbstraction() { string[string] an_object, processing; string an_object_key; string[] anchor_tags; - string segment_object_belongs_to; + string segment_anchor_tag_that_object_belongs_to; auto set_abstract_object = ObjectAbstractSet(); auto note_section = NotesSection(); /+ enum +/ @@ -48,9 +48,12 @@ template SiSUdocAbstraction() { JSONValue[] bib_arr_json; int bib_entry; /+ counters +/ - long counter, previous_count, previous_length; + long cntr, previous_count, previous_length; int[string] line_occur; - int verse_line, heading_pointer; + int verse_line, heading_ptr; + string[] html_segnames=[]; + uint html_segnames_ptr=0; + uint html_segnames_ptr_cntr=0; /+ paragraph attributes +/ int[string] indent; bool bullet = true; @@ -122,7 +125,7 @@ template SiSUdocAbstraction() { "h5" : State.off, "h6" : State.off, "h7" : State.off, - "lev_collapsed_number" : 0, + "lev_int_collapsed" : 0, ]; int[string] collapsed_lev = [ "h0" : State.off, @@ -165,8 +168,8 @@ template SiSUdocAbstraction() { 0, // obj_cite_number ["toc"], // anchor tag "1", // lev - 4, // lev_markup_number - 2, // lev_collapsed_number + 4, // lev_int_markup + 2, // lev_int_collapsed ); the_table_of_contents_section = [ "seg": [toc_head], @@ -262,8 +265,8 @@ template SiSUdocAbstraction() { 0, // obj_cite_number [""], // anchor tag "B", // lev - 1, // lev_markup_number - 1, // lev_collapsed_number + 1, // lev_int_markup + 1, // lev_int_collapsed ); the_glossary_section ~= set_abstract_object.contents_heading( @@ -272,8 +275,8 @@ template SiSUdocAbstraction() { 0, // obj_cite_number ["glossary"], // anchor tag "1", // lev - 4, // lev_markup_number - 2, // lev_collapsed_number + 4, // lev_int_markup + 2, // lev_int_collapsed ); // } else if (matchFirst(line, rgx.heading)) { // _heading_matched_(line, line_occur, an_object, an_object_key, lv, collapsed_lev, type, dochead_meta_aa); // levels? @@ -323,8 +326,8 @@ template SiSUdocAbstraction() { 0, // obj_cite_number [""], // anchor tag "B", // lev - 1, // lev_markup_number - 1, // lev_collapsed_number + 1, // lev_int_markup + 1, // lev_int_collapsed ); the_blurb_section ~= set_abstract_object.contents_heading( @@ -333,8 +336,8 @@ template SiSUdocAbstraction() { 0, // obj_cite_number ["blurb"], // anchor tag "1", // lev - 4, // lev_markup_number - 2, // lev_collapsed_number + 4, // lev_int_markup + 2, // lev_int_collapsed ); } else if ((matchFirst(line, rgx.heading)) && (opt_action_bool["backmatter"] && opt_action_bool["section_blurb"])) { @@ -366,7 +369,7 @@ template SiSUdocAbstraction() { 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); + _poem_block_(line, an_object, type, cntr, obj_cite_number_poem, dochead_make_aa); continue; /+ within block object: group +/ } else if (type["group"] == TriState.on) { @@ -444,7 +447,7 @@ template SiSUdocAbstraction() { set_abstract_object.contents_comment(strip(an_object[an_object_key])); _common_reset_(line_occur, an_object, type); processing.remove("verse"); - ++counter; + ++cntr; } else if (((line_occur["para"] == State.off) && (line_occur["heading"] == State.off)) && ((type["para"] == State.off) @@ -503,7 +506,7 @@ template SiSUdocAbstraction() { bookindex_unordered_hashes, obj_cite_number, _node, - counter, + cntr, type, obj_cite_number_poem, dochead_make_aa @@ -534,34 +537,40 @@ template SiSUdocAbstraction() { 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) { - segment_object_belongs_to = anchor_tags[0]; + segment_anchor_tag_that_object_belongs_to = anchor_tags[0]; } else if (to!int(an_object["lev_markup_number"]) < 4) { - segment_object_belongs_to = ""; + segment_anchor_tag_that_object_belongs_to = ""; } _anchor_tag=to!string(obj_cite_number); the_table_of_contents_section = obj_im.table_of_contents_gather_headings( an_object, dochead_make_aa, - segment_object_belongs_to, + segment_anchor_tag_that_object_belongs_to, _anchor_tag, the_table_of_contents_section, ); + if (an_object["lev_markup_number"] == "4") { + html_segnames ~= segment_anchor_tag_that_object_belongs_to; + html_segnames_ptr = html_segnames_ptr_cntr; + html_segnames_ptr_cntr++; + } _node = node_construct.node_emitter_heading( an_object["lev_markup_number"], an_object["lev_collapsed_number"], - segment_object_belongs_to, + segment_anchor_tag_that_object_belongs_to, obj_cite_number, - counter, - heading_pointer, - an_object["is"] + cntr, + heading_ptr, + an_object["is"], + html_segnames_ptr, ); // heading an_object["attrib"] = obj_att.obj_attributes(an_object["is"], an_object[an_object_key], _node); - ++heading_pointer; + ++heading_ptr; debug(segments) { writeln(an_object["lev_markup_number"]); - writeln(segment_object_belongs_to); + writeln(segment_anchor_tag_that_object_belongs_to); } the_document_body_section ~= set_abstract_object.contents_heading( @@ -581,7 +590,7 @@ template SiSUdocAbstraction() { an_object.remove("lev"); an_object.remove("lev_markup_number"); processing.remove("verse"); - ++counter; + ++cntr; } else if ((type["para"] == State.on) && (line_occur["para"] > State.off)) { /+ paragraph object (current line empty) +/ obj_cite_number = obj_cite_number_emit(type["obj_cite_number_status"]); @@ -593,11 +602,11 @@ template SiSUdocAbstraction() { _node = node_construct.node_emitter( content_non_header, - segment_object_belongs_to, + segment_anchor_tag_that_object_belongs_to, obj_cite_number, - counter, - heading_pointer-1, - an_object["is"] + cntr, + heading_ptr-1, + an_object["is"], ); auto substantive_object_and_anchor_tags_tuple = obj_im.obj_inline_markup_and_anchor_tags(an_object, an_object_key, dochead_make_aa); // ... @@ -621,7 +630,7 @@ template SiSUdocAbstraction() { ]; bullet = false; processing.remove("verse"); - ++counter; + ++cntr; } else { assert( line == null, @@ -640,7 +649,7 @@ template SiSUdocAbstraction() { && (the_document_body_section.length > previous_length) ) { if ((the_document_body_section[$-1].is_a == "heading") - && (the_document_body_section[$-1].heading_attrib.lev_markup_number < 5)) { + && (the_document_body_section[$-1].heading_attrib.lev_int_markup < 5)) { type["biblio_section"] = State.off; type["glossary_section"] = State.off; type["blurb_section"] = State.off; @@ -653,8 +662,8 @@ template SiSUdocAbstraction() { previous_count=the_document_body_section.length -1; note_section.gather_notes_for_endnote_section( the_document_body_section, - segment_object_belongs_to, - the_document_body_section.length-1 + segment_anchor_tag_that_object_belongs_to, + the_document_body_section.length-1, ); } } @@ -698,8 +707,8 @@ template SiSUdocAbstraction() { 0, // obj_cite_number [""], // anchor tag "B", // lev - 1, // lev_markup_number - 1, // lev_collapsed_number + 1, // lev_int_markup + 1, // lev_int_collapsed ); } else { writeln("gloss"); @@ -722,8 +731,8 @@ template SiSUdocAbstraction() { 0, // obj_cite_number [""], // anchor tag "B", // lev - 1, // lev_markup_number - 1, // lev_collapsed_number + 1, // lev_int_markup + 1, // lev_int_collapsed ); the_bibliography_section ~= set_abstract_object.contents_heading( @@ -732,8 +741,8 @@ template SiSUdocAbstraction() { 0, // obj_cite_number ["bibliography"], // anchor tag "1", // lev - 4, // lev_markup_number - 2, // lev_collapsed_number + 4, // lev_int_markup + 2, // lev_int_collapsed ); } else { the_bibliography_section ~= @@ -743,8 +752,8 @@ template SiSUdocAbstraction() { 0, // obj_cite_number [""], // anchor tag "B", // lev - 1, // lev_markup_number - 1, // lev_collapsed_number + 1, // lev_int_markup + 1, // lev_int_collapsed ); } string out_; @@ -783,7 +792,7 @@ template SiSUdocAbstraction() { bi.bookindex_build_section( bookindex_unordered_hashes, obj_cite_number, - segment_object_belongs_to, + segment_anchor_tag_that_object_belongs_to, opt_action_bool, ); static assert(!isTypeTuple!(bi_tuple)); @@ -803,8 +812,8 @@ template SiSUdocAbstraction() { 0, // obj_cite_number [""], // anchor tag "B", // lev - 1, // lev_markup_number - 1, // lev_collapsed_number + 1, // lev_int_markup + 1, // lev_int_collapsed ); } else { writeln("blurb"); @@ -823,7 +832,7 @@ template SiSUdocAbstraction() { toc_txt_ = format( "{ %s }../%s.fn_suffix", "Endnotes", - "endnotes", // segment_object_belongs_to + "endnotes", // segment_anchor_tag_that_object_belongs_to ); toc_txt_= munge.url_links(toc_txt_); the_table_of_contents_section["seg"] ~= @@ -857,7 +866,7 @@ template SiSUdocAbstraction() { toc_txt_ = format( "{ %s }../%s.fn_suffixs", "Glossary", - "glossary", // segment_object_belongs_to + "glossary", // segment_anchor_tag_that_object_belongs_to ); toc_txt_= munge.url_links(toc_txt_); the_table_of_contents_section["seg"] ~= @@ -889,7 +898,7 @@ template SiSUdocAbstraction() { toc_txt_ = format( "{ %s }../%s.fn_suffix", "Bibliography", - "bibliography", // segment_object_belongs_to + "bibliography", // segment_anchor_tag_that_object_belongs_to ); toc_txt_= munge.url_links(toc_txt_); the_table_of_contents_section["seg"] ~= @@ -921,7 +930,7 @@ template SiSUdocAbstraction() { toc_txt_ = format( "{ %s }../%s.fn_suffix", "Book Index", - "bookindex", // segment_object_belongs_to + "bookindex", // segment_anchor_tag_that_object_belongs_to ); toc_txt_= munge.url_links(toc_txt_); the_table_of_contents_section["seg"] ~= @@ -955,7 +964,7 @@ template SiSUdocAbstraction() { toc_txt_ = format( "{ %s }../%s.fn_suffix", "Blurb", - "blurb", // segment_object_belongs_to + "blurb", // segment_anchor_tag_that_object_belongs_to ); toc_txt_= munge.url_links(toc_txt_); the_table_of_contents_section["seg"] ~= @@ -1010,8 +1019,7 @@ template SiSUdocAbstraction() { ]; auto t = tuple( document_the, - bookindex_unordered_hashes, - biblio_ordered + html_segnames, ); return t; /+ post loop markup document/text ↑ +/ @@ -1400,7 +1408,7 @@ template SiSUdocAbstraction() { char[] line, ref string[string] an_object, ref int[string] type, - ref long counter, + ref long cntr, string[string] obj_cite_number_poem, string[string][string] dochead_make_aa, ) { @@ -1447,7 +1455,7 @@ template SiSUdocAbstraction() { ); object_reset(an_object); processing.remove("verse"); - ++counter; + ++cntr; } obj_cite_number_poem["end"] = to!string(obj_cite_number); @@ -1478,10 +1486,10 @@ template SiSUdocAbstraction() { an_object["is"] = "verse"; _node = node_construct.node_emitter( content_non_header, - segment_object_belongs_to, + segment_anchor_tag_that_object_belongs_to, obj_cite_number, - counter, - heading_pointer-1, + cntr, + heading_ptr-1, an_object["is"] ); auto substantive_object_and_anchor_tags_tuple = @@ -1499,7 +1507,7 @@ template SiSUdocAbstraction() { ); object_reset(an_object); processing.remove("verse"); - ++counter; + ++cntr; } } } else if (type["tic_poem"] == TriState.on) { @@ -1537,7 +1545,7 @@ template SiSUdocAbstraction() { obj_cite_number_poem["end"] = to!string(obj_cite_number); object_reset(an_object); processing.remove("verse"); - ++counter; + ++cntr; } type["blocks"] = TriState.closing; type["poem"] = TriState.closing; @@ -1567,10 +1575,10 @@ template SiSUdocAbstraction() { _node = node_construct.node_emitter( content_non_header, - segment_object_belongs_to, + segment_anchor_tag_that_object_belongs_to, obj_cite_number, - counter, - heading_pointer-1, + cntr, + heading_ptr-1, an_object["is"] ); auto substantive_object_and_anchor_tags_tuple = @@ -1588,7 +1596,7 @@ template SiSUdocAbstraction() { ); object_reset(an_object); processing.remove("verse"); - ++counter; + ++cntr; } } } @@ -1740,7 +1748,7 @@ template SiSUdocAbstraction() { ref string[][string][string] bookindex_unordered_hashes, ref int obj_cite_number, ref string _node, - ref long counter, + ref long cntr, ref int[string] type, string[string] obj_cite_number_poem, string[string][string] dochead_make_aa, @@ -1766,10 +1774,10 @@ template SiSUdocAbstraction() { _node = node_construct.node_emitter( content_non_header, - segment_object_belongs_to, + segment_anchor_tag_that_object_belongs_to, obj_cite_number, - counter, - heading_pointer-1, + cntr, + heading_ptr-1, an_object["is"] ); auto substantive_object_and_anchor_tags_tuple = @@ -1787,7 +1795,7 @@ template SiSUdocAbstraction() { ); object_reset(an_object); processing.remove("verse"); - ++counter; + ++cntr; type["blocks"] = TriState.off; type["code"] = TriState.off; } else if (type["poem"] == TriState.closing) { @@ -1799,10 +1807,10 @@ template SiSUdocAbstraction() { _node = node_construct.node_emitter( content_non_header, - segment_object_belongs_to, + segment_anchor_tag_that_object_belongs_to, obj_cite_number, - counter, - heading_pointer-1, + cntr, + heading_ptr-1, an_object["is"] ); the_document_body_section ~= @@ -1827,10 +1835,10 @@ template SiSUdocAbstraction() { _node = node_construct.node_emitter( content_non_header, - segment_object_belongs_to, + segment_anchor_tag_that_object_belongs_to, obj_cite_number, - counter, - heading_pointer-1, + cntr, + heading_ptr-1, an_object["is"] ); auto substantive_object_and_anchor_tags_tuple = @@ -1848,7 +1856,7 @@ template SiSUdocAbstraction() { ); object_reset(an_object); processing.remove("verse"); - ++counter; + ++cntr; type["blocks"] = TriState.off; type["table"] = TriState.off; } else if (type["group"] == TriState.closing) { @@ -1862,10 +1870,10 @@ template SiSUdocAbstraction() { _node = node_construct.node_emitter( content_non_header, - segment_object_belongs_to, + segment_anchor_tag_that_object_belongs_to, obj_cite_number, - counter, - heading_pointer-1, + cntr, + heading_ptr-1, an_object["is"] ); auto substantive_object_and_anchor_tags_tuple = @@ -1883,7 +1891,7 @@ template SiSUdocAbstraction() { ); object_reset(an_object); processing.remove("verse"); - ++counter; + ++cntr; type["blocks"] = TriState.off; type["group"] = TriState.off; } else if (type["block"] == TriState.closing) { @@ -1896,10 +1904,10 @@ template SiSUdocAbstraction() { _node = node_construct.node_emitter( content_non_header, - segment_object_belongs_to, + segment_anchor_tag_that_object_belongs_to, obj_cite_number, - counter, - heading_pointer-1, + cntr, + heading_ptr-1, an_object["is"] ); auto substantive_object_and_anchor_tags_tuple = @@ -1917,7 +1925,7 @@ template SiSUdocAbstraction() { ); object_reset(an_object); processing.remove("verse"); - ++counter; + ++cntr; type["blocks"] = TriState.off; type["block"] = TriState.off; } else if (type["quote"] == TriState.closing) { @@ -1931,10 +1939,10 @@ template SiSUdocAbstraction() { _node = node_construct.node_emitter( content_non_header, - segment_object_belongs_to, + segment_anchor_tag_that_object_belongs_to, obj_cite_number, - counter, - heading_pointer-1, + cntr, + heading_ptr-1, an_object["is"] ); auto substantive_object_and_anchor_tags_tuple = @@ -1952,7 +1960,7 @@ template SiSUdocAbstraction() { ); object_reset(an_object); processing.remove("verse"); - ++counter; + ++cntr; type["blocks"] = TriState.off; type["quote"] = TriState.off; } @@ -2667,7 +2675,7 @@ template SiSUdocAbstraction() { auto table_of_contents_gather_headings( string[string] obj_, string[string][string] dochead_make_aa, - string segment_object_belongs_to, + string segment_anchor_tag_that_object_belongs_to, string _anchor_tag, ObjComposite[][string] the_table_of_contents_section, ) @@ -2762,7 +2770,7 @@ template SiSUdocAbstraction() { toc_txt_ = format( "{ %s }../%s.fn_suffix", heading_toc_, - segment_object_belongs_to, + segment_anchor_tag_that_object_belongs_to, ); toc_txt_= munge.url_links(toc_txt_); indent=[ @@ -2783,7 +2791,7 @@ template SiSUdocAbstraction() { toc_txt_ = format( "{ %s }../%s.fn_suffix#%s", heading_toc_, - segment_object_belongs_to, + segment_anchor_tag_that_object_belongs_to, _anchor_tag, ); toc_txt_= munge.url_links(toc_txt_); @@ -3178,10 +3186,10 @@ template SiSUdocAbstraction() { oa_j.object["obj_cite_number"] = node_j["obj_cite_number"]; oa_j.object["lev_markup_number"] = node_j["lev_markup_number"]; oa_j.object["lev_collapsed_number"] = node_j["lev_collapsed_number"]; - oa_j.object["heading_pointer"] = - node_j["heading_pointer"]; // check - oa_j.object["doc_object_pointer"] = - node_j["doc_object_pointer"]; // check + oa_j.object["heading_ptr"] = + node_j["heading_ptr"]; // check + oa_j.object["doc_object_ptr"] = + node_j["doc_object_ptr"]; // check } oa_j.object["parent_obj_cite_number"] = node_j["parent_obj_cite_number"]; oa_j.object["parent_lev_markup_number"] = node_j["parent_lev_markup_number"]; @@ -3318,12 +3326,12 @@ template SiSUdocAbstraction() { auto bookindex_build_section( string[][string][string] bookindex_unordered_hashes, int obj_cite_number, - string segment_object_belongs_to, + string segment_anchor_tag_that_object_belongs_to, bool[string] opt_action_bool, ) { string type; string lev; - int lev_markup_number, lev_collapsed_number; + int lev_int_markup, lev_int_collapsed; string attrib; int[string] indent; auto set_abstract_object = ObjectAbstractSet(); @@ -3335,8 +3343,8 @@ template SiSUdocAbstraction() { string bi_tmp_seg, bi_tmp_scroll; attrib=""; lev="B"; - lev_markup_number=1; - lev_collapsed_number=1; + lev_int_markup=1; + lev_int_collapsed=1; bookindex_section["scroll"] ~= set_abstract_object.contents_heading( "Book Index", @@ -3344,8 +3352,8 @@ template SiSUdocAbstraction() { obj_cite_number, [], to!string(lev), - lev_markup_number, - lev_collapsed_number + lev_int_markup, + lev_int_collapsed ); bookindex_section["seg"] ~= set_abstract_object.contents_heading( @@ -3354,16 +3362,16 @@ template SiSUdocAbstraction() { obj_cite_number, [], to!string(lev), - lev_markup_number, - lev_collapsed_number + lev_int_markup, + lev_int_collapsed ); ++obj_cite_number; ++mkn; // 1~ Index attrib=""; lev="1"; - lev_markup_number=4; - lev_collapsed_number=2; + lev_int_markup=4; + lev_int_collapsed=2; bookindex_section["scroll"] ~= set_abstract_object.contents_heading( "Index", @@ -3371,8 +3379,8 @@ template SiSUdocAbstraction() { obj_cite_number, ["book_index"], to!string(lev), - lev_markup_number, - lev_collapsed_number + lev_int_markup, + lev_int_collapsed ); bookindex_section["seg"] ~= set_abstract_object.contents_heading( @@ -3381,8 +3389,8 @@ template SiSUdocAbstraction() { obj_cite_number, ["book_index"], to!string(lev), - lev_markup_number, - lev_collapsed_number + lev_int_markup, + lev_int_collapsed ); ++obj_cite_number; ++mkn; @@ -3392,9 +3400,9 @@ template SiSUdocAbstraction() { foreach (ref_; bookindex_unordered_hashes[mainkey]["_a"]) { auto go = replaceAll(ref_, rgx.book_index_go, "$1"); bi_tmp_scroll ~= munge.url_links(" {" ~ ref_ ~ "}#" ~ go ~ ", "); - bi_tmp_seg ~= (segment_object_belongs_to.empty) + bi_tmp_seg ~= (segment_anchor_tag_that_object_belongs_to.empty) ? munge.url_links(" {" ~ ref_ ~ "}#" ~ go ~ ", ") - : munge.url_links(" {" ~ ref_ ~ "}../" ~ segment_object_belongs_to ~ ".fn_suffix#" ~ go ~ ", "); + : munge.url_links(" {" ~ ref_ ~ "}../" ~ segment_anchor_tag_that_object_belongs_to ~ ".fn_suffix#" ~ go ~ ", "); } bi_tmp_scroll ~= " \\\\\n "; bi_tmp_seg ~= " \\\\\n "; @@ -3407,9 +3415,9 @@ template SiSUdocAbstraction() { foreach (ref_; bookindex_unordered_hashes[mainkey][subkey]) { auto go = replaceAll(ref_, rgx.book_index_go, "$1"); bi_tmp_scroll ~= munge.url_links(" {" ~ ref_ ~ "}#" ~ go ~ ", "); - bi_tmp_seg ~= (segment_object_belongs_to.empty) + bi_tmp_seg ~= (segment_anchor_tag_that_object_belongs_to.empty) ? munge.url_links(" {" ~ ref_ ~ "}#" ~ go ~ ", ") - : munge.url_links(" {" ~ ref_ ~ "}../" ~ segment_object_belongs_to ~ ".fn_suffix#" ~ go ~ ", "); + : munge.url_links(" {" ~ ref_ ~ "}../" ~ segment_anchor_tag_that_object_belongs_to ~ ".fn_suffix#" ~ go ~ ", "); } bi_tmp_scroll ~= " \\\\\n "; bi_tmp_seg ~= " \\\\\n "; @@ -3477,20 +3485,20 @@ template SiSUdocAbstraction() { auto rgx = Rgx(); private auto gather_notes_for_endnote_section( ObjComposite[] contents_am, - string segment_object_belongs_to, - ulong counter, + string segment_anchor_tag_that_object_belongs_to, + ulong cntr, ) in { // endnotes/ footnotes for // doc objects other than paragraphs & headings // various forms of grouped text - assert((contents_am[counter].is_a == "para") - || (contents_am[counter].is_a == "heading") - || (contents_am[counter].is_a == "group")); - assert(counter >= previous_count); - previous_count=counter; + assert((contents_am[cntr].is_a == "para") + || (contents_am[cntr].is_a == "heading") + || (contents_am[cntr].is_a == "group")); + assert(cntr >= previous_count); + previous_count=cntr; assert( - match(contents_am[counter].object, + match(contents_am[cntr].object, rgx.inline_notes_delimiter_al_regular_number_note) ); } @@ -3499,24 +3507,24 @@ template SiSUdocAbstraction() { foreach( m; matchAll( - contents_am[counter].object, + contents_am[cntr].object, rgx.inline_notes_delimiter_al_regular_number_note ) ) { debug(endnotes_build) { writeln( - "{^{", m.captures[1], ".}^}../", segment_object_belongs_to, ".fn_suffix#noteref_\n ", m.captures[1], " ", + "{^{", m.captures[1], ".}^}../", segment_anchor_tag_that_object_belongs_to, ".fn_suffix#noteref_\n ", m.captures[1], " ", m.captures[2]); // sometimes need segment name (segmented html & epub) } // TODO NEXT you need anchor for segments at this point -> object_notes["anchor"] ~= "#note_" ~ m.captures[1] ~ "』"; - object_notes["seg"] ~= (segment_object_belongs_to.empty) + object_notes["seg"] ~= (segment_anchor_tag_that_object_belongs_to.empty) ? (munge.url_links( "{^{" ~ m.captures[1] ~ ".}^}#noteref_" ~ m.captures[1]) ~ " " ~ m.captures[2] ~ "』" ) : (munge.url_links( - "{^{" ~ m.captures[1] ~ ".}^}../" ~ segment_object_belongs_to ~ ".fn_suffix#noteref_" ~ + "{^{" ~ m.captures[1] ~ ".}^}../" ~ segment_anchor_tag_that_object_belongs_to ~ ".fn_suffix#noteref_" ~ m.captures[1]) ~ " " ~ m.captures[2] ~ "』" ); object_notes["scroll"] ~= @@ -3666,11 +3674,11 @@ template SiSUdocAbstraction() { writeln("json: ", bib_arr_json.length); writeln("unsorted: ", biblio_unsorted.length); writeln("sorted: ", biblio_sorted__.length); - int counter; + int cntr; int[7] x; - while (counter < x.length) { - writeln(counter, ": ", biblio_sorted__[counter]["fulltitle"]); - counter++; + while (cntr < x.length) { + writeln(cntr, ": ", biblio_sorted__[cntr]["fulltitle"]); + cntr++; } } return biblio_sorted__; @@ -3737,9 +3745,9 @@ template SiSUdocAbstraction() { string node_emitter( string lev_markup_number, string segment_anchor_tag, - int obj_cite_number_, - long counter_, - int pointer_, + int obj_cite_number_, + long cntr_, + int ptr_, string is_ ) in { @@ -3765,20 +3773,20 @@ template SiSUdocAbstraction() { p_["obj_cite_number"] = lv4; } _node=("{ " ~ - "\"is\": \"" ~ is_ ~ "\"" ~ - ", \"heading_pointer\": " ~ to!string(pointer_) ~ - ", \"doc_object_pointer\": " ~ to!string(counter_) ~ - ", \"obj_cite_number\": " ~ to!string(obj_cite_number_) ~ - ", \"segment_anchor_tag\": \"" ~ segment_anchor_tag ~ "\"" ~ - ", \"parent_obj_cite_number\": " ~ to!string(p_["obj_cite_number"]) ~ + "\"is\": \"" ~ is_ ~ "\"" ~ + ", \"heading_ptr\": " ~ to!string(ptr_) ~ + ", \"doc_object_ptr\": " ~ to!string(cntr_) ~ + ", \"obj_cite_number\": " ~ to!string(obj_cite_number_) ~ + ", \"segment_anchor_tag\": \"" ~ segment_anchor_tag ~ "\"" ~ + ", \"parent_obj_cite_number\": " ~ to!string(p_["obj_cite_number"]) ~ ", \"parent_lev_markup_number\": " ~ to!string(p_["lev_markup_number"]) ~ " }" ); debug(node) { if (match(lev_markup_number, rgx.levels_numbered_headings)) { - writeln("* ", to!string(_node)); + writeln("x ", to!string(_node)); } else { - writeln("* ", to!string(_node)); + writeln("- ", to!string(_node)); } } JSONValue j = parseJSON(_node); @@ -3793,10 +3801,11 @@ template SiSUdocAbstraction() { string lev_markup_number, string lev_collapsed_number, string segment_anchor_tag, - int obj_cite_number_, - long counter_, - int pointer_, - string is_ + int obj_cite_number_, + long cntr_, + int ptr_, + string is_, + uint html_segnames_ptr, ) in { auto rgx = Rgx(); @@ -3815,15 +3824,15 @@ template SiSUdocAbstraction() { body { auto rgx = Rgx(); int obj_cite_number = to!int(obj_cite_number_); - switch (lev_markup_number) { // switch (to!string(lv)) { - case "0": + switch (to!int(lev_markup_number)) { // switch (to!string(lv)) { + case 0: lv = DocStructMarkupHeading.h_sect_A; lv0 = obj_cite_number; 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": + case 1: lv = DocStructMarkupHeading.h_sect_B; lv1 = obj_cite_number; lv2=0; lv3=0; lv4=0; lv5=0; lv6=0; lv7=0; @@ -3831,7 +3840,7 @@ template SiSUdocAbstraction() { DocStructMarkupHeading.h_sect_A; p_["obj_cite_number"] = lv0; break; - case "2": + case 2: lv = DocStructMarkupHeading.h_sect_C; lv2 = obj_cite_number; lv3=0; lv4=0; lv5=0; lv6=0; lv7=0; @@ -3839,7 +3848,7 @@ template SiSUdocAbstraction() { DocStructMarkupHeading.h_sect_B; p_["obj_cite_number"] = lv1; break; - case "3": + case 3: lv = DocStructMarkupHeading.h_sect_D; lv3=obj_cite_number; lv4=0; lv5=0; lv6=0; lv7=0; @@ -3847,7 +3856,7 @@ template SiSUdocAbstraction() { DocStructMarkupHeading.h_sect_C; p_["obj_cite_number"] = lv2; break; - case "4": + case 4: lv = DocStructMarkupHeading.h_text_1; lv4 = obj_cite_number; lv5=0; lv6=0; lv7=0; @@ -3869,7 +3878,7 @@ template SiSUdocAbstraction() { p_["obj_cite_number"] = lv0; } break; - case "5": + case 5: lv = DocStructMarkupHeading.h_text_2; lv5 = obj_cite_number; lv6=0; lv7=0; @@ -3877,7 +3886,7 @@ template SiSUdocAbstraction() { DocStructMarkupHeading.h_text_1; p_["obj_cite_number"] = lv4; break; - case "6": + case 6: lv = DocStructMarkupHeading.h_text_3; lv6 = obj_cite_number; lv7=0; @@ -3885,7 +3894,7 @@ template SiSUdocAbstraction() { DocStructMarkupHeading.h_text_2; p_["obj_cite_number"] = lv5; break; - case "7": + case 7: lv = DocStructMarkupHeading.h_text_4; lv7 = obj_cite_number; p_["lev_markup_number"] = @@ -3896,15 +3905,16 @@ template SiSUdocAbstraction() { break; } _node=("{ " ~ - "\"is\": \"" ~ is_ ~ "\"" ~ - ", \"heading_pointer\": " ~ to!string(pointer_) ~ - ", \"doc_object_pointer\": " ~ to!string(counter_) ~ - ", \"obj_cite_number\": " ~ to!string(obj_cite_number_) ~ - ", \"lev_markup_number\": " ~ to!string(lev_markup_number) ~ - ", \"lev_collapsed_number\": " ~ to!string(lev_collapsed_number) ~ - ", \"segment_anchor_tag\": \"" ~ segment_anchor_tag ~ "\"" ~ - ", \"parent_obj_cite_number\": " ~ to!string(p_["obj_cite_number"]) ~ - ", \"parent_lev_markup_number\": " ~ to!string(p_["lev_markup_number"]) ~ + "\"is\": \"" ~ is_ ~ "\"" ~ + ", \"heading_ptr\": " ~ to!string(ptr_) ~ + ", \"doc_object_ptr\": " ~ to!string(cntr_) ~ + ", \"html_segnames_ptr\": \"" ~ ((lev_markup_number == "4") ? (to!string(html_segnames_ptr)) : "") ~ "\"" ~ + ", \"obj_cite_number\": " ~ to!string(obj_cite_number_) ~ + ", \"lev_markup_number\": " ~ to!string(lev_markup_number) ~ + ", \"lev_collapsed_number\": " ~ to!string(lev_collapsed_number) ~ + ", \"segment_anchor_tag\": \"" ~ segment_anchor_tag ~ "\"" ~ + ", \"parent_obj_cite_number\": " ~ to!string(p_["obj_cite_number"]) ~ + ", \"parent_lev_markup_number\": " ~ to!string(p_["lev_markup_number"]) ~ " }" ); debug(heading) { @@ -3912,11 +3922,9 @@ template SiSUdocAbstraction() { writeln("* ", to!string(_node)); } } - debug(node) { + debug(nodeheading) { if (match(lev_markup_number, rgx.levels_numbered_headings)) { writeln("* ", to!string(_node)); - } else { - writeln("* ", to!string(_node)); } } JSONValue j = parseJSON(_node); diff --git a/src/sdp/ao_object_setter.d b/src/sdp/ao_object_setter.d index 844af9b..35ca768 100644 --- a/src/sdp/ao_object_setter.d +++ b/src/sdp/ao_object_setter.d @@ -6,9 +6,14 @@ template ObjectSetter() { /+ structs +/ struct HeadingAttrib { - string lev = "9"; - int lev_markup_number = 9; - int lev_collapsed_number = 9; + string lev = "9"; + int lev_int_markup = 9; + int lev_int_collapsed = 9; + int[] closes_lev_collapsed = []; // TODO track + int[] closes_lev_markup = []; // TODO track + int array_ptr = 0; + // heading segments, 1~ lev4: + int heading_array_ptr_segments = 0; // TODO } struct ParaAttrib { int indent_start = 0; @@ -22,10 +27,22 @@ template ObjectSetter() { // no .attrib and no .obj_cite_number } struct Node { - int ocn = 0; - int parent_lev = 0; - int parent_ocn = 0; - string node = ""; + int ocn = 0; + string seg_anchor_tag = ""; + // parent + int parent_lev_int_markup = 0; + int parent_ocn = 0; + int[] ancestors = []; // TODO track + // heading: + int heading_lev_int_markup = 0; + int heading_lev_int_collapsed = 0; + int[] heading_closes_lev_collapsed = []; // TODO track + int[] heading_closes_lev_markup = []; // TODO track + int heading_array_ptr = 0; + // heading segments, 1~ lev4: + int heading_array_ptr_segments = 0; // TODO + // node info json string: + string node = ""; } struct ObjComposite { string use = ""; @@ -59,8 +76,8 @@ template ObjectSetter() { in int obj_cite_number, in string[] tags, in string lev, - in int lev_markup_number, - in int lev_collapsed_number, + in int lev_int_markup, + in int lev_int_collapsed, ) { ObjComposite object_set; object_set.use = "content"; @@ -70,9 +87,8 @@ template ObjectSetter() { object_set.obj_cite_number = (obj_cite_number==0) ? "" : to!string(obj_cite_number); object_set.anchor_tags ~= tags; object_set.heading_attrib.lev = lev; - object_set.heading_attrib.lev_markup_number = lev_markup_number; - object_set.heading_attrib.lev_collapsed_number = lev_collapsed_number; - // object_set.node_structure.node = _node; + object_set.heading_attrib.lev_int_markup = lev_int_markup; + object_set.heading_attrib.lev_int_collapsed = lev_int_collapsed; return object_set; } auto contents_para( @@ -81,7 +97,7 @@ template ObjectSetter() { in string attrib, in int obj_cite_number, in int[string] indent, - in bool bullet + in bool bullet, ) { ObjComposite object_set; object_set.use = "content"; @@ -101,7 +117,7 @@ template ObjectSetter() { in string attrib, in int obj_cite_number, in int[string] indent, - in bool bullet + in bool bullet, ) { ObjComposite object_set; object_set.use = "content"; @@ -137,7 +153,7 @@ template ObjectSetter() { in string type, in string object, in string attrib, - in int obj_cite_number + in int obj_cite_number, ) { ObjComposite object_set; object_set.use = "content"; @@ -152,7 +168,7 @@ template ObjectSetter() { in string type, in string object, in string attrib_language_syntax, - in int obj_cite_number + in int obj_cite_number, ) { ObjComposite object_set; object_set.use = "content"; diff --git a/src/sdp/ao_output_debugs.d b/src/sdp/ao_output_debugs.d index 3c3b101..c6e8ac7 100644 --- a/src/sdp/ao_output_debugs.d +++ b/src/sdp/ao_output_debugs.d @@ -6,8 +6,7 @@ template SiSUoutputDebugs() { auto abstract_doc_source_debugs(S)( auto ref const S contents, string[][string] document_section_keys_sequenced, - string[][string][string] bookindex_unordered_hashes, // redundant, consider - JSONValue[] biblio, // redundant, consider + string[] html_segnames, string[string][string] dochead_make, string[string][string] dochead_meta, string fn_src, @@ -18,30 +17,7 @@ template SiSUoutputDebugs() { auto rgx = Rgx(); auto markup = InlineMarkup(); string key; - struct BookIndexReport { - int mkn, skn; - auto bookindex_report_sorted( - string[][string][string] bookindex_unordered_hashes - ) { - auto mainkeys=bookindex_unordered_hashes.byKey.array. - sort!("toLower(a) < toLower(b)", SwapStrategy.stable).release; - foreach (mainkey; mainkeys) { - auto subkeys=bookindex_unordered_hashes[mainkey].byKey.array. - sort!("toLower(a) < toLower(b)", SwapStrategy.stable).release; - foreach (subkey; subkeys) { - debug(bookindex) { - writeln( - mainkey, ": ", - subkey, ": ", - to!string(bookindex_unordered_hashes[mainkey][subkey]) - ); - } - ++skn; - } - ++mkn; - } - } - } + debug(parent) { writefln( "%s:%s", @@ -56,7 +32,7 @@ template SiSUoutputDebugs() { "%s node: %s heading: %s %s", obj.obj_cite_number, obj.node, - obj.lev_markup_number, + obj.lev_int_markup, obj.object, ); } @@ -251,12 +227,12 @@ template SiSUoutputDebugs() { "%s\n%s\n%s", "document header, metadata & make instructions:", dochead_meta, - pointer_head_main, + ptr_head_main, ); - foreach (main_header; pointer_head_main) { + foreach (main_header; ptr_head_main) { switch (main_header) { case "make": - foreach (sub_header; pointer_head_sub_make) { + foreach (sub_header; ptr_head_sub_make) { if (to!string(dochead_meta[main_header][sub_header]).length > 2) { writefln( "%s:%s: %s", @@ -277,12 +253,12 @@ template SiSUoutputDebugs() { "%s\n%s\n%s", "document header, metadata & make instructions:", dochead_meta, - pointer_head_main, + ptr_head_main, ); - foreach (main_header; pointer_head_main) { + foreach (main_header; ptr_head_main) { switch (main_header) { case "creator": - foreach (sub_header; pointer_head_sub_creator) { + foreach (sub_header; ptr_head_sub_creator) { if (to!string(dochead_meta[main_header][sub_header]).length > 2) { writefln( "%s:%s: %s", @@ -294,7 +270,7 @@ template SiSUoutputDebugs() { } break; case "title": - foreach (sub_header; pointer_head_sub_title) { + foreach (sub_header; ptr_head_sub_title) { if (to!string(dochead_meta[main_header][sub_header]).length > 2) { writefln( "%s:%s: %s", @@ -306,7 +282,7 @@ template SiSUoutputDebugs() { } break; case "rights": - foreach (sub_header; pointer_head_sub_rights) { + foreach (sub_header; ptr_head_sub_rights) { if (to!string(dochead_meta[main_header][sub_header]).length > 2) { writefln( "%s:%s: %s", @@ -318,7 +294,7 @@ template SiSUoutputDebugs() { } break; case "date": - foreach (sub_header; pointer_head_sub_date) { + foreach (sub_header; ptr_head_sub_date) { if (to!string(dochead_meta[main_header][sub_header]).length > 2) { writefln( "%s:%s: %s", @@ -330,7 +306,7 @@ template SiSUoutputDebugs() { } break; case "original": - foreach (sub_header; pointer_head_sub_original) { + foreach (sub_header; ptr_head_sub_original) { if (to!string(dochead_meta[main_header][sub_header]).length > 2) { writefln( "%s:%s: %s", @@ -342,7 +318,7 @@ template SiSUoutputDebugs() { } break; case "classify": - foreach (sub_header; pointer_head_sub_classify) { + foreach (sub_header; ptr_head_sub_classify) { if (to!string(dochead_meta[main_header][sub_header]).length > 2) { writefln( "%s:%s: %s", @@ -354,7 +330,7 @@ template SiSUoutputDebugs() { } break; case "identifier": - foreach (sub_header; pointer_head_sub_identifier) { + foreach (sub_header; ptr_head_sub_identifier) { if (to!string(dochead_meta[main_header][sub_header]).length > 2) { writefln( "%s:%s: %s", @@ -366,7 +342,7 @@ template SiSUoutputDebugs() { } break; case "notes": - foreach (sub_header; pointer_head_sub_notes) { + foreach (sub_header; ptr_head_sub_notes) { if (to!string(dochead_meta[main_header][sub_header]).length > 2) { writefln( "%s:%s: %s", @@ -378,7 +354,7 @@ template SiSUoutputDebugs() { } break; case "publisher": - foreach (sub_header; pointer_head_sub_publisher) { + foreach (sub_header; ptr_head_sub_publisher) { if (to!string(dochead_meta[main_header][sub_header]).length > 2) { writefln( "%s:%s: %s", @@ -394,27 +370,6 @@ template SiSUoutputDebugs() { } } } - debug(bookindex) { - writefln( - "%s\n%s:%s", - "-------------------------------", - __FILE__, - __LINE__, - ); - auto bookindex = BookIndexReport(); - bookindex.bookindex_report_sorted(bookindex_unordered_hashes); - } - - debug(biblio) { - foreach (entry; biblio) { - writefln( - "%s; (%s)", - entry["sortby_deemed_author_year_title"], - entry["author"], - ); - } - } - debug(anchor) { writefln( "%s\n%s:%s", @@ -442,7 +397,7 @@ template SiSUoutputDebugs() { foreach (k; document_section_keys_sequenced["seg"]) { foreach (o; contents[k]) { if (o.is_a == "heading") { - switch (o.heading_attrib.lev_markup_number) { + switch (o.heading_attrib.lev_int_markup) { case 0: spc=""; break; @@ -478,8 +433,8 @@ template SiSUoutputDebugs() { "%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 + o.heading_attrib.lev_int_markup, + o.heading_attrib.lev_int_collapsed ); } } diff --git a/src/sdp/output_html.d b/src/sdp/output_html.d index c20d6ef..3767d5a 100644 --- a/src/sdp/output_html.d +++ b/src/sdp/output_html.d @@ -14,12 +14,12 @@ template SiSUoutputHTML() { ¶", obj.obj_cite_number, obj.obj_cite_number, - obj.heading_attrib.lev_markup_number, + obj.heading_attrib.lev_int_markup, obj.is_a, obj.obj_cite_number, obj.obj_cite_number, obj.object, - obj.heading_attrib.lev_markup_number + obj.heading_attrib.lev_int_markup ); return o; } diff --git a/src/sdp/output_hub.d b/src/sdp/output_hub.d index bdb8480..7235619 100644 --- a/src/sdp/output_hub.d +++ b/src/sdp/output_hub.d @@ -7,6 +7,7 @@ template SiSUoutputHub() { void hub(S)( auto ref const S contents, string[][string] document_section_keys_sequenced, + string[] html_segnames, string[string][string] dochead_make, string[string][string] dochead_meta, string fn_src, -- cgit v1.2.3