From 4bf871e555efa9cb3d4c6ebd3b8ed7fb0e5e0cb7 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Fri, 2 Dec 2016 15:06:12 -0500 Subject: start work on node info, a way to go --- org/ao_abstract_doc_source.org | 349 +++++++++++++++++++++++++++------------ org/ao_defaults.org | 49 ++++-- org/sdp.org | 1 + src/sdp.d | 1 + src/sdp/ao_abstract_doc_source.d | 328 +++++++++++++++++++++++++----------- src/sdp/ao_defaults.d | 45 +++-- src/sdp/ao_object_setter.d | 5 +- 7 files changed, 554 insertions(+), 224 deletions(-) diff --git a/org/ao_abstract_doc_source.org b/org/ao_abstract_doc_source.org index cec9f08..63daac5 100644 --- a/org/ao_abstract_doc_source.org +++ b/org/ao_abstract_doc_source.org @@ -97,11 +97,14 @@ int obj_cite_number_emit(int obj_cite_number_status_flag) { string book_idx_tmp; string[][string][string] bookindex_unordered_hashes; auto bookindex_extract_hash = BookIndexNuggetHash(); -string[][string][string] bkidx_hash(string bookindex_section, int obj_cite_number) { +string[][string][string] bkidx_hash( + string bookindex_section, + int obj_cite_number +) { return bookindex_extract_hash.bookindex_nugget_hash(bookindex_section, obj_cite_number); } /+ node +/ -string _node; +string[string][string] _node; auto node_construct = NodeStructureMetadata(); #+END_SRC @@ -128,6 +131,7 @@ scope(exit) { #+name: abs_init_rest #+BEGIN_SRC d +auto node_ = node_metadata; line_occur = [ "heading" : 0, "para" : 0, @@ -135,13 +139,6 @@ line_occur = [ "blurb" : 0, ]; auto type = flags_type_init; -void tell_lo(int obj_cite_number, in char[] line) { - writefln( - "* %s %s", - to!string(obj_cite_number), - to!string(line) - ); -} string[string] obj_cite_number_poem = [ "start" : "", "end" : "" @@ -192,6 +189,11 @@ string _anchor_tag; string toc_txt_; an_object["glossary_nugget"] = ""; an_object["blurb_nugget"] = ""; +node_["object"]["is"] = "heading"; +node_["object"]["obj_cite_number"] = "0"; +node_["object"]["segment_anchor_tag"] = "toc"; +node_["object"]["parent_obj_cite_number"] = "1"; +node_["object"]["parent_lev_markup_number"] = "0"; auto toc_head = set_abstract_object.contents_heading( "Table of Contents", // nugget/object @@ -201,6 +203,7 @@ auto toc_head = "1", // lev 4, // lev_int_markup 2, // lev_int_collapsed + node_, ); the_table_of_contents_section = [ "seg": [toc_head], @@ -322,6 +325,11 @@ if there is a glossary section you need to: line_occur["para"] = State.off; an_object_key="glossary_nugget"; // if (matchFirst(line, rgx.heading_glossary)) { + node_["object"]["is"] = "heading"; + node_["object"]["obj_cite_number"] = "0"; + node_["object"]["segment_anchor_tag"] = "glossary"; + node_["object"]["parent_obj_cite_number"] = "1"; + node_["object"]["parent_lev_markup_number"] = "0"; the_glossary_section ~= set_abstract_object.contents_heading( "Glossary", // nugget/object @@ -331,7 +339,13 @@ if there is a glossary section you need to: "B", // lev 1, // lev_int_markup 1, // lev_int_collapsed + node_, ); + node_["object"]["is"] = "heading"; + node_["object"]["obj_cite_number"] = "0"; + node_["object"]["segment_anchor_tag"] = "glossary"; + node_["object"]["parent_obj_cite_number"] = "1"; + node_["object"]["parent_lev_markup_number"] = "0"; the_glossary_section ~= set_abstract_object.contents_heading( "Glossary", // nugget/object @@ -341,6 +355,7 @@ if there is a glossary section you need to: "1", // lev 4, // lev_int_markup 2, // lev_int_collapsed + node_, ); // } else if (matchFirst(line, rgx.heading)) { // _heading_matched_(line, line_occur, an_object, an_object_key, lv, collapsed_lev, type, dochead_meta_aa); // levels? @@ -396,6 +411,11 @@ if there is a blurb section you need to: line_occur["para"] = State.off; an_object_key="blurb_nugget"; if (matchFirst(line, rgx.heading_blurb)) { + node_["object"]["is"] = "heading"; + node_["object"]["obj_cite_number"] = "0"; + node_["object"]["segment_anchor_tag"] = "blurb"; + node_["object"]["parent_obj_cite_number"] = "1"; + node_["object"]["parent_lev_markup_number"] = "0"; the_blurb_section ~= set_abstract_object.contents_heading( "Blurb", // nugget/object @@ -405,7 +425,13 @@ if there is a blurb section you need to: "B", // lev 1, // lev_int_markup 1, // lev_int_collapsed + node_, ); + node_["object"]["is"] = "heading"; + node_["object"]["obj_cite_number"] = "0"; + node_["object"]["segment_anchor_tag"] = "blurb"; + node_["object"]["parent_obj_cite_number"] = "1"; + node_["object"]["parent_lev_markup_number"] = "0"; the_blurb_section ~= set_abstract_object.contents_heading( "Blurb", // nugget/object @@ -415,10 +441,16 @@ if there is a blurb section you need to: "1", // lev 4, // lev_int_markup 2, // lev_int_collapsed + node_, ); } else if ((matchFirst(line, rgx.heading)) - && (opt_action_bool["backmatter"] && opt_action_bool["section_blurb"])) { + && (opt_action_bool["backmatter"] && opt_action_bool["section_blurb"])) { _heading_matched_(line, line_occur, an_object, an_object_key, lv, collapsed_lev, type, dochead_meta_aa); // levels? + node_["object"]["is"] = "heading"; + node_["object"]["obj_cite_number"] = "0"; + node_["object"]["segment_anchor_tag"] = "blurb"; + node_["object"]["parent_obj_cite_number"] = "1"; + node_["object"]["parent_lev_markup_number"] = "0"; the_blurb_section ~= set_abstract_object.contents_heading( to!string(line), // an_object["substantive"], @@ -428,6 +460,7 @@ if there is a blurb section you need to: to!string(an_object["lev"]), to!int(an_object["lev_markup_number"]), to!int(an_object["lev_collapsed_number"]), + node_, ); } else { _para_match_(line, an_object, an_object_key, indent, bullet, type, line_occur); @@ -755,6 +788,7 @@ if ((type["heading"] == State.on) to!string(an_object["lev"]), to!int(an_object["lev_markup_number"]), to!int(an_object["lev_collapsed_number"]), + _node, ); // track previous heading and make assertions debug(objectrelated1) { // check @@ -876,7 +910,7 @@ debug(objectrelated2) { // check #+END_SRC *** document sections -**** DONE endnotes section (scroll & seg) :endnotes: +**** endnotes section (scroll & seg) :endnotes: #+name: abs_post #+BEGIN_SRC d @@ -897,12 +931,17 @@ debug(endnotes) { } #+END_SRC -**** DONE glossary section? +**** glossary section? #+name: abs_post #+BEGIN_SRC d if (an_object["glossary_nugget"].length == 0) { writeln("no gloss"); + node_["object"]["is"] = "heading"; + node_["object"]["obj_cite_number"] = "0"; + node_["object"]["segment_anchor_tag"] = "glossary"; + node_["object"]["parent_obj_cite_number"] = "1"; + node_["object"]["parent_lev_markup_number"] = "0"; the_glossary_section ~= set_abstract_object.contents_heading( "(skip) there is no Glossary section", // nugget/object @@ -912,6 +951,7 @@ if (an_object["glossary_nugget"].length == 0) { "B", // lev 1, // lev_int_markup 1, // lev_int_collapsed + node_, ); } else { writeln("gloss"); @@ -923,7 +963,7 @@ debug(glossary) { } #+END_SRC -**** DONE [#B] bibliography section (objects) :bibliography: +**** [#B] bibliography section (objects) :bibliography: #+name: abs_post #+BEGIN_SRC d @@ -937,6 +977,11 @@ auto biblio_ordered = #+name: abs_post #+BEGIN_SRC d if (biblio_ordered.length > 0) { + node_["object"]["is"] = "heading"; + node_["object"]["obj_cite_number"] = "0"; + node_["object"]["segment_anchor_tag"] = "bibliography"; + node_["object"]["parent_obj_cite_number"] = "1"; + node_["object"]["parent_lev_markup_number"] = "0"; the_bibliography_section ~= set_abstract_object.contents_heading( "Bibliography", // nugget/object @@ -946,7 +991,13 @@ if (biblio_ordered.length > 0) { "B", // lev 1, // lev_int_markup 1, // lev_int_collapsed + node_, ); + node_["object"]["is"] = "heading"; + node_["object"]["obj_cite_number"] = "0"; + node_["object"]["segment_anchor_tag"] = "bibliography"; + node_["object"]["parent_obj_cite_number"] = "1"; + node_["object"]["parent_lev_markup_number"] = "0"; the_bibliography_section ~= set_abstract_object.contents_heading( "Bibliography", // nugget/object @@ -956,8 +1007,14 @@ if (biblio_ordered.length > 0) { "1", // lev 4, // lev_int_markup 2, // lev_int_collapsed + node_, ); } else { + node_["object"]["is"] = "heading"; + node_["object"]["obj_cite_number"] = "0"; + node_["object"]["segment_anchor_tag"] = "bibliography"; + node_["object"]["parent_obj_cite_number"] = "1"; + node_["object"]["parent_lev_markup_number"] = "0"; the_bibliography_section ~= set_abstract_object.contents_heading( "(skip) there is no Bibliography", // nugget/object @@ -967,6 +1024,7 @@ if (biblio_ordered.length > 0) { "B", // lev 1, // lev_int_markup 1, // lev_int_collapsed + node_, ); } #+END_SRC @@ -1044,7 +1102,7 @@ auto biblio_entry_tags_jsonstr = `{ "id" : "" }`; // is: book, article, magazine, newspaper, blog, other -**** DONE [#B] bookindex section (scroll & seg) :book:index: +**** [#B] bookindex section (scroll & seg) :book:index: #+name: abs_post #+BEGIN_SRC d @@ -1066,12 +1124,17 @@ debug(bookindex) { // bookindex } #+END_SRC -**** DONE blurb section? +**** blurb section? #+name: abs_post #+BEGIN_SRC d if (an_object["blurb_nugget"].length == 0) { writeln("no blurb"); + node_["object"]["is"] = "heading"; + node_["object"]["obj_cite_number"] = "0"; + node_["object"]["segment_anchor_tag"] = "blurb"; + node_["object"]["parent_obj_cite_number"] = "1"; + node_["object"]["parent_lev_markup_number"] = "0"; the_blurb_section ~= set_abstract_object.contents_heading( "(skip) there is no Blurb section", // nugget/object @@ -1081,6 +1144,7 @@ if (an_object["blurb_nugget"].length == 0) { "B", // lev 1, // lev_int_markup 1, // lev_int_collapsed + node_, ); } else { writeln("blurb"); @@ -1092,7 +1156,7 @@ debug(blurb) { } #+END_SRC -**** DONE [#B] toc, table of contents section (scroll & seg) :contents: +**** [#B] toc, table of contents section (scroll & seg) :contents: #+name: abs_post #+BEGIN_SRC d @@ -2202,7 +2266,7 @@ void _block_flag_line_empty_( ref ObjComposite[] the_document_body_section, ref string[][string][string] bookindex_unordered_hashes, ref int obj_cite_number, - ref string _node, + ref string[string][string] _node, ref long cntr, ref int[string] type, string[string] obj_cite_number_poem, @@ -3346,7 +3410,12 @@ private: #+name: ao_emitters_obj_inline_markup_heading_numbering_segment_anchor_tags #+BEGIN_SRC d - static string _configured_auto_heading_numbering_and_segment_anchor_tags(string munge_, string[string] obj_, string[string][string] dochead_make_aa) { + 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) { if (!(match(munge_, rgx.heading_anchor_tag))) { static __gshared uint heading_num_top_level=9; @@ -3561,7 +3630,11 @@ struct ObjAttributes { #+name: ao_emitters_obj_attributes_public #+BEGIN_SRC d - string obj_attributes(string obj_is_, string obj_raw, string _node) + string obj_attributes( + string obj_is_, + string obj_raw, + string[string][string] _node + ) in { } body { scope(exit) { @@ -3813,24 +3886,26 @@ struct ObjAttributes { #+name: ao_emitters_obj_attributes_private_json #+BEGIN_SRC d - string _set_additional_values_parse_as_json(string _obj_attrib, string obj_is_, string _node) { + string _set_additional_values_parse_as_json( + string _obj_attrib, + string obj_is_, + string[string][string] _node + ) { // JSONValue oa_j = parseJSON(_obj_attrib); - JSONValue node_j = parseJSON(_node); assert( - (oa_j.type == JSON_TYPE.OBJECT) && - (node_j.type == JSON_TYPE.OBJECT) + (oa_j.type == JSON_TYPE.OBJECT) ); if (obj_is_ == "heading") { - 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["obj_cite_number"] = _node["object"]["obj_cite_number"]; + oa_j.object["lev_markup_number"] = _node["heading"]["lev_markup_number"]; + oa_j.object["lev_collapsed_number"] = _node["heading"]["lev_collapsed_number"]; oa_j.object["heading_ptr"] = - node_j["heading_ptr"]; // check + _node["object"]["heading_ptr"]; // check oa_j.object["doc_object_ptr"] = - node_j["doc_object_ptr"]; // check + _node["object"]["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"]; + oa_j.object["parent_obj_cite_number"] = _node["object"]["parent_obj_cite_number"]; + oa_j.object["parent_lev_markup_number"] = _node["object"]["parent_lev_markup_number"]; _obj_attrib = oa_j.toString(); return _obj_attrib; } @@ -3855,7 +3930,10 @@ struct BookIndexNuggetHash { string[][string][string] bi; string[][string][string] hash_nugget; string[] bi_main_terms_split_arr; - string[][string][string] bookindex_nugget_hash(string bookindex_section, int obj_cite_number) + string[][string][string] bookindex_nugget_hash( + string bookindex_section, + int obj_cite_number + ) in { debug(bookindexraw) { if (!bookindex_section.empty) { @@ -4005,6 +4083,7 @@ struct BookIndexReportSection { string segment_anchor_tag_that_object_belongs_to, bool[string] opt_action_bool, ) { + mixin SiSUnode; string type; string lev; int lev_int_markup, lev_int_collapsed; @@ -4014,6 +4093,7 @@ struct BookIndexReportSection { auto mainkeys = bookindex_unordered_hashes.byKey.array.sort().release; ObjComposite[][string] bookindex_section; + auto node_ = node_metadata; if ((mainkeys.length > 0) && (opt_action_bool["backmatter"] && opt_action_bool["section_bookindex"])) { string bi_tmp_seg, bi_tmp_scroll; @@ -4021,6 +4101,11 @@ struct BookIndexReportSection { lev="B"; lev_int_markup=1; lev_int_collapsed=1; + node_["object"]["is"] = "heading"; + node_["object"]["obj_cite_number"] = "0"; + node_["object"]["segment_anchor_tag"] = "bookindex"; + node_["object"]["parent_obj_cite_number"] = "1"; + node_["object"]["parent_lev_markup_number"] = "0"; bookindex_section["scroll"] ~= set_abstract_object.contents_heading( "Book Index", @@ -4029,7 +4114,8 @@ struct BookIndexReportSection { [], to!string(lev), lev_int_markup, - lev_int_collapsed + lev_int_collapsed, + node_, ); bookindex_section["seg"] ~= set_abstract_object.contents_heading( @@ -4039,7 +4125,8 @@ struct BookIndexReportSection { [], to!string(lev), lev_int_markup, - lev_int_collapsed + lev_int_collapsed, + node_, ); ++obj_cite_number; ++mkn; @@ -4048,6 +4135,11 @@ struct BookIndexReportSection { lev="1"; lev_int_markup=4; lev_int_collapsed=2; + node_["object"]["is"] = "heading"; + node_["object"]["obj_cite_number"] = "0"; + node_["object"]["segment_anchor_tag"] = "bookindex"; + node_["object"]["parent_obj_cite_number"] = "1"; + node_["object"]["parent_lev_markup_number"] = "0"; bookindex_section["scroll"] ~= set_abstract_object.contents_heading( "Index", @@ -4056,7 +4148,8 @@ struct BookIndexReportSection { ["book_index"], to!string(lev), lev_int_markup, - lev_int_collapsed + lev_int_collapsed, + node_, ); bookindex_section["seg"] ~= set_abstract_object.contents_heading( @@ -4066,7 +4159,8 @@ struct BookIndexReportSection { ["book_index"], to!string(lev), lev_int_markup, - lev_int_collapsed + lev_int_collapsed, + node_, ); ++obj_cite_number; ++mkn; @@ -4129,6 +4223,11 @@ struct BookIndexReportSection { ++mkn; } } else { // no book index, (figure out what to do here) + node_["object"]["is"] = "heading"; + node_["object"]["obj_cite_number"] = "0"; + node_["object"]["segment_anchor_tag"] = "bookindex"; + node_["object"]["parent_obj_cite_number"] = "1"; + node_["object"]["parent_lev_markup_number"] = "0"; bookindex_section["scroll"] ~= set_abstract_object.contents_heading( "(skip) there is no Book Index", @@ -4137,7 +4236,8 @@ struct BookIndexReportSection { [""], "B", 1, - 1 + 1, + node_, ); bookindex_section["seg"] ~= set_abstract_object.contents_heading( @@ -4147,7 +4247,8 @@ struct BookIndexReportSection { [""], "B", 1, - 1 + 1, + node_, ); } auto t = tuple(bookindex_section, obj_cite_number); @@ -4264,6 +4365,7 @@ struct NotesSection { in { } body { + mixin SiSUnode; auto set_abstract_object = ObjectAbstractSet(); ObjComposite[][string] the_endnotes_section; auto endnotes_ = gathered_notes(); @@ -4271,12 +4373,18 @@ struct NotesSection { string lev, lev_markup_number, lev_collapsed_number; string attrib; int[string] indent; + auto node_ = node_metadata; if ((endnotes_["seg"].length > 0) && (opt_action_bool["backmatter"] && opt_action_bool["section_endnotes"])) { attrib=""; lev="B"; lev_markup_number="1"; lev_collapsed_number="1"; + node_["object"]["is"] = "heading"; + node_["object"]["obj_cite_number"] = "0"; + node_["object"]["segment_anchor_tag"] = "endnotes"; + node_["object"]["parent_obj_cite_number"] = "1"; + node_["object"]["parent_lev_markup_number"] = "0"; the_endnotes_section["seg"] ~= set_abstract_object.contents_heading( "Endnotes", @@ -4285,7 +4393,8 @@ struct NotesSection { [], to!string(lev), to!int(lev_markup_number), - to!int(lev_collapsed_number) + to!int(lev_collapsed_number), + node_, ); the_endnotes_section["scroll"] ~= set_abstract_object.contents_heading( @@ -4295,7 +4404,8 @@ struct NotesSection { [], to!string(lev), to!int(lev_markup_number), - to!int(lev_collapsed_number) + to!int(lev_collapsed_number), + node_, ); ++obj_cite_number; ++mkn; @@ -4303,6 +4413,11 @@ struct NotesSection { lev="1"; lev_markup_number="4"; lev_collapsed_number="2"; + node_["object"]["is"] = "heading"; + node_["object"]["obj_cite_number"] = "0"; + node_["object"]["segment_anchor_tag"] = "endnotes"; + node_["object"]["parent_obj_cite_number"] = "1"; + node_["object"]["parent_lev_markup_number"] = "0"; the_endnotes_section["seg"] ~= set_abstract_object.contents_heading( "Endnotes", @@ -4311,7 +4426,8 @@ struct NotesSection { ["endnotes"], to!string(lev), to!int(lev_markup_number), - to!int(lev_collapsed_number) + to!int(lev_collapsed_number), + node_, ); the_endnotes_section["scroll"] ~= set_abstract_object.contents_heading( @@ -4321,11 +4437,17 @@ struct NotesSection { ["endnotes"], to!string(lev), to!int(lev_markup_number), - to!int(lev_collapsed_number) + to!int(lev_collapsed_number), + node_, ); ++obj_cite_number; ++mkn; } else { + node_["object"]["is"] = "heading"; + node_["object"]["obj_cite_number"] = "0"; + node_["object"]["segment_anchor_tag"] = "endnotes"; + node_["object"]["parent_obj_cite_number"] = "1"; + node_["object"]["parent_lev_markup_number"] = "0"; the_endnotes_section["seg"] ~= set_abstract_object.contents_heading( "(skip) there are no Endnotes", @@ -4334,7 +4456,8 @@ struct NotesSection { [""], "B", 1, - 1 + 1, + node_, ); the_endnotes_section["scroll"] ~= set_abstract_object.contents_heading( @@ -4344,7 +4467,8 @@ struct NotesSection { [""], "B", 1, - 1 + 1, + node_, ); } if (opt_action_bool["backmatter"] && opt_action_bool["section_endnotes"]) { @@ -4497,14 +4621,14 @@ struct NodeStructureMetadata { int lv, lv0, lv1, lv2, lv3, lv4, lv5, lv6, lv7; int obj_cite_number; int[string] p_; // p_ parent_ - string _node; + string[string][string] _node; #+END_SRC -**** TODO metadata node emitter +**** TODO node metadata emitter #+name: ao_emitters_metadata #+BEGIN_SRC d - string node_emitter( + string[string][string] node_emitter( string lev_markup_number, string segment_anchor_tag, int obj_cite_number_, @@ -4534,16 +4658,24 @@ struct NodeStructureMetadata { p_["lev_markup_number"] = DocStructMarkupHeading.h_text_1; p_["obj_cite_number"] = lv4; } - _node=("{ " ~ - "\"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"]) ~ - " }" - ); + auto _node = [ + "object" : [ + "is" : is_, + "heading_ptr" : to!string(ptr_), + "doc_object_ptr" : to!string(cntr_), + "obj_cite_number" : to!string(obj_cite_number_), + "segment_anchor_tag" : to!string(segment_anchor_tag), + "parent_obj_cite_number" : to!string(p_["obj_cite_number"]), + "parent_lev_markup_number" : to!string(p_["lev_markup_number"]), + ], + "heading" : [ + "html_segnames_ptr" : "", + "lev_markup_number" : "", + "lev_collapsed_number" : "", + // "ancestors" : "", + // "open_headings_to_close" : "", + ] + ]; debug(node) { if (match(lev_markup_number, rgx.levels_numbered_headings)) { writeln("x ", to!string(_node)); @@ -4551,21 +4683,20 @@ struct NodeStructureMetadata { writeln("- ", to!string(_node)); } } - JSONValue j = parseJSON(_node); - assert(j["parent_lev_markup_number"].integer >= 4); - assert(j["parent_lev_markup_number"].integer <= 7); - assert(j["parent_obj_cite_number"].integer >= 0); + assert(to!int(_node["object"]["parent_lev_markup_number"]) >= 4); + assert(to!int(_node["object"]["parent_lev_markup_number"]) <= 7); + assert(to!int(_node["object"]["parent_obj_cite_number"]) >= 0); // hmm, perhaps return _node; } invariant() { } #+END_SRC -**** TODO metadata emitter heading +**** TODO node metadata emitter heading #+name: ao_emitters_metadata #+BEGIN_SRC d - string node_emitter_heading( + string[string][string] node_emitter_heading( string lev_markup_number, string lev_collapsed_number, string segment_anchor_tag, @@ -4672,20 +4803,25 @@ struct NodeStructureMetadata { default: break; } - _node=("{ " ~ - "\"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) { + auto _node = [ + "object" : [ + "is" : is_, + "heading_ptr" : to!string(ptr_), + "doc_object_ptr" : to!string(cntr_), + "obj_cite_number" : to!string(obj_cite_number_), + "segment_anchor_tag" : to!string(segment_anchor_tag), + "parent_obj_cite_number" : to!string(p_["obj_cite_number"]), + "parent_lev_markup_number" : to!string(p_["lev_markup_number"]), + ], + "heading" : [ + "html_segnames_ptr" : ((lev_markup_number == "4") ? (to!string(html_segnames_ptr)) : ""), + "lev_markup_number" : to!string(lev_markup_number), + "lev_collapsed_number" : to!string(lev_collapsed_number), + // "ancestors" : to!string(ancestors), + // "open_headings_to_close" : to!string(open_headings_to_close), + ] + ]; + debug(node) { if (match(lev_markup_number, rgx.levels_numbered_headings)) { writeln("* ", to!string(_node)); } @@ -4695,35 +4831,34 @@ struct NodeStructureMetadata { writeln("* ", to!string(_node)); } } - JSONValue j = parseJSON(_node); - assert(j["parent_lev_markup_number"].integer <= 7); - assert(j["parent_obj_cite_number"].integer >= 0); + assert(to!int(_node["object"]["parent_lev_markup_number"]) <= 7); + assert(to!int(_node["object"]["parent_obj_cite_number"]) >= 0); if (match(lev_markup_number, rgx.levels_numbered_headings)) { - assert(j["lev_markup_number"].integer <= 7); - assert(j["obj_cite_number"].integer >= 0); - if (j["parent_lev_markup_number"].integer > 0) { - assert(j["parent_lev_markup_number"].integer < j["lev_markup_number"].integer); - if (j["obj_cite_number"].integer != 0) { - assert(j["parent_obj_cite_number"].integer < j["obj_cite_number"].integer); + assert(to!int(_node["heading"]["lev_markup_number"]) <= 7); + assert(to!int(_node["object"]["obj_cite_number"]) >= 0); + if (to!int(_node["object"]["parent_lev_markup_number"]) > 0) { + assert(to!int(_node["object"]["parent_lev_markup_number"]) < to!int(_node["heading"]["lev_markup_number"])); + if (to!int(_node["object"]["obj_cite_number"]) != 0) { + assert(to!int(_node["object"]["parent_obj_cite_number"]) < to!int(_node["object"]["obj_cite_number"])); } } - if (j["lev_markup_number"].integer == 0) { - assert(j["parent_lev_markup_number"].integer == DocStructMarkupHeading.h_sect_A); - } else if (j["lev_markup_number"].integer == DocStructMarkupHeading.h_sect_B) { - assert(j["parent_lev_markup_number"].integer == DocStructMarkupHeading.h_sect_A); - } else if (j["lev_markup_number"].integer == DocStructMarkupHeading.h_sect_C) { - assert(j["parent_lev_markup_number"].integer == DocStructMarkupHeading.h_sect_B); - } else if (j["lev_markup_number"].integer == DocStructMarkupHeading.h_sect_D) { - assert(j["parent_lev_markup_number"].integer == DocStructMarkupHeading.h_sect_C); - } else if (j["lev_markup_number"].integer == DocStructMarkupHeading.h_text_1) { - assert(j["parent_lev_markup_number"].integer <= DocStructMarkupHeading.h_sect_D); - } else if (j["lev_markup_number"].integer == DocStructMarkupHeading.h_text_2) { - assert(j["parent_lev_markup_number"].integer == DocStructMarkupHeading.h_text_1); - } else if (j["lev_markup_number"].integer == DocStructMarkupHeading.h_text_3) { - assert(j["parent_lev_markup_number"].integer == DocStructMarkupHeading.h_text_2); - } else if (j["lev_markup_number"].integer == DocStructMarkupHeading.h_text_4) { - assert(j["parent_lev_markup_number"].integer == DocStructMarkupHeading.h_text_3); - } else if (j["lev_markup_number"].integer == DocStructMarkupHeading.h_text_5) { + if (to!int(_node["heading"]["lev_markup_number"]) == 0) { + assert(to!int(_node["object"]["parent_lev_markup_number"]) == DocStructMarkupHeading.h_sect_A); + } else if (to!int(_node["heading"]["lev_markup_number"]) == DocStructMarkupHeading.h_sect_B) { + assert(to!int(_node["object"]["parent_lev_markup_number"]) == DocStructMarkupHeading.h_sect_A); + } else if (to!int(_node["heading"]["lev_markup_number"]) == DocStructMarkupHeading.h_sect_C) { + assert(to!int(_node["object"]["parent_lev_markup_number"]) == DocStructMarkupHeading.h_sect_B); + } else if (to!int(_node["heading"]["lev_markup_number"]) == DocStructMarkupHeading.h_sect_D) { + assert(to!int(_node["object"]["parent_lev_markup_number"]) == DocStructMarkupHeading.h_sect_C); + } else if (to!int(_node["heading"]["lev_markup_number"]) == DocStructMarkupHeading.h_text_1) { + assert(to!int(_node["object"]["parent_lev_markup_number"]) <= DocStructMarkupHeading.h_sect_D); + } else if (to!int(_node["heading"]["lev_markup_number"]) == DocStructMarkupHeading.h_text_2) { + assert(to!int(_node["object"]["parent_lev_markup_number"]) == DocStructMarkupHeading.h_text_1); + } else if (to!int(_node["heading"]["lev_markup_number"]) == DocStructMarkupHeading.h_text_3) { + assert(to!int(_node["object"]["parent_lev_markup_number"]) == DocStructMarkupHeading.h_text_2); + } else if (to!int(_node["heading"]["lev_markup_number"]) == DocStructMarkupHeading.h_text_4) { + assert(to!int(_node["object"]["parent_lev_markup_number"]) == DocStructMarkupHeading.h_text_3); + } else if (to!int(_node["heading"]["lev_markup_number"]) == DocStructMarkupHeading.h_text_5) { } } return _node; @@ -4744,7 +4879,10 @@ struct NodeStructureMetadata { #+name: abs_functions_assertions #+BEGIN_SRC d -auto assertions_doc_structure(string[string] an_object, int[string] lv) { +auto assertions_doc_structure( + string[string] an_object, + int[string] lv +) { if (lv["h3"] > State.off) { assert(lv["h0"] > State.off); assert(lv["h1"] > State.off); @@ -5016,7 +5154,7 @@ struct Node { // heading segments, 1~ lev4: int heading_array_ptr_segments = 0; // TODO // node info json string: - string node = ""; + string[string][string] node; } #+END_SRC @@ -5074,6 +5212,7 @@ auto contents_heading( in string lev, in int lev_int_markup, in int lev_int_collapsed, + in string[string][string] _node, ) { ObjComposite object_set; object_set.use = "content"; @@ -5216,7 +5355,7 @@ auto contents_block_obj_cite_number_string( in string type, in string object, in string obj_cite_number, - in string _node + in string[string][string] _node ) { ObjComposite object_set; object_set.use = "content"; diff --git a/org/ao_defaults.org b/org/ao_defaults.org index 067fe59..4f9777c 100644 --- a/org/ao_defaults.org +++ b/org/ao_defaults.org @@ -169,7 +169,7 @@ template SiSUregisters() { #+name: ao_defaults_templates #+BEGIN_SRC d - auto pointer_head_main = + auto ptr_head_main = [ "classify", "creator", @@ -182,7 +182,7 @@ template SiSUregisters() { "rights", "title" ]; - auto pointer_head_sub_classify = + auto ptr_head_sub_classify = [ "dewey", "keywords", @@ -190,7 +190,7 @@ template SiSUregisters() { "subject", "topic_register" ]; - auto pointer_head_sub_creator = + auto ptr_head_sub_creator = [ "author", "author_email", @@ -198,7 +198,7 @@ template SiSUregisters() { "illustrator", "translator" ]; - auto pointer_head_sub_date = + auto ptr_head_sub_date = [ "added_to_site", "available", @@ -208,14 +208,14 @@ template SiSUregisters() { "published", "valid" ]; - auto pointer_head_sub_identifier = + auto ptr_head_sub_identifier = [ "isbn", "oclc", "pg" ]; /+ make +/ - auto pointer_head_sub_make = + auto ptr_head_sub_make = [ "cover_image", "home_button_image", @@ -230,27 +230,27 @@ template SiSUregisters() { "texpdf_font", "css" ]; - auto pointer_head_sub_notes = + auto ptr_head_sub_notes = [ "abstract", "description" ]; - auto pointer_head_sub_original = + auto ptr_head_sub_original = [ "language", "source", "title" ]; - auto pointer_head_sub_publisher = + auto ptr_head_sub_publisher = [ "name" ]; - auto pointer_head_sub_rights = + auto ptr_head_sub_rights = [ "copyright", "cover", "illustrations", "license" ]; - auto pointer_head_sub_title = + auto ptr_head_sub_title = [ "edition", "full", @@ -389,6 +389,33 @@ template SiSUrgxInitFlags() { } #+END_SRC +#+name: ao_defaults_templates +#+BEGIN_SRC d +template SiSUnode() { + string[string][string] node_metadata() { + auto node_ = [ + "object" : [ + "is" : "", + "heading_ptr" : "", + "doc_object_ptr" : "", + "obj_cite_number" : "", + "segment_anchor_tag" : "", + "parent_obj_cite_number" : "", + "parent_lev_markup_number" : "", + ], + "heading" : [ + "html_segnames_ptr" : "", + "lev_markup_number" : "", + "lev_collapsed_number" : "", + // "ancestors" : "", + // "open_headings_to_close" : "", + ], + ]; + return node_; + } +} +#+END_SRC + ** template: bibliography :biblio: #+name: ao_defaults_templates diff --git a/org/sdp.org b/org/sdp.org index a8e8724..6a2c0b7 100644 --- a/org/sdp.org +++ b/org/sdp.org @@ -150,6 +150,7 @@ mixin RgxInit; mixin SiSUregisters; mixin SiSUheaderExtractHub; mixin SiSUheaderExtractSDLang; +mixin SiSUnode; mixin SiSUbiblio; mixin SiSUrgxInitFlags; mixin SiSUconfigSDLangHub; diff --git a/src/sdp.d b/src/sdp.d index 8b376e6..a900b55 100755 --- a/src/sdp.d +++ b/src/sdp.d @@ -45,6 +45,7 @@ void main(string[] args) { mixin SiSUregisters; mixin SiSUheaderExtractHub; mixin SiSUheaderExtractSDLang; + mixin SiSUnode; mixin SiSUbiblio; mixin SiSUrgxInitFlags; mixin SiSUconfigSDLangHub; diff --git a/src/sdp/ao_abstract_doc_source.d b/src/sdp/ao_abstract_doc_source.d index 7dbc573..c2cf32b 100644 --- a/src/sdp/ao_abstract_doc_source.d +++ b/src/sdp/ao_abstract_doc_source.d @@ -70,11 +70,14 @@ template SiSUdocAbstraction() { string book_idx_tmp; string[][string][string] bookindex_unordered_hashes; auto bookindex_extract_hash = BookIndexNuggetHash(); - string[][string][string] bkidx_hash(string bookindex_section, int obj_cite_number) { + string[][string][string] bkidx_hash( + string bookindex_section, + int obj_cite_number + ) { return bookindex_extract_hash.bookindex_nugget_hash(bookindex_section, obj_cite_number); } /+ node +/ - string _node; + string[string][string] _node; auto node_construct = NodeStructureMetadata(); /+ ↓ abstract marked up document +/ auto abstract_doc_source( @@ -97,6 +100,7 @@ template SiSUdocAbstraction() { destroy(processing); destroy(biblio_arr_json); } + auto node_ = node_metadata; line_occur = [ "heading" : 0, "para" : 0, @@ -104,13 +108,6 @@ template SiSUdocAbstraction() { "blurb" : 0, ]; auto type = flags_type_init; - void tell_lo(int obj_cite_number, in char[] line) { - writefln( - "* %s %s", - to!string(obj_cite_number), - to!string(line) - ); - } string[string] obj_cite_number_poem = [ "start" : "", "end" : "" @@ -161,6 +158,11 @@ template SiSUdocAbstraction() { string toc_txt_; an_object["glossary_nugget"] = ""; an_object["blurb_nugget"] = ""; + node_["object"]["is"] = "heading"; + node_["object"]["obj_cite_number"] = "0"; + node_["object"]["segment_anchor_tag"] = "toc"; + node_["object"]["parent_obj_cite_number"] = "1"; + node_["object"]["parent_lev_markup_number"] = "0"; auto toc_head = set_abstract_object.contents_heading( "Table of Contents", // nugget/object @@ -170,6 +172,7 @@ template SiSUdocAbstraction() { "1", // lev 4, // lev_int_markup 2, // lev_int_collapsed + node_, ); the_table_of_contents_section = [ "seg": [toc_head], @@ -258,6 +261,11 @@ template SiSUdocAbstraction() { line_occur["para"] = State.off; an_object_key="glossary_nugget"; // if (matchFirst(line, rgx.heading_glossary)) { + node_["object"]["is"] = "heading"; + node_["object"]["obj_cite_number"] = "0"; + node_["object"]["segment_anchor_tag"] = "glossary"; + node_["object"]["parent_obj_cite_number"] = "1"; + node_["object"]["parent_lev_markup_number"] = "0"; the_glossary_section ~= set_abstract_object.contents_heading( "Glossary", // nugget/object @@ -267,7 +275,13 @@ template SiSUdocAbstraction() { "B", // lev 1, // lev_int_markup 1, // lev_int_collapsed + node_, ); + node_["object"]["is"] = "heading"; + node_["object"]["obj_cite_number"] = "0"; + node_["object"]["segment_anchor_tag"] = "glossary"; + node_["object"]["parent_obj_cite_number"] = "1"; + node_["object"]["parent_lev_markup_number"] = "0"; the_glossary_section ~= set_abstract_object.contents_heading( "Glossary", // nugget/object @@ -277,6 +291,7 @@ template SiSUdocAbstraction() { "1", // lev 4, // lev_int_markup 2, // lev_int_collapsed + node_, ); // } else if (matchFirst(line, rgx.heading)) { // _heading_matched_(line, line_occur, an_object, an_object_key, lv, collapsed_lev, type, dochead_meta_aa); // levels? @@ -319,6 +334,11 @@ template SiSUdocAbstraction() { line_occur["para"] = State.off; an_object_key="blurb_nugget"; if (matchFirst(line, rgx.heading_blurb)) { + node_["object"]["is"] = "heading"; + node_["object"]["obj_cite_number"] = "0"; + node_["object"]["segment_anchor_tag"] = "blurb"; + node_["object"]["parent_obj_cite_number"] = "1"; + node_["object"]["parent_lev_markup_number"] = "0"; the_blurb_section ~= set_abstract_object.contents_heading( "Blurb", // nugget/object @@ -328,7 +348,13 @@ template SiSUdocAbstraction() { "B", // lev 1, // lev_int_markup 1, // lev_int_collapsed + node_, ); + node_["object"]["is"] = "heading"; + node_["object"]["obj_cite_number"] = "0"; + node_["object"]["segment_anchor_tag"] = "blurb"; + node_["object"]["parent_obj_cite_number"] = "1"; + node_["object"]["parent_lev_markup_number"] = "0"; the_blurb_section ~= set_abstract_object.contents_heading( "Blurb", // nugget/object @@ -338,10 +364,16 @@ template SiSUdocAbstraction() { "1", // lev 4, // lev_int_markup 2, // lev_int_collapsed + node_, ); } else if ((matchFirst(line, rgx.heading)) - && (opt_action_bool["backmatter"] && opt_action_bool["section_blurb"])) { + && (opt_action_bool["backmatter"] && opt_action_bool["section_blurb"])) { _heading_matched_(line, line_occur, an_object, an_object_key, lv, collapsed_lev, type, dochead_meta_aa); // levels? + node_["object"]["is"] = "heading"; + node_["object"]["obj_cite_number"] = "0"; + node_["object"]["segment_anchor_tag"] = "blurb"; + node_["object"]["parent_obj_cite_number"] = "1"; + node_["object"]["parent_lev_markup_number"] = "0"; the_blurb_section ~= set_abstract_object.contents_heading( to!string(line), // an_object["substantive"], @@ -351,6 +383,7 @@ template SiSUdocAbstraction() { to!string(an_object["lev"]), to!int(an_object["lev_markup_number"]), to!int(an_object["lev_collapsed_number"]), + node_, ); } else { _para_match_(line, an_object, an_object_key, indent, bullet, type, line_occur); @@ -581,6 +614,7 @@ template SiSUdocAbstraction() { to!string(an_object["lev"]), to!int(an_object["lev_markup_number"]), to!int(an_object["lev_collapsed_number"]), + _node, ); // track previous heading and make assertions debug(objectrelated1) { // check @@ -700,6 +734,11 @@ template SiSUdocAbstraction() { } if (an_object["glossary_nugget"].length == 0) { writeln("no gloss"); + node_["object"]["is"] = "heading"; + node_["object"]["obj_cite_number"] = "0"; + node_["object"]["segment_anchor_tag"] = "glossary"; + node_["object"]["parent_obj_cite_number"] = "1"; + node_["object"]["parent_lev_markup_number"] = "0"; the_glossary_section ~= set_abstract_object.contents_heading( "(skip) there is no Glossary section", // nugget/object @@ -709,6 +748,7 @@ template SiSUdocAbstraction() { "B", // lev 1, // lev_int_markup 1, // lev_int_collapsed + node_, ); } else { writeln("gloss"); @@ -724,6 +764,11 @@ template SiSUdocAbstraction() { auto biblio_ordered = biblio._bibliography_(biblio_unsorted_incomplete, bib_arr_json); if (biblio_ordered.length > 0) { + node_["object"]["is"] = "heading"; + node_["object"]["obj_cite_number"] = "0"; + node_["object"]["segment_anchor_tag"] = "bibliography"; + node_["object"]["parent_obj_cite_number"] = "1"; + node_["object"]["parent_lev_markup_number"] = "0"; the_bibliography_section ~= set_abstract_object.contents_heading( "Bibliography", // nugget/object @@ -733,7 +778,13 @@ template SiSUdocAbstraction() { "B", // lev 1, // lev_int_markup 1, // lev_int_collapsed + node_, ); + node_["object"]["is"] = "heading"; + node_["object"]["obj_cite_number"] = "0"; + node_["object"]["segment_anchor_tag"] = "bibliography"; + node_["object"]["parent_obj_cite_number"] = "1"; + node_["object"]["parent_lev_markup_number"] = "0"; the_bibliography_section ~= set_abstract_object.contents_heading( "Bibliography", // nugget/object @@ -743,8 +794,14 @@ template SiSUdocAbstraction() { "1", // lev 4, // lev_int_markup 2, // lev_int_collapsed + node_, ); } else { + node_["object"]["is"] = "heading"; + node_["object"]["obj_cite_number"] = "0"; + node_["object"]["segment_anchor_tag"] = "bibliography"; + node_["object"]["parent_obj_cite_number"] = "1"; + node_["object"]["parent_lev_markup_number"] = "0"; the_bibliography_section ~= set_abstract_object.contents_heading( "(skip) there is no Bibliography", // nugget/object @@ -754,6 +811,7 @@ template SiSUdocAbstraction() { "B", // lev 1, // lev_int_markup 1, // lev_int_collapsed + node_, ); } string out_; @@ -805,6 +863,11 @@ template SiSUdocAbstraction() { } if (an_object["blurb_nugget"].length == 0) { writeln("no blurb"); + node_["object"]["is"] = "heading"; + node_["object"]["obj_cite_number"] = "0"; + node_["object"]["segment_anchor_tag"] = "blurb"; + node_["object"]["parent_obj_cite_number"] = "1"; + node_["object"]["parent_lev_markup_number"] = "0"; the_blurb_section ~= set_abstract_object.contents_heading( "(skip) there is no Blurb section", // nugget/object @@ -814,6 +877,7 @@ template SiSUdocAbstraction() { "B", // lev 1, // lev_int_markup 1, // lev_int_collapsed + node_, ); } else { writeln("blurb"); @@ -1747,7 +1811,7 @@ template SiSUdocAbstraction() { ref ObjComposite[] the_document_body_section, ref string[][string][string] bookindex_unordered_hashes, ref int obj_cite_number, - ref string _node, + ref string[string][string] _node, ref long cntr, ref int[string] type, string[string] obj_cite_number_poem, @@ -2817,7 +2881,12 @@ template SiSUdocAbstraction() { invariant() { } private: - static string _configured_auto_heading_numbering_and_segment_anchor_tags(string munge_, string[string] obj_, string[string][string] dochead_make_aa) { + 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) { if (!(match(munge_, rgx.heading_anchor_tag))) { static __gshared uint heading_num_top_level=9; @@ -2996,7 +3065,11 @@ template SiSUdocAbstraction() { } struct ObjAttributes { string[string] _obj_attrib; - string obj_attributes(string obj_is_, string obj_raw, string _node) + string obj_attributes( + string obj_is_, + string obj_raw, + string[string][string] _node + ) in { } body { scope(exit) { @@ -3175,24 +3248,26 @@ template SiSUdocAbstraction() { } invariant() { } - string _set_additional_values_parse_as_json(string _obj_attrib, string obj_is_, string _node) { + string _set_additional_values_parse_as_json( + string _obj_attrib, + string obj_is_, + string[string][string] _node + ) { // JSONValue oa_j = parseJSON(_obj_attrib); - JSONValue node_j = parseJSON(_node); assert( - (oa_j.type == JSON_TYPE.OBJECT) && - (node_j.type == JSON_TYPE.OBJECT) + (oa_j.type == JSON_TYPE.OBJECT) ); if (obj_is_ == "heading") { - 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["obj_cite_number"] = _node["object"]["obj_cite_number"]; + oa_j.object["lev_markup_number"] = _node["heading"]["lev_markup_number"]; + oa_j.object["lev_collapsed_number"] = _node["heading"]["lev_collapsed_number"]; oa_j.object["heading_ptr"] = - node_j["heading_ptr"]; // check + _node["object"]["heading_ptr"]; // check oa_j.object["doc_object_ptr"] = - node_j["doc_object_ptr"]; // check + _node["object"]["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"]; + oa_j.object["parent_obj_cite_number"] = _node["object"]["parent_obj_cite_number"]; + oa_j.object["parent_lev_markup_number"] = _node["object"]["parent_lev_markup_number"]; _obj_attrib = oa_j.toString(); return _obj_attrib; } @@ -3204,7 +3279,10 @@ template SiSUdocAbstraction() { string[][string][string] bi; string[][string][string] hash_nugget; string[] bi_main_terms_split_arr; - string[][string][string] bookindex_nugget_hash(string bookindex_section, int obj_cite_number) + string[][string][string] bookindex_nugget_hash( + string bookindex_section, + int obj_cite_number + ) in { debug(bookindexraw) { if (!bookindex_section.empty) { @@ -3329,6 +3407,7 @@ template SiSUdocAbstraction() { string segment_anchor_tag_that_object_belongs_to, bool[string] opt_action_bool, ) { + mixin SiSUnode; string type; string lev; int lev_int_markup, lev_int_collapsed; @@ -3338,6 +3417,7 @@ template SiSUdocAbstraction() { auto mainkeys = bookindex_unordered_hashes.byKey.array.sort().release; ObjComposite[][string] bookindex_section; + auto node_ = node_metadata; if ((mainkeys.length > 0) && (opt_action_bool["backmatter"] && opt_action_bool["section_bookindex"])) { string bi_tmp_seg, bi_tmp_scroll; @@ -3345,6 +3425,11 @@ template SiSUdocAbstraction() { lev="B"; lev_int_markup=1; lev_int_collapsed=1; + node_["object"]["is"] = "heading"; + node_["object"]["obj_cite_number"] = "0"; + node_["object"]["segment_anchor_tag"] = "bookindex"; + node_["object"]["parent_obj_cite_number"] = "1"; + node_["object"]["parent_lev_markup_number"] = "0"; bookindex_section["scroll"] ~= set_abstract_object.contents_heading( "Book Index", @@ -3353,7 +3438,8 @@ template SiSUdocAbstraction() { [], to!string(lev), lev_int_markup, - lev_int_collapsed + lev_int_collapsed, + node_, ); bookindex_section["seg"] ~= set_abstract_object.contents_heading( @@ -3363,7 +3449,8 @@ template SiSUdocAbstraction() { [], to!string(lev), lev_int_markup, - lev_int_collapsed + lev_int_collapsed, + node_, ); ++obj_cite_number; ++mkn; @@ -3372,6 +3459,11 @@ template SiSUdocAbstraction() { lev="1"; lev_int_markup=4; lev_int_collapsed=2; + node_["object"]["is"] = "heading"; + node_["object"]["obj_cite_number"] = "0"; + node_["object"]["segment_anchor_tag"] = "bookindex"; + node_["object"]["parent_obj_cite_number"] = "1"; + node_["object"]["parent_lev_markup_number"] = "0"; bookindex_section["scroll"] ~= set_abstract_object.contents_heading( "Index", @@ -3380,7 +3472,8 @@ template SiSUdocAbstraction() { ["book_index"], to!string(lev), lev_int_markup, - lev_int_collapsed + lev_int_collapsed, + node_, ); bookindex_section["seg"] ~= set_abstract_object.contents_heading( @@ -3390,7 +3483,8 @@ template SiSUdocAbstraction() { ["book_index"], to!string(lev), lev_int_markup, - lev_int_collapsed + lev_int_collapsed, + node_, ); ++obj_cite_number; ++mkn; @@ -3453,6 +3547,11 @@ template SiSUdocAbstraction() { ++mkn; } } else { // no book index, (figure out what to do here) + node_["object"]["is"] = "heading"; + node_["object"]["obj_cite_number"] = "0"; + node_["object"]["segment_anchor_tag"] = "bookindex"; + node_["object"]["parent_obj_cite_number"] = "1"; + node_["object"]["parent_lev_markup_number"] = "0"; bookindex_section["scroll"] ~= set_abstract_object.contents_heading( "(skip) there is no Book Index", @@ -3461,7 +3560,8 @@ template SiSUdocAbstraction() { [""], "B", 1, - 1 + 1, + node_, ); bookindex_section["seg"] ~= set_abstract_object.contents_heading( @@ -3471,7 +3571,8 @@ template SiSUdocAbstraction() { [""], "B", 1, - 1 + 1, + node_, ); } auto t = tuple(bookindex_section, obj_cite_number); @@ -3558,6 +3659,7 @@ template SiSUdocAbstraction() { in { } body { + mixin SiSUnode; auto set_abstract_object = ObjectAbstractSet(); ObjComposite[][string] the_endnotes_section; auto endnotes_ = gathered_notes(); @@ -3565,12 +3667,18 @@ template SiSUdocAbstraction() { string lev, lev_markup_number, lev_collapsed_number; string attrib; int[string] indent; + auto node_ = node_metadata; if ((endnotes_["seg"].length > 0) && (opt_action_bool["backmatter"] && opt_action_bool["section_endnotes"])) { attrib=""; lev="B"; lev_markup_number="1"; lev_collapsed_number="1"; + node_["object"]["is"] = "heading"; + node_["object"]["obj_cite_number"] = "0"; + node_["object"]["segment_anchor_tag"] = "endnotes"; + node_["object"]["parent_obj_cite_number"] = "1"; + node_["object"]["parent_lev_markup_number"] = "0"; the_endnotes_section["seg"] ~= set_abstract_object.contents_heading( "Endnotes", @@ -3579,7 +3687,8 @@ template SiSUdocAbstraction() { [], to!string(lev), to!int(lev_markup_number), - to!int(lev_collapsed_number) + to!int(lev_collapsed_number), + node_, ); the_endnotes_section["scroll"] ~= set_abstract_object.contents_heading( @@ -3589,7 +3698,8 @@ template SiSUdocAbstraction() { [], to!string(lev), to!int(lev_markup_number), - to!int(lev_collapsed_number) + to!int(lev_collapsed_number), + node_, ); ++obj_cite_number; ++mkn; @@ -3597,6 +3707,11 @@ template SiSUdocAbstraction() { lev="1"; lev_markup_number="4"; lev_collapsed_number="2"; + node_["object"]["is"] = "heading"; + node_["object"]["obj_cite_number"] = "0"; + node_["object"]["segment_anchor_tag"] = "endnotes"; + node_["object"]["parent_obj_cite_number"] = "1"; + node_["object"]["parent_lev_markup_number"] = "0"; the_endnotes_section["seg"] ~= set_abstract_object.contents_heading( "Endnotes", @@ -3605,7 +3720,8 @@ template SiSUdocAbstraction() { ["endnotes"], to!string(lev), to!int(lev_markup_number), - to!int(lev_collapsed_number) + to!int(lev_collapsed_number), + node_, ); the_endnotes_section["scroll"] ~= set_abstract_object.contents_heading( @@ -3615,11 +3731,17 @@ template SiSUdocAbstraction() { ["endnotes"], to!string(lev), to!int(lev_markup_number), - to!int(lev_collapsed_number) + to!int(lev_collapsed_number), + node_, ); ++obj_cite_number; ++mkn; } else { + node_["object"]["is"] = "heading"; + node_["object"]["obj_cite_number"] = "0"; + node_["object"]["segment_anchor_tag"] = "endnotes"; + node_["object"]["parent_obj_cite_number"] = "1"; + node_["object"]["parent_lev_markup_number"] = "0"; the_endnotes_section["seg"] ~= set_abstract_object.contents_heading( "(skip) there are no Endnotes", @@ -3628,7 +3750,8 @@ template SiSUdocAbstraction() { [""], "B", 1, - 1 + 1, + node_, ); the_endnotes_section["scroll"] ~= set_abstract_object.contents_heading( @@ -3638,7 +3761,8 @@ template SiSUdocAbstraction() { [""], "B", 1, - 1 + 1, + node_, ); } if (opt_action_bool["backmatter"] && opt_action_bool["section_endnotes"]) { @@ -3741,8 +3865,8 @@ template SiSUdocAbstraction() { int lv, lv0, lv1, lv2, lv3, lv4, lv5, lv6, lv7; int obj_cite_number; int[string] p_; // p_ parent_ - string _node; - string node_emitter( + string[string][string] _node; + string[string][string] node_emitter( string lev_markup_number, string segment_anchor_tag, int obj_cite_number_, @@ -3772,16 +3896,24 @@ template SiSUdocAbstraction() { p_["lev_markup_number"] = DocStructMarkupHeading.h_text_1; p_["obj_cite_number"] = lv4; } - _node=("{ " ~ - "\"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"]) ~ - " }" - ); + auto _node = [ + "object" : [ + "is" : is_, + "heading_ptr" : to!string(ptr_), + "doc_object_ptr" : to!string(cntr_), + "obj_cite_number" : to!string(obj_cite_number_), + "segment_anchor_tag" : to!string(segment_anchor_tag), + "parent_obj_cite_number" : to!string(p_["obj_cite_number"]), + "parent_lev_markup_number" : to!string(p_["lev_markup_number"]), + ], + "heading" : [ + "html_segnames_ptr" : "", + "lev_markup_number" : "", + "lev_collapsed_number" : "", + // "ancestors" : "", + // "open_headings_to_close" : "", + ] + ]; debug(node) { if (match(lev_markup_number, rgx.levels_numbered_headings)) { writeln("x ", to!string(_node)); @@ -3789,15 +3921,14 @@ template SiSUdocAbstraction() { writeln("- ", to!string(_node)); } } - JSONValue j = parseJSON(_node); - assert(j["parent_lev_markup_number"].integer >= 4); - assert(j["parent_lev_markup_number"].integer <= 7); - assert(j["parent_obj_cite_number"].integer >= 0); + assert(to!int(_node["object"]["parent_lev_markup_number"]) >= 4); + assert(to!int(_node["object"]["parent_lev_markup_number"]) <= 7); + assert(to!int(_node["object"]["parent_obj_cite_number"]) >= 0); // hmm, perhaps return _node; } invariant() { } - string node_emitter_heading( + string[string][string] node_emitter_heading( string lev_markup_number, string lev_collapsed_number, string segment_anchor_tag, @@ -3904,20 +4035,25 @@ template SiSUdocAbstraction() { default: break; } - _node=("{ " ~ - "\"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) { + auto _node = [ + "object" : [ + "is" : is_, + "heading_ptr" : to!string(ptr_), + "doc_object_ptr" : to!string(cntr_), + "obj_cite_number" : to!string(obj_cite_number_), + "segment_anchor_tag" : to!string(segment_anchor_tag), + "parent_obj_cite_number" : to!string(p_["obj_cite_number"]), + "parent_lev_markup_number" : to!string(p_["lev_markup_number"]), + ], + "heading" : [ + "html_segnames_ptr" : ((lev_markup_number == "4") ? (to!string(html_segnames_ptr)) : ""), + "lev_markup_number" : to!string(lev_markup_number), + "lev_collapsed_number" : to!string(lev_collapsed_number), + // "ancestors" : to!string(ancestors), + // "open_headings_to_close" : to!string(open_headings_to_close), + ] + ]; + debug(node) { if (match(lev_markup_number, rgx.levels_numbered_headings)) { writeln("* ", to!string(_node)); } @@ -3927,35 +4063,34 @@ template SiSUdocAbstraction() { writeln("* ", to!string(_node)); } } - JSONValue j = parseJSON(_node); - assert(j["parent_lev_markup_number"].integer <= 7); - assert(j["parent_obj_cite_number"].integer >= 0); + assert(to!int(_node["object"]["parent_lev_markup_number"]) <= 7); + assert(to!int(_node["object"]["parent_obj_cite_number"]) >= 0); if (match(lev_markup_number, rgx.levels_numbered_headings)) { - assert(j["lev_markup_number"].integer <= 7); - assert(j["obj_cite_number"].integer >= 0); - if (j["parent_lev_markup_number"].integer > 0) { - assert(j["parent_lev_markup_number"].integer < j["lev_markup_number"].integer); - if (j["obj_cite_number"].integer != 0) { - assert(j["parent_obj_cite_number"].integer < j["obj_cite_number"].integer); + assert(to!int(_node["heading"]["lev_markup_number"]) <= 7); + assert(to!int(_node["object"]["obj_cite_number"]) >= 0); + if (to!int(_node["object"]["parent_lev_markup_number"]) > 0) { + assert(to!int(_node["object"]["parent_lev_markup_number"]) < to!int(_node["heading"]["lev_markup_number"])); + if (to!int(_node["object"]["obj_cite_number"]) != 0) { + assert(to!int(_node["object"]["parent_obj_cite_number"]) < to!int(_node["object"]["obj_cite_number"])); } } - if (j["lev_markup_number"].integer == 0) { - assert(j["parent_lev_markup_number"].integer == DocStructMarkupHeading.h_sect_A); - } else if (j["lev_markup_number"].integer == DocStructMarkupHeading.h_sect_B) { - assert(j["parent_lev_markup_number"].integer == DocStructMarkupHeading.h_sect_A); - } else if (j["lev_markup_number"].integer == DocStructMarkupHeading.h_sect_C) { - assert(j["parent_lev_markup_number"].integer == DocStructMarkupHeading.h_sect_B); - } else if (j["lev_markup_number"].integer == DocStructMarkupHeading.h_sect_D) { - assert(j["parent_lev_markup_number"].integer == DocStructMarkupHeading.h_sect_C); - } else if (j["lev_markup_number"].integer == DocStructMarkupHeading.h_text_1) { - assert(j["parent_lev_markup_number"].integer <= DocStructMarkupHeading.h_sect_D); - } else if (j["lev_markup_number"].integer == DocStructMarkupHeading.h_text_2) { - assert(j["parent_lev_markup_number"].integer == DocStructMarkupHeading.h_text_1); - } else if (j["lev_markup_number"].integer == DocStructMarkupHeading.h_text_3) { - assert(j["parent_lev_markup_number"].integer == DocStructMarkupHeading.h_text_2); - } else if (j["lev_markup_number"].integer == DocStructMarkupHeading.h_text_4) { - assert(j["parent_lev_markup_number"].integer == DocStructMarkupHeading.h_text_3); - } else if (j["lev_markup_number"].integer == DocStructMarkupHeading.h_text_5) { + if (to!int(_node["heading"]["lev_markup_number"]) == 0) { + assert(to!int(_node["object"]["parent_lev_markup_number"]) == DocStructMarkupHeading.h_sect_A); + } else if (to!int(_node["heading"]["lev_markup_number"]) == DocStructMarkupHeading.h_sect_B) { + assert(to!int(_node["object"]["parent_lev_markup_number"]) == DocStructMarkupHeading.h_sect_A); + } else if (to!int(_node["heading"]["lev_markup_number"]) == DocStructMarkupHeading.h_sect_C) { + assert(to!int(_node["object"]["parent_lev_markup_number"]) == DocStructMarkupHeading.h_sect_B); + } else if (to!int(_node["heading"]["lev_markup_number"]) == DocStructMarkupHeading.h_sect_D) { + assert(to!int(_node["object"]["parent_lev_markup_number"]) == DocStructMarkupHeading.h_sect_C); + } else if (to!int(_node["heading"]["lev_markup_number"]) == DocStructMarkupHeading.h_text_1) { + assert(to!int(_node["object"]["parent_lev_markup_number"]) <= DocStructMarkupHeading.h_sect_D); + } else if (to!int(_node["heading"]["lev_markup_number"]) == DocStructMarkupHeading.h_text_2) { + assert(to!int(_node["object"]["parent_lev_markup_number"]) == DocStructMarkupHeading.h_text_1); + } else if (to!int(_node["heading"]["lev_markup_number"]) == DocStructMarkupHeading.h_text_3) { + assert(to!int(_node["object"]["parent_lev_markup_number"]) == DocStructMarkupHeading.h_text_2); + } else if (to!int(_node["heading"]["lev_markup_number"]) == DocStructMarkupHeading.h_text_4) { + assert(to!int(_node["object"]["parent_lev_markup_number"]) == DocStructMarkupHeading.h_text_3); + } else if (to!int(_node["heading"]["lev_markup_number"]) == DocStructMarkupHeading.h_text_5) { } } return _node; @@ -3965,7 +4100,10 @@ template SiSUdocAbstraction() { } /+ abstraction functions emitters ↑ +/ /+ ↓ abstraction functions assertions +/ - auto assertions_doc_structure(string[string] an_object, int[string] lv) { + auto assertions_doc_structure( + string[string] an_object, + int[string] lv + ) { if (lv["h3"] > State.off) { assert(lv["h0"] > State.off); assert(lv["h1"] > State.off); diff --git a/src/sdp/ao_defaults.d b/src/sdp/ao_defaults.d index 9a84e80..4408cc8 100644 --- a/src/sdp/ao_defaults.d +++ b/src/sdp/ao_defaults.d @@ -144,7 +144,7 @@ template SiSUregisters() { ]; return meta_; } - auto pointer_head_main = + auto ptr_head_main = [ "classify", "creator", @@ -157,7 +157,7 @@ template SiSUregisters() { "rights", "title" ]; - auto pointer_head_sub_classify = + auto ptr_head_sub_classify = [ "dewey", "keywords", @@ -165,7 +165,7 @@ template SiSUregisters() { "subject", "topic_register" ]; - auto pointer_head_sub_creator = + auto ptr_head_sub_creator = [ "author", "author_email", @@ -173,7 +173,7 @@ template SiSUregisters() { "illustrator", "translator" ]; - auto pointer_head_sub_date = + auto ptr_head_sub_date = [ "added_to_site", "available", @@ -183,14 +183,14 @@ template SiSUregisters() { "published", "valid" ]; - auto pointer_head_sub_identifier = + auto ptr_head_sub_identifier = [ "isbn", "oclc", "pg" ]; /+ make +/ - auto pointer_head_sub_make = + auto ptr_head_sub_make = [ "cover_image", "home_button_image", @@ -205,27 +205,27 @@ template SiSUregisters() { "texpdf_font", "css" ]; - auto pointer_head_sub_notes = + auto ptr_head_sub_notes = [ "abstract", "description" ]; - auto pointer_head_sub_original = + auto ptr_head_sub_original = [ "language", "source", "title" ]; - auto pointer_head_sub_publisher = + auto ptr_head_sub_publisher = [ "name" ]; - auto pointer_head_sub_rights = + auto ptr_head_sub_rights = [ "copyright", "cover", "illustrations", "license" ]; - auto pointer_head_sub_title = + auto ptr_head_sub_title = [ "edition", "full", @@ -350,6 +350,29 @@ template SiSUrgxInitFlags() { return flags_type_init; } } +template SiSUnode() { + string[string][string] node_metadata() { + auto node_ = [ + "object" : [ + "is" : "", + "heading_ptr" : "", + "doc_object_ptr" : "", + "obj_cite_number" : "", + "segment_anchor_tag" : "", + "parent_obj_cite_number" : "", + "parent_lev_markup_number" : "", + ], + "heading" : [ + "html_segnames_ptr" : "", + "lev_markup_number" : "", + "lev_collapsed_number" : "", + // "ancestors" : "", + // "open_headings_to_close" : "", + ], + ]; + return node_; + } +} template SiSUbiblio() { // required: deemed_author (author || editor); year; fulltitle; auto biblio_entry_tags_jsonstr = `{ diff --git a/src/sdp/ao_object_setter.d b/src/sdp/ao_object_setter.d index 35ca768..c293eb0 100644 --- a/src/sdp/ao_object_setter.d +++ b/src/sdp/ao_object_setter.d @@ -42,7 +42,7 @@ template ObjectSetter() { // heading segments, 1~ lev4: int heading_array_ptr_segments = 0; // TODO // node info json string: - string node = ""; + string[string][string] node; } struct ObjComposite { string use = ""; @@ -78,6 +78,7 @@ template ObjectSetter() { in string lev, in int lev_int_markup, in int lev_int_collapsed, + in string[string][string] _node, ) { ObjComposite object_set; object_set.use = "content"; @@ -184,7 +185,7 @@ template ObjectSetter() { in string type, in string object, in string obj_cite_number, - in string _node + in string[string][string] _node ) { ObjComposite object_set; object_set.use = "content"; -- cgit v1.2.3