From 0079c34ce7a524d4b93ed56191b5e7cf6a380975 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Tue, 1 Nov 2016 10:06:47 -0400 Subject: 0.8.0 the document parts (& org babel tangle) --- src/sdp/ao_abstract_doc_source.d | 524 +++++++++++++++++++++++++++++++-------- 1 file changed, 427 insertions(+), 97 deletions(-) (limited to 'src/sdp/ao_abstract_doc_source.d') diff --git a/src/sdp/ao_abstract_doc_source.d b/src/sdp/ao_abstract_doc_source.d index 074fbc5..683b748 100644 --- a/src/sdp/ao_abstract_doc_source.d +++ b/src/sdp/ao_abstract_doc_source.d @@ -17,7 +17,10 @@ template SiSUdocAbstraction() { /+ ↓ abstraction struct init +/ /+ initialize +/ auto rgx = Rgx(); - ObjComposite[] contents_the_objects; + ObjComposite[] the_document_head_section; + ObjComposite[][string] the_table_of_contents_section; + ObjComposite[] the_document_body_section; + ObjComposite[] the_bibliography_section; string[string] an_object, processing; string[] anchor_tags; string segment_object_belongs_to; @@ -83,7 +86,10 @@ template SiSUdocAbstraction() { scope(failure) { } scope(exit) { - destroy(contents_the_objects); + destroy(the_document_head_section); + destroy(the_table_of_contents_section); + destroy(the_document_body_section); + destroy(the_bibliography_section); destroy(an_object); destroy(processing); destroy(biblio_arr_json); @@ -272,9 +278,9 @@ template SiSUdocAbstraction() { writeln(line); } an_object["obj"] ~= line ~= "\n"; - contents_the_objects ~= + the_document_body_section ~= set_abstract_object.contents_comment(strip(an_object["obj"])); - _header_set_common_(line_occur, an_object, type); + _common_reset_(line_occur, an_object, type); processing.remove("verse"); ++counter; } else if (((line_occur["para"] == State.off) @@ -295,6 +301,13 @@ template SiSUdocAbstraction() { /+ heading make set +/ _heading_make_set_(line, line_occur, heading_match_rgx, type); } + /+ TODO node info: all headings identified at this point, + - extract node info here?? + - how long can it wait? + - should be incorporated in composite objects + - should happen before endnote links set (they need to be moved down?) + // node_construct.node_emitter_heading segment anchor tag + +/ if (matchFirst(line, rgx.heading)) { /+ heading match +/ _heading_matched_(line, line_occur, an_object, lv, collapsed_lev, type, dochead_meta_aa); @@ -320,7 +333,18 @@ template SiSUdocAbstraction() { } } else if (type["blocks"] == TriState.closing) { /+ line empty, with blocks flag +/ - _block_flag_line_empty_(line, an_object, contents_the_objects, bookindex_unordered_hashes, obj_cite_number, _node, counter, type, obj_cite_number_poem, dochead_make_aa); // watch + _block_flag_line_empty_( + line, + an_object, + the_document_body_section, + bookindex_unordered_hashes, + obj_cite_number, + _node, + counter, + type, + obj_cite_number_poem, + dochead_make_aa + ); // watch } else { /+ line empty +/ /+ line.empty, post contents, empty variables: +/ @@ -350,6 +374,13 @@ template SiSUdocAbstraction() { } else if (to!int(an_object["lev_markup_number"]) < 4) { segment_object_belongs_to = ""; } + the_table_of_contents_section = obj_im.table_of_contents_gather_headings( + an_object, + dochead_make_aa, + segment_object_belongs_to, + obj_cite_number, + the_table_of_contents_section, + ); _node = node_construct.node_emitter_heading( an_object["lev_markup_number"], @@ -367,7 +398,7 @@ template SiSUdocAbstraction() { writeln(an_object["lev_markup_number"]); writeln(segment_object_belongs_to); } - contents_the_objects ~= + the_document_body_section ~= set_abstract_object.contents_heading( an_object["substantive"], an_object["attrib"], @@ -384,7 +415,7 @@ template SiSUdocAbstraction() { // writeln(contents_am[counter]["obj_cite_number"], " ", contents_am[counter]["obj"]); // writeln(m.hit, "\n"); } - _header_set_common_(line_occur, an_object, type); + _common_reset_(line_occur, an_object, type); an_object.remove("lev"); an_object.remove("lev_markup_number"); // an_object["lev_markup_number"]="9"; @@ -413,7 +444,7 @@ template SiSUdocAbstraction() { anchor_tags = substantive_object_and_anchor_tags_tuple[1]; an_object["attrib"] = obj_att.obj_attributes(an_object["is"], an_object["obj"], _node); - contents_the_objects ~= + the_document_body_section ~= set_abstract_object.contents_para( an_object["is"], an_object["substantive"], @@ -422,16 +453,11 @@ template SiSUdocAbstraction() { indent, bullet ); - // contents_the_objects ~= - // set_abstract_object.contents_para( - // an_object, - // obj_cite_number, - // indent, - // bullet - // ); - _header_set_common_(line_occur, an_object, type); - indent["hang_position"] = "0"; - indent["base_position"] = "0"; + _common_reset_(line_occur, an_object, type); + indent=[ + "hang_position" : "0", + "base_position" : "0", + ]; bullet = false; processing.remove("verse"); ++counter; @@ -445,18 +471,18 @@ template SiSUdocAbstraction() { } // close else for line empty } // close else for not the above } // close after non code, other blocks or regular text - /+ unless (contents_the_objects.length == 0) ? +/ - if (contents_the_objects.length > 0) { - if (((contents_the_objects[$-1].is_a == "para") - || (contents_the_objects[$-1].is_a == "heading")) + /+ unless (the_document_body_section.length == 0) ? +/ + 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 (match(contents_the_objects[$-1].object, + if (match(the_document_body_section[$-1].object, rgx.inline_notes_delimiter_al_regular_number_note)) { - previous_count=contents_the_objects.length -1; + previous_count=the_document_body_section.length -1; note_section.gather_notes_for_endnote_section( - contents_the_objects, + the_document_body_section, segment_object_belongs_to, - contents_the_objects.length -1 + the_document_body_section.length -1 ); } } @@ -475,39 +501,116 @@ template SiSUdocAbstraction() { +/ // TODO FIGURE OUT, you need this possibility // obj_im.obj_inline_markup_and_anchor_tags("doc_end_reset", "", dochead_make_aa); + debug(toc) { + writefln( + "%s %s", + __LINE__, + the_table_of_contents_section["seg"].length + ); + foreach (toc_linked_heading; the_table_of_contents_section["seg"]) { + writeln(toc_linked_heading.object); + } + } auto en_tuple = note_section.endnote_objects(obj_cite_number); static assert(!isTypeTuple!(en_tuple)); - auto endnotes_section = en_tuple[0]; + auto the_endnotes_section = en_tuple[0]; obj_cite_number = en_tuple[1]; debug(endnotes) { writefln( "%s %s", __LINE__, - endnotes_section.length + the_endnotes_section["seg"].length + ); + foreach (o; the_endnotes_section["seg"]) { + writeln(o); + } + } + the_bibliography_section ~= + set_abstract_object.contents_heading( + "Bibliography", // nugget/object + "", // attrib + 0, // obj_cite_number + [""], // anchor tag + "B", // lev + 1, // lev_markup_number + 1, // lev_collapsed_number + ); + the_bibliography_section ~= + set_abstract_object.contents_heading( + "Bibliography", // nugget/object + "", // attrib + 0, // obj_cite_number + ["bibliography"], // anchor tag + "1", // lev + 4, // lev_markup_number + 2, // lev_collapsed_number ); - foreach (n; endnotes_section) { - writeln(n); - } - } auto biblio_unsorted_incomplete = biblio_arr_json.dup; // destroy(biblio_arr_json); auto biblio = Bibliography(); auto biblio_ordered = biblio._bibliography_(biblio_unsorted_incomplete, bib_arr_json); + string out_; + foreach (entry; biblio_ordered) { + out_ = format( + "%s \"%s\"%s%s%s%s%s%s%s%s%s.", + ((entry["author"].str.empty) ? entry["editor"].str : entry["author"].str), + entry["fulltitle"].str, + ((entry["journal"].str.empty) ? "" : ", /{" ~ entry["journal"].str ~ "}/"), + ((entry["volume"].str.empty) ? "" : ", " ~ entry["volume"].str), + ((entry["in"].str.empty) ? "" : ", " ~ entry["in"].str), + ((!(entry["author"].str.empty) && (!(entry["editor"].str.empty))) ? entry["editor"].str : ""), + ", " ~ entry["year"].str, + ((entry["pages"].str.empty) ? "" : ", " ~ entry["pages"].str), + ((entry["publisher"].str.empty) ? "" : ", " ~ entry["publisher"].str), + ((entry["place"].str.empty) ? "" : ", " ~ entry["place"].str), + ((entry["url"].str.empty) ? "" : ", [" ~ entry["url"].str ~ "]"), + ); + the_bibliography_section ~= + set_abstract_object.contents_para( + "bibliography", + out_, // nugget/object + "", // attrib + 0, // obj_cite_number + ([ "hang_position" : "0", "base_position" : "1", ]), // indent + false + ); + } + debug(bibliosection) { + foreach (o; the_bibliography_section) { + writeln(o.object); + } + } auto bi = BookIndexReportSection(); auto bi_tuple = - bi.bookindex_build_section(bookindex_unordered_hashes, obj_cite_number, segment_object_belongs_to); + bi.bookindex_build_section( + bookindex_unordered_hashes, + obj_cite_number, + segment_object_belongs_to + ); static assert(!isTypeTuple!(bi_tuple)); - auto bookindex_section = bi_tuple[0]; + auto the_bookindex_section = bi_tuple[0]; obj_cite_number = bi_tuple[1]; debug(bookindex) { // bookindex - foreach (bi_entry; bookindex_section) { + foreach (bi_entry; the_bookindex_section["seg"]) { writeln(bi_entry); } } - auto document_the = - contents_the_objects ~ endnotes_section ~ bookindex_section; + the_document_head_section ~= the_document_body_section[0]; + the_document_body_section=the_document_body_section[1..$]; + auto document_the = [ + "head": the_document_head_section, + "toc_seg": the_table_of_contents_section["seg"], + "toc_scroll": the_table_of_contents_section["scroll"], + "body": the_document_body_section, + "endnotes_seg": the_endnotes_section["seg"], + "endnotes_scroll": the_endnotes_section["scroll"], + // "glossary": the_glossary_section, // TODO + "bibliography": the_bibliography_section, + "bookindex_scroll": the_bookindex_section["scroll"], + "bookindex_seg": the_bookindex_section["seg"], + ]; auto t = tuple( document_the, bookindex_unordered_hashes, @@ -524,12 +627,11 @@ template SiSUdocAbstraction() { an_object.remove("attrib"); an_object.remove("bookindex"); } - auto _header_set_common_( + auto _common_reset_( ref int[string] line_occur, ref string[string] an_object, ref int[string] type ) { - // line_occur["header"] = State.off; line_occur["heading"] = State.off; line_occur["para"]= State.off; type["heading"] = State.off; @@ -944,7 +1046,7 @@ template SiSUdocAbstraction() { anchor_tags = substantive_object_and_anchor_tags_tuple[1]; an_object["attrib"] = obj_att.obj_attributes(an_object["is"], an_object["obj"], _node); - contents_the_objects ~= + the_document_body_section ~= set_abstract_object.contents_block( an_object["is"], an_object["substantive"], @@ -966,7 +1068,7 @@ template SiSUdocAbstraction() { obj_cite_number = obj_cite_number_emit(type["obj_cite_number_status"]); type["verse_new"] = State.off; - } else if (matchFirst(line, rgx.line_delimiter_only)) { + } else if (matchFirst(line, rgx.newline_eol_delimiter_only)) { verse_line = TriState.off; type["verse_new"] = State.on; } @@ -996,7 +1098,7 @@ template SiSUdocAbstraction() { anchor_tags = substantive_object_and_anchor_tags_tuple[1]; an_object["attrib"] = obj_att.obj_attributes(an_object["is"], an_object["obj"], _node); - contents_the_objects ~= + the_document_body_section ~= set_abstract_object.contents_block( an_object["is"], an_object["substantive"], @@ -1033,7 +1135,7 @@ template SiSUdocAbstraction() { anchor_tags = substantive_object_and_anchor_tags_tuple[1]; an_object["attrib"] = obj_att.obj_attributes(an_object["is"], an_object["obj"], _node); - contents_the_objects ~= + the_document_body_section ~= set_abstract_object.contents_block( an_object["is"], an_object["substantive"], @@ -1054,7 +1156,7 @@ template SiSUdocAbstraction() { obj_cite_number = obj_cite_number_emit(type["obj_cite_number_status"]); type["verse_new"] = State.off; - } else if (matchFirst(line, rgx.line_delimiter_only)) { + } else if (matchFirst(line, rgx.newline_eol_delimiter_only)) { type["verse_new"] = State.on; verse_line = TriState.off; } @@ -1085,7 +1187,7 @@ template SiSUdocAbstraction() { anchor_tags = substantive_object_and_anchor_tags_tuple[1]; an_object["attrib"] = obj_att.obj_attributes(an_object["is"], an_object["obj"], _node); - contents_the_objects ~= + the_document_body_section ~= set_abstract_object.contents_block( an_object["is"], an_object["substantive"], @@ -1242,7 +1344,7 @@ template SiSUdocAbstraction() { void _block_flag_line_empty_( char[] line, ref string[string] an_object, - ref ObjComposite[] contents_the_objects, + ref ObjComposite[] the_document_body_section, ref string[][string][string] bookindex_unordered_hashes, ref int obj_cite_number, ref string _node, @@ -1284,7 +1386,7 @@ template SiSUdocAbstraction() { anchor_tags = substantive_object_and_anchor_tags_tuple[1]; an_object["attrib"] = obj_att.obj_attributes(an_object["is"], an_object["obj"], _node); - contents_the_objects ~= + the_document_body_section ~= set_abstract_object.contents_block_code( an_object["is"], an_object["substantive"], @@ -1313,7 +1415,7 @@ template SiSUdocAbstraction() { an_object["is"] // "verse" ); - contents_the_objects ~= + the_document_body_section ~= set_abstract_object.contents_block_obj_cite_number_string( "poem", "", @@ -1348,7 +1450,7 @@ template SiSUdocAbstraction() { anchor_tags = substantive_object_and_anchor_tags_tuple[1]; an_object["attrib"] = obj_att.obj_attributes(an_object["is"], an_object["obj"], _node); - contents_the_objects ~= + the_document_body_section ~= set_abstract_object.contents_block( an_object["is"], an_object["substantive"], @@ -1383,7 +1485,7 @@ template SiSUdocAbstraction() { anchor_tags = substantive_object_and_anchor_tags_tuple[1]; an_object["attrib"] = obj_att.obj_attributes(an_object["is"], an_object["obj"], _node); - contents_the_objects ~= + the_document_body_section ~= set_abstract_object.contents_block( an_object["is"], an_object["substantive"], @@ -1417,7 +1519,7 @@ template SiSUdocAbstraction() { anchor_tags = substantive_object_and_anchor_tags_tuple[1]; an_object["attrib"] = obj_att.obj_attributes(an_object["is"], an_object["obj"], _node); - contents_the_objects ~= + the_document_body_section ~= set_abstract_object.contents_block( an_object["is"], an_object["substantive"], @@ -1452,7 +1554,7 @@ template SiSUdocAbstraction() { anchor_tags = substantive_object_and_anchor_tags_tuple[1]; an_object["attrib"] = obj_att.obj_attributes(an_object["is"], an_object["obj"], _node); - contents_the_objects ~= + the_document_body_section ~= set_abstract_object.contents_block( an_object["is"], an_object["substantive"], @@ -1672,8 +1774,10 @@ template SiSUdocAbstraction() { assertions_doc_structure(an_object, lv); // includes most of the logic for collapsed levels switch (an_object["lev"]) { case "A": - an_object["obj"]=replaceFirst(an_object["obj"], rgx.variable_doc_title, dochead_meta_aa["title"]["main"]); - an_object["obj"]=replaceFirst(an_object["obj"], rgx.variable_doc_author, dochead_meta_aa["creator"]["author"]); + an_object["obj"]=replaceFirst(an_object["obj"], + rgx.variable_doc_title, (dochead_meta_aa["title"]["full"] ~ ",")); + an_object["obj"]=replaceFirst(an_object["obj"], + rgx.variable_doc_author, dochead_meta_aa["creator"]["author"]); collapsed_lev["h0"] = 1; an_object["lev_collapsed_number"] = to!string(collapsed_lev["h0"]); @@ -1817,8 +1921,10 @@ template SiSUdocAbstraction() { } type["para"] = State.on; an_object["obj"] ~= line; - indent["hang_position"] = "0"; - indent["base_position"] = "0"; + indent=[ + "hang_position" : "0", + "base_position" : "0", + ]; bullet = true; } else if (auto m = matchFirst(line, rgx.para_indent_hang)) { debug(paraindenthang) { // para indent hang @@ -1826,8 +1932,10 @@ template SiSUdocAbstraction() { } type["para"] = State.on; an_object["obj"] ~= line; - indent["hang_position"] = to!string(m.captures[1]); - indent["base_position"] = to!string(m.captures[2]); + indent=[ + "hang_position" : to!string(m.captures[1]), + "base_position" : to!string(m.captures[2]), + ]; bullet = false; } else if (auto m = matchFirst(line, rgx.para_bullet_indent)) { debug(parabulletindent) { // para bullet indent @@ -1835,15 +1943,19 @@ template SiSUdocAbstraction() { } type["para"] = State.on; an_object["obj"] ~= line; - indent["hang_position"] = to!string(m.captures[1]); - indent["base_position"] = "0"; + indent=[ + "hang_position" : to!string(m.captures[1]), + "base_position" : "0", + ]; bullet = true; } else { // !line.empty type["para"] = State.on; an_object["obj"] ~= line; - indent["hang_position"] = "0"; - indent["base_position"] = "0"; + indent=[ + "hang_position" : "0", + "base_position" : "0", + ]; bullet = false; } ++line_occur["para"]; @@ -1963,6 +2075,7 @@ template SiSUdocAbstraction() { obj_txt["munge"]=obj_txt_in; obj_txt["munge"]=replaceFirst(obj_txt["munge"], rgx.heading, ""); obj_txt["munge"]=replaceFirst(obj_txt["munge"], rgx.obj_cite_number_off_all, ""); + obj_txt["munge"]=strip(obj_txt["munge"]); obj_txt["munge"]=object_notes_(obj_txt["munge"]); debug(munge) { writeln(__LINE__); @@ -2054,7 +2167,10 @@ template SiSUdocAbstraction() { struct ObjInlineMarkup { auto munge = ObjInlineMarkupMunge(); string[string] obj_txt; - auto obj_inline_markup_and_anchor_tags(string[string] obj_, string[string][string] dochead_make_aa) + auto obj_inline_markup_and_anchor_tags( + string[string] obj_, + string[string][string] dochead_make_aa + ) in { } body { obj_txt["munge"]=obj_["obj"].dup; @@ -2115,6 +2231,150 @@ template SiSUdocAbstraction() { } invariant() { } + auto _clean_heading_toc_( + char[] heading_toc_, + ) { + auto m = matchFirst(cast(char[]) heading_toc_, rgx.heading); + heading_toc_ = m.post; + return heading_toc_; + }; + auto table_of_contents_gather_headings( + string[string] obj_, + string[string][string] dochead_make_aa, + string segment_object_belongs_to, + int obj_cite_number, + ObjComposite[][string] the_table_of_contents_section, + ) + in { } + body { + char[] heading_toc_ = to!(char[])(obj_["obj"].dup.strip); + heading_toc_ = _clean_heading_toc_(heading_toc_); + auto attrib=""; + string toc_txt_; + string[string] indent; + auto set_abstract_object = ObjectAbstractSet(); + if (to!int(obj_["lev_markup_number"]) > 0) { + toc_txt_ = format( + "{ %s }#%s", + heading_toc_, + obj_cite_number, + ); + indent=[ + "hang_position" : obj_["lev_markup_number"], + "base_position" : obj_["lev_markup_number"], + ]; + toc_txt_ = format( + "{ %s }#%s", + heading_toc_, + obj_cite_number, + ); + the_table_of_contents_section["scroll"] ~= + set_abstract_object.contents_para( + "toc", + toc_txt_, + "", // attrib + 0, + indent, + false + ); + } else { + indent=[ + "hang_position" : "0", + "base_position" : "0", + ]; + the_table_of_contents_section["scroll"] ~= + set_abstract_object.contents_para( + "toc", + "Table of Contents", + "", // attrib + 0, + indent, + false + ); + } + switch (to!int(obj_["lev_markup_number"])) { + case 0: + indent=[ + "hang_position" : "0", + "base_position" : "0", + ]; + the_table_of_contents_section["seg"] ~= + set_abstract_object.contents_para( + "toc", + "{ Table of Contents }../toc.fn_suffix", + "", // attrib + 0, + indent, + false + ); + break; + case 1: .. case 3: + indent=[ + "hang_position" : obj_["lev_markup_number"], + "base_position" : obj_["lev_markup_number"], + ]; + toc_txt_ = format( + "%s", + heading_toc_, + ); + the_table_of_contents_section["seg"] ~= + set_abstract_object.contents_para( + "toc", + toc_txt_, + "", // attrib + 0, + indent, + false + ); + break; + case 4: + toc_txt_ = format( + "{ %s }../%s.fn_suffix", + heading_toc_, + segment_object_belongs_to, + ); + indent=[ + "hang_position" : obj_["lev_markup_number"], + "base_position" : obj_["lev_markup_number"], + ]; + the_table_of_contents_section["seg"] ~= + set_abstract_object.contents_para( + "toc", + toc_txt_, + "", // attrib + 0, + indent, + false + ); + break; + case 5: .. case 7: + toc_txt_ = format( + "{ %s }../%s.fn_suffix#%s", + heading_toc_, + segment_object_belongs_to, + obj_cite_number, + ); + indent=[ + "hang_position" : obj_["lev_markup_number"], + "base_position" : obj_["lev_markup_number"], + ]; + the_table_of_contents_section["seg"] ~= + set_abstract_object.contents_para( + "toc", + toc_txt_, + "", // attrib + 0, + indent, + false + ); + break; + default: + break; + } + return the_table_of_contents_section; + } + invariant() { + } private: static string _configured_auto_heading_numbering_and_segment_anchor_tags(string munge_, string[string] obj_, string[string][string] dochead_make_aa) { if (dochead_make_aa["make"]["num_top"].length > 0) { @@ -2639,15 +2899,25 @@ template SiSUdocAbstraction() { auto set_abstract_object = ObjectAbstractSet(); auto mainkeys = bookindex_unordered_hashes.byKey.array.sort().release; - string bi_tmp; - ObjComposite[] bookindex_section; + string bi_tmp_seg, bi_tmp_scroll; + ObjComposite[][string] bookindex_section; // writeln(mainkeys.length); // B~ Book Index attrib=""; lev="B"; lev_markup_number="1"; lev_collapsed_number="1"; - bookindex_section ~= + bookindex_section["scroll"] ~= + set_abstract_object.contents_heading( + "Book Index", + attrib, + obj_cite_number, + [], + to!string(lev), + to!int(lev_markup_number), + to!int(lev_collapsed_number) + ); + bookindex_section["seg"] ~= set_abstract_object.contents_heading( "Book Index", attrib, @@ -2664,7 +2934,17 @@ template SiSUdocAbstraction() { lev="1"; lev_markup_number="4"; lev_collapsed_number="2"; - bookindex_section ~= + bookindex_section["scroll"] ~= + set_abstract_object.contents_heading( + "Index", + attrib, + obj_cite_number, + ["book_index"], + to!string(lev), + to!int(lev_markup_number), + to!int(lev_collapsed_number) + ); + bookindex_section["seg"] ~= set_abstract_object.contents_heading( "Index", attrib, @@ -2677,35 +2957,43 @@ template SiSUdocAbstraction() { ++obj_cite_number; ++mkn; foreach (mainkey; mainkeys) { - bi_tmp = "!{" ~ mainkey ~ "}! "; + bi_tmp_scroll = "!{" ~ mainkey ~ "}! "; + bi_tmp_seg = "!{" ~ mainkey ~ "}! "; // bi_tmp = "_0_1 !{" ~ mainkey ~ "}! "; foreach (ref_; bookindex_unordered_hashes[mainkey]["_a"]) { auto go = replaceAll(ref_, rgx.book_index_go, "$1"); - bi_tmp ~= (segment_object_belongs_to.empty) + bi_tmp_scroll ~= (" {" ~ ref_ ~ "}#" ~ go ~ ", "); + bi_tmp_seg ~= (segment_object_belongs_to.empty) ? (" {" ~ ref_ ~ "}#" ~ go ~ ", ") - : (" {" ~ ref_ ~ "}[../" ~ segment_object_belongs_to ~ ".fn_suffix]#" ~ go ~ ", "); + : (" {" ~ ref_ ~ "}../" ~ segment_object_belongs_to ~ ".fn_suffix#" ~ go ~ ", "); } - bi_tmp ~= " \\\\\n "; + bi_tmp_scroll ~= " \\\\\n "; + bi_tmp_seg ~= " \\\\\n "; bookindex_unordered_hashes[mainkey].remove("_a"); auto subkeys = bookindex_unordered_hashes[mainkey].byKey.array.sort().release; foreach (subkey; subkeys) { - bi_tmp ~= subkey ~ ", "; + bi_tmp_scroll ~= subkey ~ ", "; + bi_tmp_seg ~= subkey ~ ", "; foreach (ref_; bookindex_unordered_hashes[mainkey][subkey]) { auto go = replaceAll(ref_, rgx.book_index_go, "$1"); - bi_tmp ~= (segment_object_belongs_to.empty) + bi_tmp_scroll ~= (" {" ~ ref_ ~ "}#" ~ go ~ ", "); + bi_tmp_seg ~= (segment_object_belongs_to.empty) ? (" {" ~ ref_ ~ "}#" ~ go ~ ", ") - : (" {" ~ ref_ ~ "}[../" ~ segment_object_belongs_to ~ ".fn_suffix]#" ~ go ~ ", "); + : (" {" ~ ref_ ~ "}../" ~ segment_object_belongs_to ~ ".fn_suffix#" ~ go ~ ", "); } - bi_tmp ~= " \\\\\n "; + bi_tmp_scroll ~= " \\\\\n "; + bi_tmp_seg ~= " \\\\\n "; ++skn; } - bi_tmp = replaceFirst(bi_tmp, rgx.trailing_linebreak, ""); + bi_tmp_scroll = replaceFirst(bi_tmp_scroll, rgx.trailing_linebreak, ""); + bi_tmp_seg = replaceFirst(bi_tmp_seg, rgx.trailing_linebreak, ""); type="para"; attrib=""; - indent["hang_position"] = "0"; - indent["base_position"] = "1"; - attrib=""; + indent=[ + "hang_position" : "0", + "base_position" : "1", + ]; // bookindex_section ~= // set_abstract_object.contents_para( // obj, @@ -2713,10 +3001,19 @@ template SiSUdocAbstraction() { // indent, // false // ); - bookindex_section ~= + bookindex_section["scroll"] ~= + set_abstract_object.contents_para( + type, + bi_tmp_scroll, + attrib, + obj_cite_number, + indent, + false + ); + bookindex_section["seg"] ~= set_abstract_object.contents_para( type, - bi_tmp, + bi_tmp_seg, attrib, obj_cite_number, indent, @@ -2730,7 +3027,7 @@ template SiSUdocAbstraction() { } } struct NotesSection { - string object_notes; + string[string] object_notes; long previous_count; int mkn; auto rgx = Rgx(); @@ -2758,15 +3055,22 @@ template SiSUdocAbstraction() { 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_object_belongs_to, ".fn_suffix#noteref_\n ", m.captures[1], " ", m.captures[2]); // sometimes need segment name (segmented html & epub) // writeln("{^{", m.captures[1], ".}^}#", contents_am[counter]["obj_cite_number"], " ", m.captures[2]); } - object_notes ~= (segment_object_belongs_to.empty) + // TODO NEXT you need anchor for segments at this point -> + object_notes["seg"] ~= + "{^{" ~ m.captures[1] ~ ".}^}#noteref_" ~ + m.captures[1] ~ " " ~ m.captures[2] ~ "』"; + object_notes["seg"] ~= (segment_object_belongs_to.empty) ? ("{^{" ~ m.captures[1] ~ ".}^}#noteref_" ~ m.captures[1] ~ " " ~ m.captures[2] ~ "』") - : ("{^{" ~ m.captures[1] ~ ".}^}[../" ~ segment_object_belongs_to ~ ".fn_suffix]#noteref_" ~ + : ("{^{" ~ m.captures[1] ~ ".}^}../" ~ segment_object_belongs_to ~ ".fn_suffix#noteref_" ~ m.captures[1] ~ " " ~ m.captures[2] ~ "』"); + object_notes["scroll"] ~= + "{^{" ~ m.captures[1] ~ ".}^}#noteref_" ~ + m.captures[1] ~ " " ~ m.captures[2] ~ "』"; } return object_notes; } @@ -2774,9 +3078,13 @@ template SiSUdocAbstraction() { in { } body { - string[] endnotes_; + string[][string] endnotes_; if (object_notes.length > 1) { - endnotes_ = (split(object_notes, rgx.break_string))[0..$-1]; + endnotes_["seg"] = (split(object_notes["seg"], rgx.break_string))[0..$-1]; + endnotes_["scroll"] = (split(object_notes["scroll"], rgx.break_string))[0..$-1]; + } else { + endnotes_["seg"] = []; + endnotes_["scroll"] = []; } return endnotes_; } @@ -2785,7 +3093,7 @@ template SiSUdocAbstraction() { } body { auto set_abstract_object = ObjectAbstractSet(); - ObjComposite[] endnotes_section; + ObjComposite[][string] the_endnotes_section; auto endnotes_ = gathered_notes(); // auto endnotes_ = (split(object_notes, rgx.break_string))[0..$-1]; string type; @@ -2797,7 +3105,17 @@ template SiSUdocAbstraction() { lev="B"; lev_markup_number="1"; lev_collapsed_number="1"; - endnotes_section ~= + the_endnotes_section["seg"] ~= + set_abstract_object.contents_heading( + "Endnotes", + attrib, + obj_cite_number, + [], + to!string(lev), + to!int(lev_markup_number), + to!int(lev_collapsed_number) + ); + the_endnotes_section["scroll"] ~= set_abstract_object.contents_heading( "Endnotes", attrib, @@ -2814,7 +3132,17 @@ template SiSUdocAbstraction() { lev="1"; lev_markup_number="4"; lev_collapsed_number="2"; - endnotes_section ~= + the_endnotes_section["seg"] ~= + set_abstract_object.contents_heading( + "Endnotes", + attrib, + obj_cite_number, + ["endnotes"], + to!string(lev), + to!int(lev_markup_number), + to!int(lev_collapsed_number) + ); + the_endnotes_section["scroll"] ~= set_abstract_object.contents_heading( "Endnotes", attrib, @@ -2826,7 +3154,7 @@ template SiSUdocAbstraction() { ); ++obj_cite_number; ++mkn; - foreach (endnote; endnotes_) { + foreach (endnote; endnotes_["seg"]) { attrib=""; // endnotes ~= // set_abstract_object.contents_para( @@ -2835,13 +3163,15 @@ template SiSUdocAbstraction() { // indent, // false // ); - endnotes_section ~= - set_abstract_object.contents_endnote( - endnote, - ); - ++mkn; + the_endnotes_section["seg"] ~= + set_abstract_object.contents_endnote(endnote); + } + foreach (endnote; endnotes_["scroll"]) { + attrib=""; + the_endnotes_section["scroll"] ~= + set_abstract_object.contents_endnote(endnote); } - auto t = tuple(endnotes_section, obj_cite_number); + auto t = tuple(the_endnotes_section, obj_cite_number); return t; } } -- cgit v1.2.3