From c9c1b3501569d83f9c1e9f7ca153230cd117b8a9 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Mon, 25 Jun 2018 12:50:54 -0400 Subject: obj.metainfo node type info, ancestors --- org/meta_abstraction.org | 589 +++++++++++++++++++++++++++++----------- org/meta_debugs.org | 4 +- org/output_sqlite.org | 4 +- org/output_xmls.org | 4 +- src/sdp/meta/doc_debugs.d | 4 +- src/sdp/meta/metadoc_from_src.d | 473 ++++++++++++++++++++++++-------- src/sdp/meta/object_setter.d | 72 ++--- src/sdp/output/epub3.d | 4 +- src/sdp/output/sqlite.d | 4 +- 9 files changed, 830 insertions(+), 328 deletions(-) diff --git a/org/meta_abstraction.org b/org/meta_abstraction.org index 0153020..feaf5ea 100644 --- a/org/meta_abstraction.org +++ b/org/meta_abstraction.org @@ -85,6 +85,7 @@ template SiSUdocAbstraction() { } /+ ← closed: loop markup document/text line by line +/ /+ ↓ post loop markup document/text +/ <> + <> <> /+ post loop markup document/text ↑ +/ } /+ ← closed: abstract doc source +/ @@ -232,14 +233,14 @@ struct OCNset { OCNset obj_cite_digits; int obj_cite_digit_, obj_cite_digit_off, obj_cite_digit_bkidx, obj_cite_digit_type; auto object_citation_number = OCNemitter(); -int[] dom_markedup = [ 0, 0, 0, 0, 0, 0, 0, 0, 0,]; -int[] dom_markedup_buffer = [ 0, 0, 0, 0, 0, 0, 0, 0, 0,]; -int[] dom_collapsed = [ 0, 0, 0, 0, 0, 0, 0, 0, 0,]; -int[] dom_collapsed_buffer = [ 0, 0, 0, 0, 0, 0, 0, 0, 0,]; +int[] dom_structure_markedup_tags_status = [ 0, 0, 0, 0, 0, 0, 0, 0, 0,]; +int[] dom_structure_markedup_tags_status_buffer = [ 0, 0, 0, 0, 0, 0, 0, 0, 0,]; +int[] dom_structure_collapsed_tags_status = [ 0, 0, 0, 0, 0, 0, 0, 0, 0,]; +int[] dom_structure_collapsed_tags_status_buffer = [ 0, 0, 0, 0, 0, 0, 0, 0, 0,]; enum DomTags { none, open, close, close_and_open, open_still, } #+END_SRC -**** initialize heading ancestors +**** method heading ancestors #+name: abs_top_init_struct #+BEGIN_SRC d @@ -298,7 +299,7 @@ pure auto obj_heading_ancestors(O)( } #+END_SRC -**** initialize dom markup tags +**** method dom markup tags #+name: abs_top_init_struct #+BEGIN_SRC d @@ -343,12 +344,12 @@ pure auto obj_dom_structure_set_markup_tags(O)( debug(dom_magic_numbers) { writeln("marked up: ", lev, ": ", dom); } - obj.metainfo.dom_markedup = dom.dup; + obj.metainfo.dom_structure_markedup_tags_status = dom.dup; return obj; } #+END_SRC -**** initialize dom collapsed tags +**** method dom collapsed tags #+name: abs_top_init_struct #+BEGIN_SRC d @@ -393,12 +394,12 @@ pure auto obj_dom_set_collapsed_tags(O)( debug(dom_magic_numbers) { writeln("collapsed: ", lev, ": ", dom); } - obj.metainfo.dom_collapsed = dom.dup; + obj.metainfo.dom_structure_collapsed_tags_status = dom.dup; return obj; } #+END_SRC -**** initialize ocn emit +**** method ocn emit #+name: abs_top_init_struct #+BEGIN_SRC d @@ -500,27 +501,27 @@ auto heading_match_rgx = [ ]; string _anchor_tag; string toc_txt_; -an_object["glossary_nugget"] = ""; -an_object["blurb_nugget"] = ""; -comp_obj_heading_ = comp_obj_heading_.init; -comp_obj_heading_.metainfo.is_of_part = "frontmatter"; -comp_obj_heading_.metainfo.is_of_section = "toc"; -comp_obj_heading_.metainfo.is_of_type = "para"; -comp_obj_heading_.metainfo.is_a = "heading"; -comp_obj_heading_.text = "Table of Contents"; -comp_obj_heading_.metainfo.ocn = 0; -comp_obj_heading_.metainfo.object_number_off = ""; -comp_obj_heading_.metainfo.object_number_type = 0; -comp_obj_heading_.tags.segment_anchor_tag = "toc"; -comp_obj_heading_.metainfo.heading_lev_markup = 4; -comp_obj_heading_.metainfo.heading_lev_collapsed = 1; -comp_obj_heading_.metainfo.parent_ocn = 1; -comp_obj_heading_.metainfo.parent_lev_markup = 0; -comp_obj_heading_.ptr.html_segnames = html_segnames_ptr; -comp_obj_heading_.tags.anchor_tags = ["toc"]; -comp_obj_heading_.metainfo.dom_markedup = [ 1, 1, 0, 0, 1, 0, 0, 0]; -comp_obj_heading_.metainfo.dom_collapsed = [ 1, 1, 1, 0, 0, 0, 0, 0]; -auto toc_head = comp_obj_heading_; +an_object["glossary_nugget"] = ""; +an_object["blurb_nugget"] = ""; +comp_obj_heading_ = comp_obj_heading_.init; +comp_obj_heading_.metainfo.is_of_part = "frontmatter"; +comp_obj_heading_.metainfo.is_of_section = "toc"; +comp_obj_heading_.metainfo.is_of_type = "para"; +comp_obj_heading_.metainfo.is_a = "heading"; +comp_obj_heading_.text = "Table of Contents"; +comp_obj_heading_.metainfo.ocn = 0; +comp_obj_heading_.metainfo.object_number_off = ""; +comp_obj_heading_.metainfo.object_number_type = 0; +comp_obj_heading_.tags.segment_anchor_tag = "toc"; +comp_obj_heading_.metainfo.heading_lev_markup = 4; +comp_obj_heading_.metainfo.heading_lev_collapsed = 1; +comp_obj_heading_.metainfo.parent_ocn = 1; +comp_obj_heading_.metainfo.parent_lev_markup = 0; +comp_obj_heading_.ptr.html_segnames = html_segnames_ptr; +comp_obj_heading_.tags.anchor_tags = ["toc"]; +comp_obj_heading_.metainfo.dom_structure_markedup_tags_status = [ 1, 1, 0, 0, 1, 0, 0, 0]; +comp_obj_heading_.metainfo.dom_structure_collapsed_tags_status = [ 1, 1, 1, 0, 0, 0, 0, 0]; +auto toc_head = comp_obj_heading_; html_segnames_ptr_cntr++; the_table_of_contents_section = [ "seg": [toc_head], @@ -691,8 +692,8 @@ if there is a glossary section you need to: comp_obj_heading_.metainfo.heading_lev_collapsed = 1; comp_obj_heading_.metainfo.parent_ocn = 1; comp_obj_heading_.metainfo.parent_lev_markup = 0; - comp_obj_heading_.metainfo.dom_markedup = [ 1, 1, 0, 0, 0, 0, 0, 0]; - comp_obj_heading_.metainfo.dom_collapsed = [ 1, 1, 0, 0, 0, 0, 0, 0]; + comp_obj_heading_.metainfo.dom_structure_markedup_tags_status = [ 1, 1, 0, 0, 0, 0, 0, 0]; + comp_obj_heading_.metainfo.dom_structure_collapsed_tags_status = [ 1, 1, 0, 0, 0, 0, 0, 0]; the_glossary_section ~= comp_obj_heading_; comp_obj_heading_ = comp_obj_heading_.init; comp_obj_heading_.metainfo.is_of_part = "backmatter"; @@ -708,8 +709,8 @@ if there is a glossary section you need to: comp_obj_heading_.metainfo.heading_lev_collapsed = 2; comp_obj_heading_.metainfo.parent_ocn = 1; comp_obj_heading_.metainfo.parent_lev_markup = 0; - comp_obj_heading_.metainfo.dom_markedup = [ 1, 1, 0, 0, 1, 0, 0, 0]; - comp_obj_heading_.metainfo.dom_collapsed = [ 1, 1, 1, 0, 0, 0, 0, 0]; + comp_obj_heading_.metainfo.dom_structure_markedup_tags_status = [ 1, 1, 0, 0, 1, 0, 0, 0]; + comp_obj_heading_.metainfo.dom_structure_collapsed_tags_status = [ 1, 1, 1, 0, 0, 0, 0, 0]; comp_obj_heading_.tags.anchor_tags = ["glossary"]; the_glossary_section ~= comp_obj_heading_; } else { @@ -796,41 +797,41 @@ if there is a blurb section you need to: line_occur["para"] = State.off; an_object_key="blurb_nugget"; if (line.matchFirst(rgx.heading_blurb)) { - comp_obj_heading_ = comp_obj_heading_.init; - comp_obj_heading_.metainfo.is_of_part = "backmatter"; - comp_obj_heading_.metainfo.is_of_section = "blurb"; - comp_obj_heading_.metainfo.is_of_type = "para"; - comp_obj_heading_.metainfo.is_a = "heading"; - comp_obj_heading_.text = "Blurb"; - comp_obj_heading_.metainfo.ocn = 0; - comp_obj_heading_.metainfo.object_number_off = ""; - comp_obj_heading_.metainfo.object_number_type = 0; - comp_obj_heading_.tags.segment_anchor_tag = "_part_blurb"; - comp_obj_heading_.metainfo.heading_lev_markup = 1; - comp_obj_heading_.metainfo.heading_lev_collapsed = 1; - comp_obj_heading_.metainfo.parent_ocn = 1; - comp_obj_heading_.metainfo.parent_lev_markup = 0; - comp_obj_heading_.metainfo.dom_markedup = [ 1, 1, 0, 0, 0, 0, 0, 0]; - comp_obj_heading_.metainfo.dom_collapsed = [ 1, 1, 0, 0, 0, 0, 0, 0]; - the_blurb_section ~= comp_obj_heading_; - comp_obj_heading_ = comp_obj_heading_.init; - comp_obj_heading_.metainfo.is_of_part = "backmatter"; - comp_obj_heading_.metainfo.is_of_section = "blurb"; - comp_obj_heading_.metainfo.is_of_type = "para"; - comp_obj_heading_.metainfo.is_a = "heading"; - comp_obj_heading_.text = "Blurb"; - comp_obj_heading_.metainfo.ocn = 0; - comp_obj_heading_.metainfo.object_number_off = ""; - comp_obj_heading_.metainfo.object_number_type = 0; - comp_obj_heading_.tags.segment_anchor_tag = "blurb"; - comp_obj_heading_.metainfo.heading_lev_markup = 4; - comp_obj_heading_.metainfo.heading_lev_collapsed = 2; - comp_obj_heading_.metainfo.parent_ocn = 1; - comp_obj_heading_.metainfo.parent_lev_markup = 0; - comp_obj_heading_.tags.anchor_tags = ["blurb"]; - comp_obj_heading_.metainfo.dom_markedup = [ 1, 1, 0, 0, 1, 0, 0, 0]; - comp_obj_heading_.metainfo.dom_collapsed = [ 1, 1, 1, 0, 0, 0, 0, 0]; - the_blurb_section ~= comp_obj_heading_; + comp_obj_heading_ = comp_obj_heading_.init; + comp_obj_heading_.metainfo.is_of_part = "backmatter"; + comp_obj_heading_.metainfo.is_of_section = "blurb"; + comp_obj_heading_.metainfo.is_of_type = "para"; + comp_obj_heading_.metainfo.is_a = "heading"; + comp_obj_heading_.text = "Blurb"; + comp_obj_heading_.metainfo.ocn = 0; + comp_obj_heading_.metainfo.object_number_off = ""; + comp_obj_heading_.metainfo.object_number_type = 0; + comp_obj_heading_.tags.segment_anchor_tag = "_part_blurb"; + comp_obj_heading_.metainfo.heading_lev_markup = 1; + comp_obj_heading_.metainfo.heading_lev_collapsed = 1; + comp_obj_heading_.metainfo.parent_ocn = 1; + comp_obj_heading_.metainfo.parent_lev_markup = 0; + comp_obj_heading_.metainfo.dom_structure_markedup_tags_status = [ 1, 1, 0, 0, 0, 0, 0, 0]; + comp_obj_heading_.metainfo.dom_structure_collapsed_tags_status = [ 1, 1, 0, 0, 0, 0, 0, 0]; + the_blurb_section ~= comp_obj_heading_; + comp_obj_heading_ = comp_obj_heading_.init; + comp_obj_heading_.metainfo.is_of_part = "backmatter"; + comp_obj_heading_.metainfo.is_of_section = "blurb"; + comp_obj_heading_.metainfo.is_of_type = "para"; + comp_obj_heading_.metainfo.is_a = "heading"; + comp_obj_heading_.text = "Blurb"; + comp_obj_heading_.metainfo.ocn = 0; + comp_obj_heading_.metainfo.object_number_off = ""; + comp_obj_heading_.metainfo.object_number_type = 0; + comp_obj_heading_.tags.segment_anchor_tag = "blurb"; + comp_obj_heading_.metainfo.heading_lev_markup = 4; + comp_obj_heading_.metainfo.heading_lev_collapsed = 2; + comp_obj_heading_.metainfo.parent_ocn = 1; + comp_obj_heading_.metainfo.parent_lev_markup = 0; + comp_obj_heading_.tags.anchor_tags = ["blurb"]; + comp_obj_heading_.metainfo.dom_structure_markedup_tags_status = [ 1, 1, 0, 0, 1, 0, 0, 0]; + comp_obj_heading_.metainfo.dom_structure_collapsed_tags_status = [ 1, 1, 1, 0, 0, 0, 0, 0]; + the_blurb_section ~= comp_obj_heading_; } else if (line.matchFirst(rgx.heading) && (opt_action.backmatter && opt_action.section_blurb)) { comp_obj_heading_ = comp_obj_heading_.init; @@ -847,7 +848,7 @@ if there is a blurb section you need to: comp_obj_heading_.metainfo.heading_lev_collapsed = an_object["lev_collapsed_number"].to!int; // make int, remove need to conv comp_obj_heading_.metainfo.parent_ocn = 1; comp_obj_heading_.metainfo.parent_lev_markup = 0; - the_blurb_section ~= comp_obj_heading_; + the_blurb_section ~= comp_obj_heading_; } else { _para_match_(line, an_object, an_object_key, indent, bullet, obj_type_status, line_occur); comp_obj_para = comp_obj_para.init; @@ -1772,6 +1773,219 @@ NOTE there are issues attempting to do this on first pass as: - could optimise a bit by - skipping this loop unless the html seg or epub output is selected +***** Methods +****** get ancestors markup + +#+name: abs_post +#+BEGIN_SRC d +int[] _get_ancestors_markup(O)(O obj, ref int[] _ancestors_markup) { + if (obj.metainfo.is_a == "heading") { + debug(dom) { + writeln(obj.text); + } + if (obj.metainfo.heading_lev_markup == 1) { + _ancestors_markup = [ + _ancestors_markup[0], + 0,0,0,0,0,0,0 + ]; + } + if (obj.metainfo.heading_lev_markup == 2) { + _ancestors_markup = [ + _ancestors_markup[0], + _ancestors_markup[1], + 0,0,0,0,0,0 + ]; + } + if (obj.metainfo.heading_lev_markup == 3) { + _ancestors_markup = [ + _ancestors_markup[0], + _ancestors_markup[1], + _ancestors_markup[2], + 0,0,0,0,0 + ]; + } + if (obj.metainfo.heading_lev_markup == 4) { + _ancestors_markup = [ + _ancestors_markup[0], + _ancestors_markup[1], + _ancestors_markup[2], + _ancestors_markup[3], + 0,0,0,0 + ]; + } + if (obj.metainfo.heading_lev_markup == 5) { + _ancestors_markup = [ + _ancestors_markup[0], + _ancestors_markup[1], + _ancestors_markup[2], + _ancestors_markup[3], + _ancestors_markup[4], + 0,0,0 + ]; + } + if (obj.metainfo.heading_lev_markup == 6) { + _ancestors_markup = [ + _ancestors_markup[0], + _ancestors_markup[1], + _ancestors_markup[2], + _ancestors_markup[3], + _ancestors_markup[4], + _ancestors_markup[5], + 0,0 + ]; + } + if (obj.metainfo.heading_lev_markup == 7) { + _ancestors_markup = [ + _ancestors_markup[0], + _ancestors_markup[1], + _ancestors_markup[2], + _ancestors_markup[3], + _ancestors_markup[4], + _ancestors_markup[5], + _ancestors_markup[6], + 0 + ]; + } + if (obj.metainfo.heading_lev_markup == 8) { + _ancestors_markup = [ + _ancestors_markup[0], + _ancestors_markup[1], + _ancestors_markup[2], + _ancestors_markup[3], + _ancestors_markup[4], + _ancestors_markup[5], + _ancestors_markup[6], + _ancestors_markup[7] + ]; + } + _ancestors_markup[obj.metainfo.heading_lev_markup] = obj.metainfo.ocn; + } + debug(ancestor_markup) { + writeln("marked up: ", _ancestors_markup); + } + return _ancestors_markup; +} +#+END_SRC + +****** get ancestors collapsed + +#+name: abs_post +#+BEGIN_SRC d +int[] _get_ancestors_collapsed(O)(O obj, ref int[] _ancestors_collapsed) { + if (obj.metainfo.is_a == "heading") { + if (obj.metainfo.heading_lev_collapsed == 1) { + _ancestors_collapsed = [ + _ancestors_collapsed[0], + 0,0,0,0,0,0,0 + ]; + } + if (obj.metainfo.heading_lev_collapsed == 2) { + _ancestors_collapsed = [ + _ancestors_collapsed[0], + _ancestors_collapsed[1], + 0,0,0,0,0,0 + ]; + } + if (obj.metainfo.heading_lev_collapsed == 3) { + _ancestors_collapsed = [ + _ancestors_collapsed[0], + _ancestors_collapsed[1], + _ancestors_collapsed[2], + 0,0,0,0,0 + ]; + } + if (obj.metainfo.heading_lev_collapsed == 4) { + _ancestors_collapsed = [ + _ancestors_collapsed[0], + _ancestors_collapsed[1], + _ancestors_collapsed[2], + _ancestors_collapsed[3], + 0,0,0,0 + ]; + } + if (obj.metainfo.heading_lev_collapsed == 5) { + _ancestors_collapsed = [ + _ancestors_collapsed[0], + _ancestors_collapsed[1], + _ancestors_collapsed[2], + _ancestors_collapsed[3], + _ancestors_collapsed[4], + 0,0,0 + ]; + } + if (obj.metainfo.heading_lev_collapsed == 6) { + _ancestors_collapsed = [ + _ancestors_collapsed[0], + _ancestors_collapsed[1], + _ancestors_collapsed[2], + _ancestors_collapsed[3], + _ancestors_collapsed[4], + _ancestors_collapsed[5], + 0,0 + ]; + } + if (obj.metainfo.heading_lev_collapsed == 7) { + _ancestors_collapsed = [ + _ancestors_collapsed[0], + _ancestors_collapsed[1], + _ancestors_collapsed[2], + _ancestors_collapsed[3], + _ancestors_collapsed[4], + _ancestors_collapsed[5], + _ancestors_collapsed[6], + 0 + ]; + } + if (obj.metainfo.heading_lev_collapsed == 8) { + _ancestors_collapsed = [ + _ancestors_collapsed[0], + _ancestors_collapsed[1], + _ancestors_collapsed[2], + _ancestors_collapsed[3], + _ancestors_collapsed[4], + _ancestors_collapsed[5], + _ancestors_collapsed[6], + _ancestors_collapsed[7] + ]; + } + _ancestors_collapsed[obj.metainfo.heading_lev_collapsed] = obj.metainfo.ocn; + } + debug(ancestor_collapsed) { + writeln("collapsed: ", _ancestors_collapsed); + } + return _ancestors_collapsed; +} +#+END_SRC + +***** ↻ Loop section: document body [bd] + +- substantive object numbers already exist +- number un-numbered non-substantive text + +#+name: abs_post +#+BEGIN_SRC d +/+ multiple 1~ levels, loop through document body +/ +if (the_document_body_section.length > 1) { + int[] _ancestors_markup = [0,0,0,0,0,0,0,0]; + int[][] _ancestors_markup_; + _ancestors_markup = [1,0,0,0,0,0,0,0]; + _ancestors_markup_ ~= _ancestors_markup; + int[] _ancestors_collapsed = [0,0,0,0,0,0,0,0]; + int[][] _ancestors_collapsed_; + _ancestors_collapsed = [1,0,0,0,0,0,0,0]; + _ancestors_collapsed_ ~= _ancestors_collapsed; + foreach (ref obj; the_document_body_section) { + if (obj.metainfo.is_a == "heading") { + obj.metainfo.markedup_ancestors = _get_ancestors_markup(obj, _ancestors_markup); + } + } + debug(ancestors) { + writeln("ancestors markup o_n: ", obj.metainfo.markedup_ancestors); + writeln("ancestors collapsed o_n: ", obj.metainfo.markedup_ancestors); + } +} +#+END_SRC + ***** ↻ Loop section: endnotes #+name: abs_post @@ -1879,8 +2093,9 @@ Build here: - DOM structure - ancestors & decendants - ancestors could be determined earlier, but convenient to have here - - descendants could be in the form of: headings contained under current - heading, and/or; the range of objects under the current heading + - descendants could be in the form of: + - headings contained under current heading, and/or; + - the range of objects under the current heading - numbering - already given - substantive object numbers @@ -1984,8 +2199,8 @@ foreach (ref obj; the_document_head_section) { || (opt_action.sqlite_discrete) || (opt_action.sqlite_update) || (opt_action.postgresql)) { - obj = obj_dom_structure_set_markup_tags(obj, dom_markedup, obj.metainfo.heading_lev_markup); - obj = obj_dom_set_collapsed_tags(obj, dom_collapsed, obj.metainfo.heading_lev_collapsed); + obj = obj_dom_structure_set_markup_tags(obj, dom_structure_markedup_tags_status, obj.metainfo.heading_lev_markup); + obj = obj_dom_set_collapsed_tags(obj, dom_structure_collapsed_tags_status, obj.metainfo.heading_lev_collapsed); } obj = obj_heading_ancestors(obj, lv_ancestors_txt); } @@ -1998,8 +2213,8 @@ foreach (ref obj; the_document_head_section) { #+BEGIN_SRC d if (the_table_of_contents_section["scroll"].length > 1) { /+ scroll +/ - dom_markedup_buffer = dom_markedup.dup; - dom_collapsed_buffer = dom_collapsed.dup; + dom_structure_markedup_tags_status_buffer = dom_structure_markedup_tags_status.dup; + dom_structure_collapsed_tags_status_buffer = dom_structure_collapsed_tags_status.dup; foreach (ref obj; the_table_of_contents_section["scroll"]) { if (obj.metainfo.is_a == "heading") { if (obj.metainfo.heading_lev_markup <= 4) { @@ -2018,15 +2233,15 @@ if (the_table_of_contents_section["scroll"].length > 1) { || (opt_action.sqlite_discrete) || (opt_action.sqlite_update) || (opt_action.postgresql)) { - obj = obj_dom_structure_set_markup_tags(obj, dom_markedup, obj.metainfo.heading_lev_markup); - obj = obj_dom_set_collapsed_tags(obj, dom_collapsed, obj.metainfo.heading_lev_collapsed); + obj = obj_dom_structure_set_markup_tags(obj, dom_structure_markedup_tags_status, obj.metainfo.heading_lev_markup); + obj = obj_dom_set_collapsed_tags(obj, dom_structure_collapsed_tags_status, obj.metainfo.heading_lev_collapsed); } obj = obj_heading_ancestors(obj, lv_ancestors_txt); } } /+ seg +/ - dom_markedup = dom_markedup_buffer.dup; - dom_collapsed = dom_collapsed_buffer.dup; + dom_structure_markedup_tags_status = dom_structure_markedup_tags_status_buffer.dup; + dom_structure_collapsed_tags_status = dom_structure_collapsed_tags_status_buffer.dup; foreach (ref obj; the_table_of_contents_section["seg"]) { if (obj.metainfo.is_a == "heading") { debug(dom) { @@ -2044,8 +2259,8 @@ if (the_table_of_contents_section["scroll"].length > 1) { || (opt_action.html_scroll) || (opt_action.html_seg) || (opt_action.epub)) { - obj = obj_dom_structure_set_markup_tags(obj, dom_markedup, obj.metainfo.heading_lev_markup); - obj = obj_dom_set_collapsed_tags(obj, dom_collapsed, obj.metainfo.heading_lev_collapsed); + obj = obj_dom_structure_set_markup_tags(obj, dom_structure_markedup_tags_status, obj.metainfo.heading_lev_markup); + obj = obj_dom_set_collapsed_tags(obj, dom_structure_collapsed_tags_status, obj.metainfo.heading_lev_collapsed); } obj = obj_heading_ancestors(obj, lv_ancestors_txt); } @@ -2084,8 +2299,8 @@ if (the_document_body_section.length > 1) { || (opt_action.sqlite_discrete) || (opt_action.sqlite_update) || (opt_action.postgresql)) { - obj = obj_dom_structure_set_markup_tags(obj, dom_markedup, obj.metainfo.heading_lev_markup); - obj = obj_dom_set_collapsed_tags(obj, dom_collapsed, obj.metainfo.heading_lev_collapsed); + obj = obj_dom_structure_set_markup_tags(obj, dom_structure_markedup_tags_status, obj.metainfo.heading_lev_markup); + obj = obj_dom_set_collapsed_tags(obj, dom_structure_collapsed_tags_status, obj.metainfo.heading_lev_collapsed); } obj = obj_heading_ancestors(obj, lv_ancestors_txt); } else if (obj.metainfo.is_a == "para") { @@ -2105,10 +2320,10 @@ auto images=uniq(_images.sort()); #+BEGIN_SRC d /+ optional only one 1~ level +/ if (the_endnotes_section.length > 1) { - dom_markedup_buffer = dom_markedup.dup; - dom_collapsed_buffer = dom_collapsed.dup; - dom_markedup = dom_markedup_buffer.dup; - dom_collapsed = dom_collapsed_buffer.dup; + dom_structure_markedup_tags_status_buffer = dom_structure_markedup_tags_status.dup; + dom_structure_collapsed_tags_status_buffer = dom_structure_collapsed_tags_status.dup; + dom_structure_markedup_tags_status = dom_structure_markedup_tags_status_buffer.dup; + dom_structure_collapsed_tags_status = dom_structure_collapsed_tags_status_buffer.dup; foreach (ref obj; the_endnotes_section) { if (obj.metainfo.is_a == "heading") { debug(dom) { @@ -2135,8 +2350,8 @@ if (the_endnotes_section.length > 1) { || (opt_action.sqlite_discrete) || (opt_action.sqlite_update) || (opt_action.postgresql)) { - obj = obj_dom_structure_set_markup_tags(obj, dom_markedup, obj.metainfo.heading_lev_markup); - obj = obj_dom_set_collapsed_tags(obj, dom_collapsed, obj.metainfo.heading_lev_collapsed); + obj = obj_dom_structure_set_markup_tags(obj, dom_structure_markedup_tags_status, obj.metainfo.heading_lev_markup); + obj = obj_dom_set_collapsed_tags(obj, dom_structure_collapsed_tags_status, obj.metainfo.heading_lev_collapsed); } obj = obj_heading_ancestors(obj, lv_ancestors_txt); } @@ -2178,8 +2393,8 @@ if (the_glossary_section.length > 1) { || (opt_action.sqlite_discrete) || (opt_action.sqlite_update) || (opt_action.postgresql)) { - obj = obj_dom_structure_set_markup_tags(obj, dom_markedup, obj.metainfo.heading_lev_markup); - obj = obj_dom_set_collapsed_tags(obj, dom_collapsed, obj.metainfo.heading_lev_collapsed); + obj = obj_dom_structure_set_markup_tags(obj, dom_structure_markedup_tags_status, obj.metainfo.heading_lev_markup); + obj = obj_dom_set_collapsed_tags(obj, dom_structure_collapsed_tags_status, obj.metainfo.heading_lev_collapsed); } obj = obj_heading_ancestors(obj, lv_ancestors_txt); } else if (obj.metainfo.is_a == "glossary") { @@ -2224,8 +2439,8 @@ if (the_bibliography_section.length > 1) { || (opt_action.sqlite_discrete) || (opt_action.sqlite_update) || (opt_action.postgresql)) { - obj = obj_dom_structure_set_markup_tags(obj, dom_markedup, obj.metainfo.heading_lev_markup); - obj = obj_dom_set_collapsed_tags(obj, dom_collapsed, obj.metainfo.heading_lev_collapsed); + obj = obj_dom_structure_set_markup_tags(obj, dom_structure_markedup_tags_status, obj.metainfo.heading_lev_markup); + obj = obj_dom_set_collapsed_tags(obj, dom_structure_collapsed_tags_status, obj.metainfo.heading_lev_collapsed); } obj = obj_heading_ancestors(obj, lv_ancestors_txt); } else if (obj.metainfo.is_a == "bibliography") { @@ -2248,8 +2463,8 @@ int ocn_bkidx_ = 0; int ocn_bidx_; if (the_bookindex_section["scroll"].length > 1) { /+ scroll +/ - dom_markedup_buffer = dom_markedup.dup; - dom_collapsed_buffer = dom_collapsed.dup; + dom_structure_markedup_tags_status_buffer = dom_structure_markedup_tags_status.dup; + dom_structure_collapsed_tags_status_buffer = dom_structure_collapsed_tags_status.dup; foreach (ref obj; the_bookindex_section["scroll"]) { if (obj.metainfo.is_a == "heading") { debug(dom) { @@ -2275,20 +2490,20 @@ if (the_bookindex_section["scroll"].length > 1) { || (opt_action.sqlite_discrete) || (opt_action.sqlite_update) || (opt_action.postgresql)) { - obj = obj_dom_structure_set_markup_tags(obj, dom_markedup, obj.metainfo.heading_lev_markup); - obj = obj_dom_set_collapsed_tags(obj, dom_collapsed, obj.metainfo.heading_lev_collapsed); + obj = obj_dom_structure_set_markup_tags(obj, dom_structure_markedup_tags_status, obj.metainfo.heading_lev_markup); + obj = obj_dom_set_collapsed_tags(obj, dom_structure_collapsed_tags_status, obj.metainfo.heading_lev_collapsed); } obj = obj_heading_ancestors(obj, lv_ancestors_txt); } else if (obj.metainfo.is_a == "bookindex") { - obj_cite_digits = ocn_emit(OCNstatus.bkidx); + obj_cite_digits = ocn_emit(OCNstatus.bkidx); obj.metainfo.ocn = obj_cite_digits.digit; obj.metainfo.o_n_book_index = obj_cite_digits.bkidx; obj.metainfo.object_number_type = OCNtype.bkidx; } } /+ seg +/ - dom_markedup = dom_markedup_buffer.dup; - dom_collapsed = dom_collapsed_buffer.dup; + dom_structure_markedup_tags_status = dom_structure_markedup_tags_status_buffer.dup; + dom_structure_collapsed_tags_status = dom_structure_collapsed_tags_status_buffer.dup; foreach (ref obj; the_bookindex_section["seg"]) { if (obj.metainfo.is_a == "heading") { debug(dom) { @@ -2314,12 +2529,12 @@ if (the_bookindex_section["scroll"].length > 1) { || (opt_action.sqlite_discrete) || (opt_action.sqlite_update) || (opt_action.postgresql)) { - obj = obj_dom_structure_set_markup_tags(obj, dom_markedup, obj.metainfo.heading_lev_markup); - obj = obj_dom_set_collapsed_tags(obj, dom_collapsed, obj.metainfo.heading_lev_collapsed); + obj = obj_dom_structure_set_markup_tags(obj, dom_structure_markedup_tags_status, obj.metainfo.heading_lev_markup); + obj = obj_dom_set_collapsed_tags(obj, dom_structure_collapsed_tags_status, obj.metainfo.heading_lev_collapsed); } obj = obj_heading_ancestors(obj, lv_ancestors_txt); } else if (obj.metainfo.is_a == "bookindex") { - ocn_bidx_ = ++ocn_bkidx_; + ocn_bidx_ = ++ocn_bkidx_; obj.metainfo.o_n_book_index = ocn_bidx_; // FIX need to distinguish from regular ocn obj.metainfo.object_number_type = OCNtype.bkidx; } @@ -2363,8 +2578,8 @@ if (the_blurb_section.length > 1) { || (opt_action.sqlite_discrete) || (opt_action.sqlite_update) || (opt_action.postgresql)) { - obj = obj_dom_structure_set_markup_tags(obj, dom_markedup, obj.metainfo.heading_lev_markup); - obj = obj_dom_set_collapsed_tags(obj, dom_collapsed, obj.metainfo.heading_lev_collapsed); + obj = obj_dom_structure_set_markup_tags(obj, dom_structure_markedup_tags_status, obj.metainfo.heading_lev_markup); + obj = obj_dom_set_collapsed_tags(obj, dom_structure_collapsed_tags_status, obj.metainfo.heading_lev_collapsed); } obj = obj_heading_ancestors(obj, lv_ancestors_txt); } else if (obj.metainfo.is_a == "blurb") { @@ -2383,8 +2598,8 @@ if (the_blurb_section.length > 1) { /+ TODO - note create/insert heading object sole purpose eof close all open tags sort out: - - obj.metainfo.dom_markedup = dom_markedup; - - obj.metainfo.dom_collapsed = dom_collapsed; + - obj.metainfo.dom_structure_markedup_tags_status = dom_structure_markedup_tags_status; + - obj.metainfo.dom_structure_collapsed_tags_status = dom_structure_collapsed_tags_status; +/ comp_obj_heading_ = comp_obj_heading_.init; comp_obj_heading_.metainfo.is_of_part = "empty"; @@ -2399,10 +2614,10 @@ comp_obj_heading_.metainfo.heading_lev_markup = 9; comp_obj_heading_.metainfo.heading_lev_collapsed = 9; comp_obj_heading_.metainfo.parent_ocn = 0; comp_obj_heading_.metainfo.parent_lev_markup = 0; -comp_obj_heading_.metainfo.dom_markedup = dom_markedup.dup; -comp_obj_heading_.metainfo.dom_collapsed = dom_collapsed.dup; -comp_obj_heading_ = obj_dom_structure_set_markup_tags(comp_obj_heading_, dom_markedup, 0); -comp_obj_heading_ = obj_dom_set_collapsed_tags(comp_obj_heading_, dom_collapsed, 0); +comp_obj_heading_.metainfo.dom_structure_markedup_tags_status = dom_structure_markedup_tags_status.dup; +comp_obj_heading_.metainfo.dom_structure_collapsed_tags_status = dom_structure_collapsed_tags_status.dup; +comp_obj_heading_ = obj_dom_structure_set_markup_tags(comp_obj_heading_, dom_structure_markedup_tags_status, 0); +comp_obj_heading_ = obj_dom_set_collapsed_tags(comp_obj_heading_, dom_structure_collapsed_tags_status, 0); comp_obj_heading_ = obj_heading_ancestors(comp_obj_heading_, lv_ancestors_txt); // the_dom_tail_section ~= comp_obj_heading_; // remove tail for now, decide on later #+END_SRC @@ -2497,16 +2712,68 @@ destroy(the_blurb_section); destroy(html_segnames); destroy(bookindex_unordered_hashes); destroy(an_object); -obj_cite_digits = ocn_emit(OCNstatus.reset); -biblio_arr_json = []; -obj_cite_digit_ = 0; -html_segnames_ptr = 0; -html_segnames_ptr_cntr = 0; -content_non_header = "8"; -dom_markedup = [ 0, 0, 0, 0, 0, 0, 0, 0, 0,]; -dom_markedup_buffer = [ 0, 0, 0, 0, 0, 0, 0, 0, 0,]; -dom_collapsed = [ 0, 0, 0, 0, 0, 0, 0, 0, 0,]; -dom_collapsed_buffer = [ 0, 0, 0, 0, 0, 0, 0, 0, 0,]; +obj_cite_digits = ocn_emit(OCNstatus.reset); +biblio_arr_json = []; +obj_cite_digit_ = 0; +html_segnames_ptr = 0; +html_segnames_ptr_cntr = 0; +content_non_header = "8"; +dom_structure_markedup_tags_status = [ 0, 0, 0, 0, 0, 0, 0, 0, 0,]; +dom_structure_markedup_tags_status_buffer = [ 0, 0, 0, 0, 0, 0, 0, 0, 0,]; +dom_structure_collapsed_tags_status = [ 0, 0, 0, 0, 0, 0, 0, 0, 0,]; +dom_structure_collapsed_tags_status_buffer = [ 0, 0, 0, 0, 0, 0, 0, 0, 0,]; +#+END_SRC + +*** [#A] ↻ _reloop_ :reloop: + +- this would work, but no need for extra loop, remove + +#+name: abs_post_doc_reloop_processing +#+BEGIN_SRC d +debug(abstraction) { + foreach (part; sequenced_document_keys.scroll) { + foreach (ref obj; document_the[part]) { + debug(node_misc) { + if (obj.metainfo.is_a == "heading") { + writeln("heading ancestors text?: ", obj.tags.heading_ancestors_text); + } + } + debug(node_headings) { + if (obj.metainfo.is_a == "heading") { + writeln("---"); + writeln(obj.text); + writeln(" node: ", obj.metainfo.node); + writeln(" ocn: ", obj.metainfo.ocn); + writeln(" markedup heading lev: ", obj.metainfo.heading_lev_markup); + writeln(" collapsed heading lev ", obj.metainfo.heading_lev_collapsed); + writeln(" parent ocn: ", obj.metainfo.parent_ocn); + writeln(" parent lev: ", obj.metainfo.parent_lev_markup); + writeln(" markedup ancestors o_n: ", obj.metainfo.markedup_ancestors); + writeln(" dom markedup: ", obj.metainfo.dom_structure_markedup_tags_status); + writeln(" collapsed ancestors o_n: ", obj.metainfo.collapsed_ancestors); + writeln(" dom collapsed: ", obj.metainfo.dom_structure_collapsed_tags_status); + } + } + debug(node_all) { + writeln("---"); + if (obj.metainfo.is_a == "heading") { + writeln(obj.text); + } + writeln("node: ", obj.metainfo.node); + writeln("ocn: ", obj.metainfo.ocn); + writeln("markedup heading lev: ", obj.metainfo.heading_lev_markup); + writeln("collapsed heading lev ", obj.metainfo.heading_lev_collapsed); + writeln("markedup ancestors o_n: ", obj.metainfo.markedup_ancestors); + writeln("collapsed ancestors o_n: ", obj.metainfo.collapsed_ancestors); + writeln("dom markedup: ", obj.metainfo.dom_structure_markedup_tags_status); + writeln("dom collapsed: ", obj.metainfo.dom_structure_collapsed_tags_status); + writeln("parent ocn: ", obj.metainfo.parent_ocn); + writeln("parent lev: ", obj.metainfo.parent_lev_markup); + writeln("Node: ", obj.metainfo.ocn); + } + } + } +} #+END_SRC *** [#A] _return document tuple_ :return:tuple: @@ -6808,7 +7075,7 @@ struct NodeStructureMetadata { comp_obj_location.tags.segment_anchor_tag = segment_anchor_tag.to!string; comp_obj_location.metainfo.parent_ocn = p_["object_number"]; comp_obj_location.metainfo.parent_lev_markup = p_["lev_markup_number"]; - debug(node) { + debug(_node) { if (lev_markup_number.match(rgx.levels_numbered_headings)) { writeln("x ", _node.to!string); } else { @@ -6979,7 +7246,7 @@ struct NodeStructureMetadata { _comp_obj_heading_.has.inline_notes_reg = flag_notes_reg; _comp_obj_heading_.has.inline_notes_star = flag_notes_star; _comp_obj_heading_.has.inline_links = flag_links; - debug(node) { + debug(_node) { if (lev_markup_number.match(rgx.levels_numbered_headings)) { writeln("* ", _node.to!string); } @@ -7402,50 +7669,50 @@ struct DocObj_MetaInfo_ { // metainfo } return _out; } - int[] dom_markedup = [ 0, 0, 0, 0, 0, 0, 0, 0,]; - int[] dom_collapsed = [ 0, 0, 0, 0, 0, 0, 0, 0,]; - int[] heading_ancestors = [ 0, 0, 0, 0, 0, 0, 0, 0,]; - int parent_lev_markup = 0; - int parent_ocn = 0; - int[] ancestors = []; + int[] markedup_ancestors = [ 0, 0, 0, 0, 0, 0, 0, 0,]; + int[] collapsed_ancestors = [ 0, 0, 0, 0, 0, 0, 0, 0,]; + int[] dom_structure_markedup_tags_status = [ 0, 0, 0, 0, 0, 0, 0, 0,]; + int[] dom_structure_collapsed_tags_status = [ 0, 0, 0, 0, 0, 0, 0, 0,]; + int parent_lev_markup = 0; + int parent_ocn = 0; } -struct DocObj_TxtAttrib_ { // attrib - int indent_base = 0; - int indent_hang = 0; - bool bullet = false; - string language = ""; // not implemented, consider +struct DocObj_TxtAttrib_ { // attrib + int indent_base = 0; + int indent_hang = 0; + bool bullet = false; + string language = ""; // not implemented, consider } -struct DocObj_Has_ { // has - bool inline_links = false; - bool inline_notes_reg = false; - bool inline_notes_star = false; - bool contains_image_without_dimensions = false; +struct DocObj_Has_ { // has + bool inline_links = false; + bool inline_notes_reg = false; + bool inline_notes_star = false; + bool contains_image_without_dimensions = false; } -struct DocObj_Table_ { // table - int number_of_columns = 0; - double[] column_widths = []; - string[] column_aligns = []; - bool heading = false; - bool walls = false; // not implemented +struct DocObj_Table_ { // table + int number_of_columns = 0; + double[] column_widths = []; + string[] column_aligns = []; + bool heading = false; + bool walls = false; // not implemented } -struct DocObj_CodeBlock_ { // code_block - string syntax = ""; +struct DocObj_CodeBlock_ { // code_block + string syntax = ""; } -struct DocObj_Pointer_ { // ptr - int doc_object = 0; - int html_segnames = 0; - int heading = 0; +struct DocObj_Pointer_ { // ptr + int doc_object = 0; + int html_segnames = 0; + int heading = 0; } -struct DocObj_Tags_ { // tags - string[] heading_ancestors_text = [ "", "", "", "", "", "", "", "", ]; - string segment_anchor_tag = ""; - string segname_prev = ""; - string segname_next = ""; - string[] lev4_subtoc = []; - string[] anchor_tags = []; +struct DocObj_Tags_ { // tags + string[] heading_ancestors_text = [ "", "", "", "", "", "", "", "", ]; // TODO redundant? see markedup and collapsed ancestors DONE + string segment_anchor_tag = ""; + string segname_prev = ""; + string segname_next = ""; + string[] lev4_subtoc = []; + string[] anchor_tags = []; } struct ObjGenericComposite { - string text = ""; + string text = ""; DocObj_MetaInfo_ metainfo; DocObj_TxtAttrib_ attrib; DocObj_Tags_ tags; diff --git a/org/meta_debugs.org b/org/meta_debugs.org index b89b4ea..e34a95c 100644 --- a/org/meta_debugs.org +++ b/org/meta_debugs.org @@ -310,7 +310,7 @@ debug(toc_nav_dom) { foreach (obj; contents[sect]) { if (obj.metainfo.is_a == "heading") { foreach_reverse (k; 0 .. 7) { - switch (obj.dom_markedup[k]) { + switch (obj.dom_structure_markedup_tags_status[k]) { case DomTags.close : writeln(markup.indent_by_spaces_provided(k), ""); break; @@ -337,7 +337,7 @@ debug(toc_nav_dom) { foreach (obj; contents[sect]) { if (obj.metainfo.is_a == "heading") { foreach_reverse (k; 0 .. 7) { - switch (obj.dom_collapsed[k]) { + switch (obj.dom_structure_collapsed_tags_status[k]) { case DomTags.close : writeln(markup.indent_by_spaces_provided(k), ""); break; diff --git a/org/output_sqlite.org b/org/output_sqlite.org index 45f8303..58e612e 100644 --- a/org/output_sqlite.org +++ b/org/output_sqlite.org @@ -1063,9 +1063,9 @@ foreach (part; doc_matters.xml.keys_seq.sql) { if ((doc_matters.opt.action.verbose)) { writeln( "markup: ", obj.metainfo.heading_lev_markup, - "> ", obj.metainfo.dom_markedup, + "> ", obj.metainfo.dom_structure_markedup_tags_status, "; collapsed: ", obj.metainfo.heading_lev_collapsed, - "> ", obj.metainfo.dom_collapsed, + "> ", obj.metainfo.dom_structure_collapsed_tags_status, "; ocn: ", obj.metainfo.ocn, " node: ", obj.metainfo.node, "; parent: ", obj.metainfo.parent_lev_markup, diff --git a/org/output_xmls.org b/org/output_xmls.org index 3742975..27c3f2f 100644 --- a/org/output_xmls.org +++ b/org/output_xmls.org @@ -2058,7 +2058,7 @@ string epub3_oebps_toc_nav_xhtml(D,I)(D doc_abstraction, I doc_matters) { string _txt = obj.text.replaceAll(rgx.inline_notes_al_gen, "").strip; foreach_reverse (n; 0 .. 7) { string k = n.to!string; - switch (obj.metainfo.dom_collapsed[n]) { + switch (obj.metainfo.dom_structure_collapsed_tags_status[n]) { case DomTags.close : toc ~= markup.indent_by_spaces_provided((n + 1), " ") ~ "" ~ "\n"; toc ~= markup.indent_by_spaces_provided(n, " ") ~ "" ~ "\n"; @@ -2164,7 +2164,7 @@ string epub2_oebps_toc_ncx(D,I)(D doc_abstraction, I doc_matters) { string _txt = obj.text.replaceAll(rgx.inline_notes_al_gen, "").strip; string hashtag =(obj.metainfo.heading_lev_markup <= 4) ? "" : ("#" ~ obj.metainfo.ocn.to!string); foreach_reverse (k; 0 .. 7) { - switch (obj.metainfo.dom_markedup[k]) { + switch (obj.metainfo.dom_structure_markedup_tags_status[k]) { case DomTags.close : toc ~= "\n "; break; diff --git a/src/sdp/meta/doc_debugs.d b/src/sdp/meta/doc_debugs.d index c8b9dc1..bc781ee 100644 --- a/src/sdp/meta/doc_debugs.d +++ b/src/sdp/meta/doc_debugs.d @@ -120,7 +120,7 @@ template SiSUdebugs() { foreach (obj; contents[sect]) { if (obj.metainfo.is_a == "heading") { foreach_reverse (k; 0 .. 7) { - switch (obj.dom_markedup[k]) { + switch (obj.dom_structure_markedup_tags_status[k]) { case DomTags.close : writeln(markup.indent_by_spaces_provided(k), ""); break; @@ -147,7 +147,7 @@ template SiSUdebugs() { foreach (obj; contents[sect]) { if (obj.metainfo.is_a == "heading") { foreach_reverse (k; 0 .. 7) { - switch (obj.dom_collapsed[k]) { + switch (obj.dom_structure_collapsed_tags_status[k]) { case DomTags.close : writeln(markup.indent_by_spaces_provided(k), ""); break; diff --git a/src/sdp/meta/metadoc_from_src.d b/src/sdp/meta/metadoc_from_src.d index 9c01a47..ee82257 100644 --- a/src/sdp/meta/metadoc_from_src.d +++ b/src/sdp/meta/metadoc_from_src.d @@ -79,10 +79,10 @@ template SiSUdocAbstraction() { OCNset obj_cite_digits; int obj_cite_digit_, obj_cite_digit_off, obj_cite_digit_bkidx, obj_cite_digit_type; auto object_citation_number = OCNemitter(); - int[] dom_markedup = [ 0, 0, 0, 0, 0, 0, 0, 0, 0,]; - int[] dom_markedup_buffer = [ 0, 0, 0, 0, 0, 0, 0, 0, 0,]; - int[] dom_collapsed = [ 0, 0, 0, 0, 0, 0, 0, 0, 0,]; - int[] dom_collapsed_buffer = [ 0, 0, 0, 0, 0, 0, 0, 0, 0,]; + int[] dom_structure_markedup_tags_status = [ 0, 0, 0, 0, 0, 0, 0, 0, 0,]; + int[] dom_structure_markedup_tags_status_buffer = [ 0, 0, 0, 0, 0, 0, 0, 0, 0,]; + int[] dom_structure_collapsed_tags_status = [ 0, 0, 0, 0, 0, 0, 0, 0, 0,]; + int[] dom_structure_collapsed_tags_status_buffer = [ 0, 0, 0, 0, 0, 0, 0, 0, 0,]; enum DomTags { none, open, close, close_and_open, open_still, } pure auto obj_heading_ancestors(O)( O obj, @@ -178,7 +178,7 @@ template SiSUdocAbstraction() { debug(dom_magic_numbers) { writeln("marked up: ", lev, ": ", dom); } - obj.metainfo.dom_markedup = dom.dup; + obj.metainfo.dom_structure_markedup_tags_status = dom.dup; return obj; } pure auto obj_dom_set_collapsed_tags(O)( @@ -222,7 +222,7 @@ template SiSUdocAbstraction() { debug(dom_magic_numbers) { writeln("collapsed: ", lev, ": ", dom); } - obj.metainfo.dom_collapsed = dom.dup; + obj.metainfo.dom_structure_collapsed_tags_status = dom.dup; return obj; } static auto ocn_emit(int ocn_status_flag) { @@ -323,27 +323,27 @@ template SiSUdocAbstraction() { ]; string _anchor_tag; string toc_txt_; - an_object["glossary_nugget"] = ""; - an_object["blurb_nugget"] = ""; - comp_obj_heading_ = comp_obj_heading_.init; - comp_obj_heading_.metainfo.is_of_part = "frontmatter"; - comp_obj_heading_.metainfo.is_of_section = "toc"; - comp_obj_heading_.metainfo.is_of_type = "para"; - comp_obj_heading_.metainfo.is_a = "heading"; - comp_obj_heading_.text = "Table of Contents"; - comp_obj_heading_.metainfo.ocn = 0; - comp_obj_heading_.metainfo.object_number_off = ""; - comp_obj_heading_.metainfo.object_number_type = 0; - comp_obj_heading_.tags.segment_anchor_tag = "toc"; - comp_obj_heading_.metainfo.heading_lev_markup = 4; - comp_obj_heading_.metainfo.heading_lev_collapsed = 1; - comp_obj_heading_.metainfo.parent_ocn = 1; - comp_obj_heading_.metainfo.parent_lev_markup = 0; - comp_obj_heading_.ptr.html_segnames = html_segnames_ptr; - comp_obj_heading_.tags.anchor_tags = ["toc"]; - comp_obj_heading_.metainfo.dom_markedup = [ 1, 1, 0, 0, 1, 0, 0, 0]; - comp_obj_heading_.metainfo.dom_collapsed = [ 1, 1, 1, 0, 0, 0, 0, 0]; - auto toc_head = comp_obj_heading_; + an_object["glossary_nugget"] = ""; + an_object["blurb_nugget"] = ""; + comp_obj_heading_ = comp_obj_heading_.init; + comp_obj_heading_.metainfo.is_of_part = "frontmatter"; + comp_obj_heading_.metainfo.is_of_section = "toc"; + comp_obj_heading_.metainfo.is_of_type = "para"; + comp_obj_heading_.metainfo.is_a = "heading"; + comp_obj_heading_.text = "Table of Contents"; + comp_obj_heading_.metainfo.ocn = 0; + comp_obj_heading_.metainfo.object_number_off = ""; + comp_obj_heading_.metainfo.object_number_type = 0; + comp_obj_heading_.tags.segment_anchor_tag = "toc"; + comp_obj_heading_.metainfo.heading_lev_markup = 4; + comp_obj_heading_.metainfo.heading_lev_collapsed = 1; + comp_obj_heading_.metainfo.parent_ocn = 1; + comp_obj_heading_.metainfo.parent_lev_markup = 0; + comp_obj_heading_.ptr.html_segnames = html_segnames_ptr; + comp_obj_heading_.tags.anchor_tags = ["toc"]; + comp_obj_heading_.metainfo.dom_structure_markedup_tags_status = [ 1, 1, 0, 0, 1, 0, 0, 0]; + comp_obj_heading_.metainfo.dom_structure_collapsed_tags_status = [ 1, 1, 1, 0, 0, 0, 0, 0]; + auto toc_head = comp_obj_heading_; html_segnames_ptr_cntr++; the_table_of_contents_section = [ "seg": [toc_head], @@ -478,8 +478,8 @@ template SiSUdocAbstraction() { comp_obj_heading_.metainfo.heading_lev_collapsed = 1; comp_obj_heading_.metainfo.parent_ocn = 1; comp_obj_heading_.metainfo.parent_lev_markup = 0; - comp_obj_heading_.metainfo.dom_markedup = [ 1, 1, 0, 0, 0, 0, 0, 0]; - comp_obj_heading_.metainfo.dom_collapsed = [ 1, 1, 0, 0, 0, 0, 0, 0]; + comp_obj_heading_.metainfo.dom_structure_markedup_tags_status = [ 1, 1, 0, 0, 0, 0, 0, 0]; + comp_obj_heading_.metainfo.dom_structure_collapsed_tags_status = [ 1, 1, 0, 0, 0, 0, 0, 0]; the_glossary_section ~= comp_obj_heading_; comp_obj_heading_ = comp_obj_heading_.init; comp_obj_heading_.metainfo.is_of_part = "backmatter"; @@ -495,8 +495,8 @@ template SiSUdocAbstraction() { comp_obj_heading_.metainfo.heading_lev_collapsed = 2; comp_obj_heading_.metainfo.parent_ocn = 1; comp_obj_heading_.metainfo.parent_lev_markup = 0; - comp_obj_heading_.metainfo.dom_markedup = [ 1, 1, 0, 0, 1, 0, 0, 0]; - comp_obj_heading_.metainfo.dom_collapsed = [ 1, 1, 1, 0, 0, 0, 0, 0]; + comp_obj_heading_.metainfo.dom_structure_markedup_tags_status = [ 1, 1, 0, 0, 1, 0, 0, 0]; + comp_obj_heading_.metainfo.dom_structure_collapsed_tags_status = [ 1, 1, 1, 0, 0, 0, 0, 0]; comp_obj_heading_.tags.anchor_tags = ["glossary"]; the_glossary_section ~= comp_obj_heading_; } else { @@ -570,41 +570,41 @@ template SiSUdocAbstraction() { line_occur["para"] = State.off; an_object_key="blurb_nugget"; if (line.matchFirst(rgx.heading_blurb)) { - comp_obj_heading_ = comp_obj_heading_.init; - comp_obj_heading_.metainfo.is_of_part = "backmatter"; - comp_obj_heading_.metainfo.is_of_section = "blurb"; - comp_obj_heading_.metainfo.is_of_type = "para"; - comp_obj_heading_.metainfo.is_a = "heading"; - comp_obj_heading_.text = "Blurb"; - comp_obj_heading_.metainfo.ocn = 0; - comp_obj_heading_.metainfo.object_number_off = ""; - comp_obj_heading_.metainfo.object_number_type = 0; - comp_obj_heading_.tags.segment_anchor_tag = "_part_blurb"; - comp_obj_heading_.metainfo.heading_lev_markup = 1; - comp_obj_heading_.metainfo.heading_lev_collapsed = 1; - comp_obj_heading_.metainfo.parent_ocn = 1; - comp_obj_heading_.metainfo.parent_lev_markup = 0; - comp_obj_heading_.metainfo.dom_markedup = [ 1, 1, 0, 0, 0, 0, 0, 0]; - comp_obj_heading_.metainfo.dom_collapsed = [ 1, 1, 0, 0, 0, 0, 0, 0]; - the_blurb_section ~= comp_obj_heading_; - comp_obj_heading_ = comp_obj_heading_.init; - comp_obj_heading_.metainfo.is_of_part = "backmatter"; - comp_obj_heading_.metainfo.is_of_section = "blurb"; - comp_obj_heading_.metainfo.is_of_type = "para"; - comp_obj_heading_.metainfo.is_a = "heading"; - comp_obj_heading_.text = "Blurb"; - comp_obj_heading_.metainfo.ocn = 0; - comp_obj_heading_.metainfo.object_number_off = ""; - comp_obj_heading_.metainfo.object_number_type = 0; - comp_obj_heading_.tags.segment_anchor_tag = "blurb"; - comp_obj_heading_.metainfo.heading_lev_markup = 4; - comp_obj_heading_.metainfo.heading_lev_collapsed = 2; - comp_obj_heading_.metainfo.parent_ocn = 1; - comp_obj_heading_.metainfo.parent_lev_markup = 0; - comp_obj_heading_.tags.anchor_tags = ["blurb"]; - comp_obj_heading_.metainfo.dom_markedup = [ 1, 1, 0, 0, 1, 0, 0, 0]; - comp_obj_heading_.metainfo.dom_collapsed = [ 1, 1, 1, 0, 0, 0, 0, 0]; - the_blurb_section ~= comp_obj_heading_; + comp_obj_heading_ = comp_obj_heading_.init; + comp_obj_heading_.metainfo.is_of_part = "backmatter"; + comp_obj_heading_.metainfo.is_of_section = "blurb"; + comp_obj_heading_.metainfo.is_of_type = "para"; + comp_obj_heading_.metainfo.is_a = "heading"; + comp_obj_heading_.text = "Blurb"; + comp_obj_heading_.metainfo.ocn = 0; + comp_obj_heading_.metainfo.object_number_off = ""; + comp_obj_heading_.metainfo.object_number_type = 0; + comp_obj_heading_.tags.segment_anchor_tag = "_part_blurb"; + comp_obj_heading_.metainfo.heading_lev_markup = 1; + comp_obj_heading_.metainfo.heading_lev_collapsed = 1; + comp_obj_heading_.metainfo.parent_ocn = 1; + comp_obj_heading_.metainfo.parent_lev_markup = 0; + comp_obj_heading_.metainfo.dom_structure_markedup_tags_status = [ 1, 1, 0, 0, 0, 0, 0, 0]; + comp_obj_heading_.metainfo.dom_structure_collapsed_tags_status = [ 1, 1, 0, 0, 0, 0, 0, 0]; + the_blurb_section ~= comp_obj_heading_; + comp_obj_heading_ = comp_obj_heading_.init; + comp_obj_heading_.metainfo.is_of_part = "backmatter"; + comp_obj_heading_.metainfo.is_of_section = "blurb"; + comp_obj_heading_.metainfo.is_of_type = "para"; + comp_obj_heading_.metainfo.is_a = "heading"; + comp_obj_heading_.text = "Blurb"; + comp_obj_heading_.metainfo.ocn = 0; + comp_obj_heading_.metainfo.object_number_off = ""; + comp_obj_heading_.metainfo.object_number_type = 0; + comp_obj_heading_.tags.segment_anchor_tag = "blurb"; + comp_obj_heading_.metainfo.heading_lev_markup = 4; + comp_obj_heading_.metainfo.heading_lev_collapsed = 2; + comp_obj_heading_.metainfo.parent_ocn = 1; + comp_obj_heading_.metainfo.parent_lev_markup = 0; + comp_obj_heading_.tags.anchor_tags = ["blurb"]; + comp_obj_heading_.metainfo.dom_structure_markedup_tags_status = [ 1, 1, 0, 0, 1, 0, 0, 0]; + comp_obj_heading_.metainfo.dom_structure_collapsed_tags_status = [ 1, 1, 1, 0, 0, 0, 0, 0]; + the_blurb_section ~= comp_obj_heading_; } else if (line.matchFirst(rgx.heading) && (opt_action.backmatter && opt_action.section_blurb)) { comp_obj_heading_ = comp_obj_heading_.init; @@ -621,7 +621,7 @@ template SiSUdocAbstraction() { comp_obj_heading_.metainfo.heading_lev_collapsed = an_object["lev_collapsed_number"].to!int; // make int, remove need to conv comp_obj_heading_.metainfo.parent_ocn = 1; comp_obj_heading_.metainfo.parent_lev_markup = 0; - the_blurb_section ~= comp_obj_heading_; + the_blurb_section ~= comp_obj_heading_; } else { _para_match_(line, an_object, an_object_key, indent, bullet, obj_type_status, line_occur); comp_obj_para = comp_obj_para.init; @@ -1325,6 +1325,197 @@ template SiSUdocAbstraction() { } the_document_head_section ~= the_document_body_section[0]; the_document_body_section=the_document_body_section[1..$]; + int[] _get_ancestors_markup(O)(O obj, ref int[] _ancestors_markup) { + if (obj.metainfo.is_a == "heading") { + debug(dom) { + writeln(obj.text); + } + if (obj.metainfo.heading_lev_markup == 1) { + _ancestors_markup = [ + _ancestors_markup[0], + 0,0,0,0,0,0,0 + ]; + } + if (obj.metainfo.heading_lev_markup == 2) { + _ancestors_markup = [ + _ancestors_markup[0], + _ancestors_markup[1], + 0,0,0,0,0,0 + ]; + } + if (obj.metainfo.heading_lev_markup == 3) { + _ancestors_markup = [ + _ancestors_markup[0], + _ancestors_markup[1], + _ancestors_markup[2], + 0,0,0,0,0 + ]; + } + if (obj.metainfo.heading_lev_markup == 4) { + _ancestors_markup = [ + _ancestors_markup[0], + _ancestors_markup[1], + _ancestors_markup[2], + _ancestors_markup[3], + 0,0,0,0 + ]; + } + if (obj.metainfo.heading_lev_markup == 5) { + _ancestors_markup = [ + _ancestors_markup[0], + _ancestors_markup[1], + _ancestors_markup[2], + _ancestors_markup[3], + _ancestors_markup[4], + 0,0,0 + ]; + } + if (obj.metainfo.heading_lev_markup == 6) { + _ancestors_markup = [ + _ancestors_markup[0], + _ancestors_markup[1], + _ancestors_markup[2], + _ancestors_markup[3], + _ancestors_markup[4], + _ancestors_markup[5], + 0,0 + ]; + } + if (obj.metainfo.heading_lev_markup == 7) { + _ancestors_markup = [ + _ancestors_markup[0], + _ancestors_markup[1], + _ancestors_markup[2], + _ancestors_markup[3], + _ancestors_markup[4], + _ancestors_markup[5], + _ancestors_markup[6], + 0 + ]; + } + if (obj.metainfo.heading_lev_markup == 8) { + _ancestors_markup = [ + _ancestors_markup[0], + _ancestors_markup[1], + _ancestors_markup[2], + _ancestors_markup[3], + _ancestors_markup[4], + _ancestors_markup[5], + _ancestors_markup[6], + _ancestors_markup[7] + ]; + } + _ancestors_markup[obj.metainfo.heading_lev_markup] = obj.metainfo.ocn; + } + debug(ancestor_markup) { + writeln("marked up: ", _ancestors_markup); + } + return _ancestors_markup; + } + int[] _get_ancestors_collapsed(O)(O obj, ref int[] _ancestors_collapsed) { + if (obj.metainfo.is_a == "heading") { + if (obj.metainfo.heading_lev_collapsed == 1) { + _ancestors_collapsed = [ + _ancestors_collapsed[0], + 0,0,0,0,0,0,0 + ]; + } + if (obj.metainfo.heading_lev_collapsed == 2) { + _ancestors_collapsed = [ + _ancestors_collapsed[0], + _ancestors_collapsed[1], + 0,0,0,0,0,0 + ]; + } + if (obj.metainfo.heading_lev_collapsed == 3) { + _ancestors_collapsed = [ + _ancestors_collapsed[0], + _ancestors_collapsed[1], + _ancestors_collapsed[2], + 0,0,0,0,0 + ]; + } + if (obj.metainfo.heading_lev_collapsed == 4) { + _ancestors_collapsed = [ + _ancestors_collapsed[0], + _ancestors_collapsed[1], + _ancestors_collapsed[2], + _ancestors_collapsed[3], + 0,0,0,0 + ]; + } + if (obj.metainfo.heading_lev_collapsed == 5) { + _ancestors_collapsed = [ + _ancestors_collapsed[0], + _ancestors_collapsed[1], + _ancestors_collapsed[2], + _ancestors_collapsed[3], + _ancestors_collapsed[4], + 0,0,0 + ]; + } + if (obj.metainfo.heading_lev_collapsed == 6) { + _ancestors_collapsed = [ + _ancestors_collapsed[0], + _ancestors_collapsed[1], + _ancestors_collapsed[2], + _ancestors_collapsed[3], + _ancestors_collapsed[4], + _ancestors_collapsed[5], + 0,0 + ]; + } + if (obj.metainfo.heading_lev_collapsed == 7) { + _ancestors_collapsed = [ + _ancestors_collapsed[0], + _ancestors_collapsed[1], + _ancestors_collapsed[2], + _ancestors_collapsed[3], + _ancestors_collapsed[4], + _ancestors_collapsed[5], + _ancestors_collapsed[6], + 0 + ]; + } + if (obj.metainfo.heading_lev_collapsed == 8) { + _ancestors_collapsed = [ + _ancestors_collapsed[0], + _ancestors_collapsed[1], + _ancestors_collapsed[2], + _ancestors_collapsed[3], + _ancestors_collapsed[4], + _ancestors_collapsed[5], + _ancestors_collapsed[6], + _ancestors_collapsed[7] + ]; + } + _ancestors_collapsed[obj.metainfo.heading_lev_collapsed] = obj.metainfo.ocn; + } + debug(ancestor_collapsed) { + writeln("collapsed: ", _ancestors_collapsed); + } + return _ancestors_collapsed; + } + /+ multiple 1~ levels, loop through document body +/ + if (the_document_body_section.length > 1) { + int[] _ancestors_markup = [0,0,0,0,0,0,0,0]; + int[][] _ancestors_markup_; + _ancestors_markup = [1,0,0,0,0,0,0,0]; + _ancestors_markup_ ~= _ancestors_markup; + int[] _ancestors_collapsed = [0,0,0,0,0,0,0,0]; + int[][] _ancestors_collapsed_; + _ancestors_collapsed = [1,0,0,0,0,0,0,0]; + _ancestors_collapsed_ ~= _ancestors_collapsed; + foreach (ref obj; the_document_body_section) { + if (obj.metainfo.is_a == "heading") { + obj.metainfo.markedup_ancestors = _get_ancestors_markup(obj, _ancestors_markup); + } + } + debug(ancestors) { + writeln("ancestors markup o_n: ", obj.metainfo.markedup_ancestors); + writeln("ancestors collapsed o_n: ", obj.metainfo.markedup_ancestors); + } + } if (the_endnotes_section.length > 1) { html_segnames ~= "endnotes"; html_segnames_ptr = html_segnames_ptr_cntr; @@ -1453,16 +1644,16 @@ template SiSUdocAbstraction() { || (opt_action.sqlite_discrete) || (opt_action.sqlite_update) || (opt_action.postgresql)) { - obj = obj_dom_structure_set_markup_tags(obj, dom_markedup, obj.metainfo.heading_lev_markup); - obj = obj_dom_set_collapsed_tags(obj, dom_collapsed, obj.metainfo.heading_lev_collapsed); + obj = obj_dom_structure_set_markup_tags(obj, dom_structure_markedup_tags_status, obj.metainfo.heading_lev_markup); + obj = obj_dom_set_collapsed_tags(obj, dom_structure_collapsed_tags_status, obj.metainfo.heading_lev_collapsed); } obj = obj_heading_ancestors(obj, lv_ancestors_txt); } } if (the_table_of_contents_section["scroll"].length > 1) { /+ scroll +/ - dom_markedup_buffer = dom_markedup.dup; - dom_collapsed_buffer = dom_collapsed.dup; + dom_structure_markedup_tags_status_buffer = dom_structure_markedup_tags_status.dup; + dom_structure_collapsed_tags_status_buffer = dom_structure_collapsed_tags_status.dup; foreach (ref obj; the_table_of_contents_section["scroll"]) { if (obj.metainfo.is_a == "heading") { if (obj.metainfo.heading_lev_markup <= 4) { @@ -1481,15 +1672,15 @@ template SiSUdocAbstraction() { || (opt_action.sqlite_discrete) || (opt_action.sqlite_update) || (opt_action.postgresql)) { - obj = obj_dom_structure_set_markup_tags(obj, dom_markedup, obj.metainfo.heading_lev_markup); - obj = obj_dom_set_collapsed_tags(obj, dom_collapsed, obj.metainfo.heading_lev_collapsed); + obj = obj_dom_structure_set_markup_tags(obj, dom_structure_markedup_tags_status, obj.metainfo.heading_lev_markup); + obj = obj_dom_set_collapsed_tags(obj, dom_structure_collapsed_tags_status, obj.metainfo.heading_lev_collapsed); } obj = obj_heading_ancestors(obj, lv_ancestors_txt); } } /+ seg +/ - dom_markedup = dom_markedup_buffer.dup; - dom_collapsed = dom_collapsed_buffer.dup; + dom_structure_markedup_tags_status = dom_structure_markedup_tags_status_buffer.dup; + dom_structure_collapsed_tags_status = dom_structure_collapsed_tags_status_buffer.dup; foreach (ref obj; the_table_of_contents_section["seg"]) { if (obj.metainfo.is_a == "heading") { debug(dom) { @@ -1507,8 +1698,8 @@ template SiSUdocAbstraction() { || (opt_action.html_scroll) || (opt_action.html_seg) || (opt_action.epub)) { - obj = obj_dom_structure_set_markup_tags(obj, dom_markedup, obj.metainfo.heading_lev_markup); - obj = obj_dom_set_collapsed_tags(obj, dom_collapsed, obj.metainfo.heading_lev_collapsed); + obj = obj_dom_structure_set_markup_tags(obj, dom_structure_markedup_tags_status, obj.metainfo.heading_lev_markup); + obj = obj_dom_set_collapsed_tags(obj, dom_structure_collapsed_tags_status, obj.metainfo.heading_lev_collapsed); } obj = obj_heading_ancestors(obj, lv_ancestors_txt); } @@ -1541,8 +1732,8 @@ template SiSUdocAbstraction() { || (opt_action.sqlite_discrete) || (opt_action.sqlite_update) || (opt_action.postgresql)) { - obj = obj_dom_structure_set_markup_tags(obj, dom_markedup, obj.metainfo.heading_lev_markup); - obj = obj_dom_set_collapsed_tags(obj, dom_collapsed, obj.metainfo.heading_lev_collapsed); + obj = obj_dom_structure_set_markup_tags(obj, dom_structure_markedup_tags_status, obj.metainfo.heading_lev_markup); + obj = obj_dom_set_collapsed_tags(obj, dom_structure_collapsed_tags_status, obj.metainfo.heading_lev_collapsed); } obj = obj_heading_ancestors(obj, lv_ancestors_txt); } else if (obj.metainfo.is_a == "para") { @@ -1554,10 +1745,10 @@ template SiSUdocAbstraction() { auto images=uniq(_images.sort()); /+ optional only one 1~ level +/ if (the_endnotes_section.length > 1) { - dom_markedup_buffer = dom_markedup.dup; - dom_collapsed_buffer = dom_collapsed.dup; - dom_markedup = dom_markedup_buffer.dup; - dom_collapsed = dom_collapsed_buffer.dup; + dom_structure_markedup_tags_status_buffer = dom_structure_markedup_tags_status.dup; + dom_structure_collapsed_tags_status_buffer = dom_structure_collapsed_tags_status.dup; + dom_structure_markedup_tags_status = dom_structure_markedup_tags_status_buffer.dup; + dom_structure_collapsed_tags_status = dom_structure_collapsed_tags_status_buffer.dup; foreach (ref obj; the_endnotes_section) { if (obj.metainfo.is_a == "heading") { debug(dom) { @@ -1584,8 +1775,8 @@ template SiSUdocAbstraction() { || (opt_action.sqlite_discrete) || (opt_action.sqlite_update) || (opt_action.postgresql)) { - obj = obj_dom_structure_set_markup_tags(obj, dom_markedup, obj.metainfo.heading_lev_markup); - obj = obj_dom_set_collapsed_tags(obj, dom_collapsed, obj.metainfo.heading_lev_collapsed); + obj = obj_dom_structure_set_markup_tags(obj, dom_structure_markedup_tags_status, obj.metainfo.heading_lev_markup); + obj = obj_dom_set_collapsed_tags(obj, dom_structure_collapsed_tags_status, obj.metainfo.heading_lev_collapsed); } obj = obj_heading_ancestors(obj, lv_ancestors_txt); } @@ -1619,8 +1810,8 @@ template SiSUdocAbstraction() { || (opt_action.sqlite_discrete) || (opt_action.sqlite_update) || (opt_action.postgresql)) { - obj = obj_dom_structure_set_markup_tags(obj, dom_markedup, obj.metainfo.heading_lev_markup); - obj = obj_dom_set_collapsed_tags(obj, dom_collapsed, obj.metainfo.heading_lev_collapsed); + obj = obj_dom_structure_set_markup_tags(obj, dom_structure_markedup_tags_status, obj.metainfo.heading_lev_markup); + obj = obj_dom_set_collapsed_tags(obj, dom_structure_collapsed_tags_status, obj.metainfo.heading_lev_collapsed); } obj = obj_heading_ancestors(obj, lv_ancestors_txt); } else if (obj.metainfo.is_a == "glossary") { @@ -1657,8 +1848,8 @@ template SiSUdocAbstraction() { || (opt_action.sqlite_discrete) || (opt_action.sqlite_update) || (opt_action.postgresql)) { - obj = obj_dom_structure_set_markup_tags(obj, dom_markedup, obj.metainfo.heading_lev_markup); - obj = obj_dom_set_collapsed_tags(obj, dom_collapsed, obj.metainfo.heading_lev_collapsed); + obj = obj_dom_structure_set_markup_tags(obj, dom_structure_markedup_tags_status, obj.metainfo.heading_lev_markup); + obj = obj_dom_set_collapsed_tags(obj, dom_structure_collapsed_tags_status, obj.metainfo.heading_lev_collapsed); } obj = obj_heading_ancestors(obj, lv_ancestors_txt); } else if (obj.metainfo.is_a == "bibliography") { @@ -1673,8 +1864,8 @@ template SiSUdocAbstraction() { int ocn_bidx_; if (the_bookindex_section["scroll"].length > 1) { /+ scroll +/ - dom_markedup_buffer = dom_markedup.dup; - dom_collapsed_buffer = dom_collapsed.dup; + dom_structure_markedup_tags_status_buffer = dom_structure_markedup_tags_status.dup; + dom_structure_collapsed_tags_status_buffer = dom_structure_collapsed_tags_status.dup; foreach (ref obj; the_bookindex_section["scroll"]) { if (obj.metainfo.is_a == "heading") { debug(dom) { @@ -1700,20 +1891,20 @@ template SiSUdocAbstraction() { || (opt_action.sqlite_discrete) || (opt_action.sqlite_update) || (opt_action.postgresql)) { - obj = obj_dom_structure_set_markup_tags(obj, dom_markedup, obj.metainfo.heading_lev_markup); - obj = obj_dom_set_collapsed_tags(obj, dom_collapsed, obj.metainfo.heading_lev_collapsed); + obj = obj_dom_structure_set_markup_tags(obj, dom_structure_markedup_tags_status, obj.metainfo.heading_lev_markup); + obj = obj_dom_set_collapsed_tags(obj, dom_structure_collapsed_tags_status, obj.metainfo.heading_lev_collapsed); } obj = obj_heading_ancestors(obj, lv_ancestors_txt); } else if (obj.metainfo.is_a == "bookindex") { - obj_cite_digits = ocn_emit(OCNstatus.bkidx); + obj_cite_digits = ocn_emit(OCNstatus.bkidx); obj.metainfo.ocn = obj_cite_digits.digit; obj.metainfo.o_n_book_index = obj_cite_digits.bkidx; obj.metainfo.object_number_type = OCNtype.bkidx; } } /+ seg +/ - dom_markedup = dom_markedup_buffer.dup; - dom_collapsed = dom_collapsed_buffer.dup; + dom_structure_markedup_tags_status = dom_structure_markedup_tags_status_buffer.dup; + dom_structure_collapsed_tags_status = dom_structure_collapsed_tags_status_buffer.dup; foreach (ref obj; the_bookindex_section["seg"]) { if (obj.metainfo.is_a == "heading") { debug(dom) { @@ -1739,12 +1930,12 @@ template SiSUdocAbstraction() { || (opt_action.sqlite_discrete) || (opt_action.sqlite_update) || (opt_action.postgresql)) { - obj = obj_dom_structure_set_markup_tags(obj, dom_markedup, obj.metainfo.heading_lev_markup); - obj = obj_dom_set_collapsed_tags(obj, dom_collapsed, obj.metainfo.heading_lev_collapsed); + obj = obj_dom_structure_set_markup_tags(obj, dom_structure_markedup_tags_status, obj.metainfo.heading_lev_markup); + obj = obj_dom_set_collapsed_tags(obj, dom_structure_collapsed_tags_status, obj.metainfo.heading_lev_collapsed); } obj = obj_heading_ancestors(obj, lv_ancestors_txt); } else if (obj.metainfo.is_a == "bookindex") { - ocn_bidx_ = ++ocn_bkidx_; + ocn_bidx_ = ++ocn_bkidx_; obj.metainfo.o_n_book_index = ocn_bidx_; // FIX need to distinguish from regular ocn obj.metainfo.object_number_type = OCNtype.bkidx; } @@ -1782,8 +1973,8 @@ template SiSUdocAbstraction() { || (opt_action.sqlite_discrete) || (opt_action.sqlite_update) || (opt_action.postgresql)) { - obj = obj_dom_structure_set_markup_tags(obj, dom_markedup, obj.metainfo.heading_lev_markup); - obj = obj_dom_set_collapsed_tags(obj, dom_collapsed, obj.metainfo.heading_lev_collapsed); + obj = obj_dom_structure_set_markup_tags(obj, dom_structure_markedup_tags_status, obj.metainfo.heading_lev_markup); + obj = obj_dom_set_collapsed_tags(obj, dom_structure_collapsed_tags_status, obj.metainfo.heading_lev_collapsed); } obj = obj_heading_ancestors(obj, lv_ancestors_txt); } else if (obj.metainfo.is_a == "blurb") { @@ -1796,8 +1987,8 @@ template SiSUdocAbstraction() { /+ TODO - note create/insert heading object sole purpose eof close all open tags sort out: - - obj.metainfo.dom_markedup = dom_markedup; - - obj.metainfo.dom_collapsed = dom_collapsed; + - obj.metainfo.dom_structure_markedup_tags_status = dom_structure_markedup_tags_status; + - obj.metainfo.dom_structure_collapsed_tags_status = dom_structure_collapsed_tags_status; +/ comp_obj_heading_ = comp_obj_heading_.init; comp_obj_heading_.metainfo.is_of_part = "empty"; @@ -1812,10 +2003,10 @@ template SiSUdocAbstraction() { comp_obj_heading_.metainfo.heading_lev_collapsed = 9; comp_obj_heading_.metainfo.parent_ocn = 0; comp_obj_heading_.metainfo.parent_lev_markup = 0; - comp_obj_heading_.metainfo.dom_markedup = dom_markedup.dup; - comp_obj_heading_.metainfo.dom_collapsed = dom_collapsed.dup; - comp_obj_heading_ = obj_dom_structure_set_markup_tags(comp_obj_heading_, dom_markedup, 0); - comp_obj_heading_ = obj_dom_set_collapsed_tags(comp_obj_heading_, dom_collapsed, 0); + comp_obj_heading_.metainfo.dom_structure_markedup_tags_status = dom_structure_markedup_tags_status.dup; + comp_obj_heading_.metainfo.dom_structure_collapsed_tags_status = dom_structure_collapsed_tags_status.dup; + comp_obj_heading_ = obj_dom_structure_set_markup_tags(comp_obj_heading_, dom_structure_markedup_tags_status, 0); + comp_obj_heading_ = obj_dom_set_collapsed_tags(comp_obj_heading_, dom_structure_collapsed_tags_status, 0); comp_obj_heading_ = obj_heading_ancestors(comp_obj_heading_, lv_ancestors_txt); // the_dom_tail_section ~= comp_obj_heading_; // remove tail for now, decide on later auto document_the = [ @@ -1885,16 +2076,60 @@ template SiSUdocAbstraction() { destroy(html_segnames); destroy(bookindex_unordered_hashes); destroy(an_object); - obj_cite_digits = ocn_emit(OCNstatus.reset); - biblio_arr_json = []; - obj_cite_digit_ = 0; - html_segnames_ptr = 0; - html_segnames_ptr_cntr = 0; - content_non_header = "8"; - dom_markedup = [ 0, 0, 0, 0, 0, 0, 0, 0, 0,]; - dom_markedup_buffer = [ 0, 0, 0, 0, 0, 0, 0, 0, 0,]; - dom_collapsed = [ 0, 0, 0, 0, 0, 0, 0, 0, 0,]; - dom_collapsed_buffer = [ 0, 0, 0, 0, 0, 0, 0, 0, 0,]; + obj_cite_digits = ocn_emit(OCNstatus.reset); + biblio_arr_json = []; + obj_cite_digit_ = 0; + html_segnames_ptr = 0; + html_segnames_ptr_cntr = 0; + content_non_header = "8"; + dom_structure_markedup_tags_status = [ 0, 0, 0, 0, 0, 0, 0, 0, 0,]; + dom_structure_markedup_tags_status_buffer = [ 0, 0, 0, 0, 0, 0, 0, 0, 0,]; + dom_structure_collapsed_tags_status = [ 0, 0, 0, 0, 0, 0, 0, 0, 0,]; + dom_structure_collapsed_tags_status_buffer = [ 0, 0, 0, 0, 0, 0, 0, 0, 0,]; + debug(abstraction) { + foreach (part; sequenced_document_keys.scroll) { + foreach (ref obj; document_the[part]) { + debug(node_misc) { + if (obj.metainfo.is_a == "heading") { + writeln("heading ancestors text?: ", obj.tags.heading_ancestors_text); + } + } + debug(node_headings) { + if (obj.metainfo.is_a == "heading") { + writeln("---"); + writeln(obj.text); + writeln(" node: ", obj.metainfo.node); + writeln(" ocn: ", obj.metainfo.ocn); + writeln(" markedup heading lev: ", obj.metainfo.heading_lev_markup); + writeln(" collapsed heading lev ", obj.metainfo.heading_lev_collapsed); + writeln(" parent ocn: ", obj.metainfo.parent_ocn); + writeln(" parent lev: ", obj.metainfo.parent_lev_markup); + writeln(" markedup ancestors o_n: ", obj.metainfo.markedup_ancestors); + writeln(" dom markedup: ", obj.metainfo.dom_structure_markedup_tags_status); + writeln(" collapsed ancestors o_n: ", obj.metainfo.collapsed_ancestors); + writeln(" dom collapsed: ", obj.metainfo.dom_structure_collapsed_tags_status); + } + } + debug(node_all) { + writeln("---"); + if (obj.metainfo.is_a == "heading") { + writeln(obj.text); + } + writeln("node: ", obj.metainfo.node); + writeln("ocn: ", obj.metainfo.ocn); + writeln("markedup heading lev: ", obj.metainfo.heading_lev_markup); + writeln("collapsed heading lev ", obj.metainfo.heading_lev_collapsed); + writeln("markedup ancestors o_n: ", obj.metainfo.markedup_ancestors); + writeln("collapsed ancestors o_n: ", obj.metainfo.collapsed_ancestors); + writeln("dom markedup: ", obj.metainfo.dom_structure_markedup_tags_status); + writeln("dom collapsed: ", obj.metainfo.dom_structure_collapsed_tags_status); + writeln("parent ocn: ", obj.metainfo.parent_ocn); + writeln("parent lev: ", obj.metainfo.parent_lev_markup); + writeln("Node: ", obj.metainfo.ocn); + } + } + } + } auto t = tuple( document_the, sequenced_document_keys, @@ -5473,7 +5708,7 @@ template SiSUdocAbstraction() { comp_obj_location.tags.segment_anchor_tag = segment_anchor_tag.to!string; comp_obj_location.metainfo.parent_ocn = p_["object_number"]; comp_obj_location.metainfo.parent_lev_markup = p_["lev_markup_number"]; - debug(node) { + debug(_node) { if (lev_markup_number.match(rgx.levels_numbered_headings)) { writeln("x ", _node.to!string); } else { @@ -5638,7 +5873,7 @@ template SiSUdocAbstraction() { _comp_obj_heading_.has.inline_notes_reg = flag_notes_reg; _comp_obj_heading_.has.inline_notes_star = flag_notes_star; _comp_obj_heading_.has.inline_links = flag_links; - debug(node) { + debug(_node) { if (lev_markup_number.match(rgx.levels_numbered_headings)) { writeln("* ", _node.to!string); } diff --git a/src/sdp/meta/object_setter.d b/src/sdp/meta/object_setter.d index a928ec8..09ce2ee 100644 --- a/src/sdp/meta/object_setter.d +++ b/src/sdp/meta/object_setter.d @@ -99,50 +99,50 @@ template ObjectSetter() { } return _out; } - int[] dom_markedup = [ 0, 0, 0, 0, 0, 0, 0, 0,]; - int[] dom_collapsed = [ 0, 0, 0, 0, 0, 0, 0, 0,]; - int[] heading_ancestors = [ 0, 0, 0, 0, 0, 0, 0, 0,]; - int parent_lev_markup = 0; - int parent_ocn = 0; - int[] ancestors = []; + int[] markedup_ancestors = [ 0, 0, 0, 0, 0, 0, 0, 0,]; + int[] collapsed_ancestors = [ 0, 0, 0, 0, 0, 0, 0, 0,]; + int[] dom_structure_markedup_tags_status = [ 0, 0, 0, 0, 0, 0, 0, 0,]; + int[] dom_structure_collapsed_tags_status = [ 0, 0, 0, 0, 0, 0, 0, 0,]; + int parent_lev_markup = 0; + int parent_ocn = 0; } - struct DocObj_TxtAttrib_ { // attrib - int indent_base = 0; - int indent_hang = 0; - bool bullet = false; - string language = ""; // not implemented, consider + struct DocObj_TxtAttrib_ { // attrib + int indent_base = 0; + int indent_hang = 0; + bool bullet = false; + string language = ""; // not implemented, consider } - struct DocObj_Has_ { // has - bool inline_links = false; - bool inline_notes_reg = false; - bool inline_notes_star = false; - bool contains_image_without_dimensions = false; + struct DocObj_Has_ { // has + bool inline_links = false; + bool inline_notes_reg = false; + bool inline_notes_star = false; + bool contains_image_without_dimensions = false; } - struct DocObj_Table_ { // table - int number_of_columns = 0; - double[] column_widths = []; - string[] column_aligns = []; - bool heading = false; - bool walls = false; // not implemented + struct DocObj_Table_ { // table + int number_of_columns = 0; + double[] column_widths = []; + string[] column_aligns = []; + bool heading = false; + bool walls = false; // not implemented } - struct DocObj_CodeBlock_ { // code_block - string syntax = ""; + struct DocObj_CodeBlock_ { // code_block + string syntax = ""; } - struct DocObj_Pointer_ { // ptr - int doc_object = 0; - int html_segnames = 0; - int heading = 0; + struct DocObj_Pointer_ { // ptr + int doc_object = 0; + int html_segnames = 0; + int heading = 0; } - struct DocObj_Tags_ { // tags - string[] heading_ancestors_text = [ "", "", "", "", "", "", "", "", ]; - string segment_anchor_tag = ""; - string segname_prev = ""; - string segname_next = ""; - string[] lev4_subtoc = []; - string[] anchor_tags = []; + struct DocObj_Tags_ { // tags + string[] heading_ancestors_text = [ "", "", "", "", "", "", "", "", ]; // TODO redundant? see markedup and collapsed ancestors DONE + string segment_anchor_tag = ""; + string segname_prev = ""; + string segname_next = ""; + string[] lev4_subtoc = []; + string[] anchor_tags = []; } struct ObjGenericComposite { - string text = ""; + string text = ""; DocObj_MetaInfo_ metainfo; DocObj_TxtAttrib_ attrib; DocObj_Tags_ tags; diff --git a/src/sdp/output/epub3.d b/src/sdp/output/epub3.d index 0e864f7..dce1b0c 100644 --- a/src/sdp/output/epub3.d +++ b/src/sdp/output/epub3.d @@ -150,7 +150,7 @@ template outputEPub3() { string _txt = obj.text.replaceAll(rgx.inline_notes_al_gen, "").strip; foreach_reverse (n; 0 .. 7) { string k = n.to!string; - switch (obj.metainfo.dom_collapsed[n]) { + switch (obj.metainfo.dom_structure_collapsed_tags_status[n]) { case DomTags.close : toc ~= markup.indent_by_spaces_provided((n + 1), " ") ~ "" ~ "\n"; toc ~= markup.indent_by_spaces_provided(n, " ") ~ "" ~ "\n"; @@ -247,7 +247,7 @@ template outputEPub3() { string _txt = obj.text.replaceAll(rgx.inline_notes_al_gen, "").strip; string hashtag =(obj.metainfo.heading_lev_markup <= 4) ? "" : ("#" ~ obj.metainfo.ocn.to!string); foreach_reverse (k; 0 .. 7) { - switch (obj.metainfo.dom_markedup[k]) { + switch (obj.metainfo.dom_structure_markedup_tags_status[k]) { case DomTags.close : toc ~= "\n "; break; diff --git a/src/sdp/output/sqlite.d b/src/sdp/output/sqlite.d index 1aa578d..636fe6f 100644 --- a/src/sdp/output/sqlite.d +++ b/src/sdp/output/sqlite.d @@ -1031,9 +1031,9 @@ template SQLiteInsertDocObjectsLoop() { if ((doc_matters.opt.action.verbose)) { writeln( "markup: ", obj.metainfo.heading_lev_markup, - "> ", obj.metainfo.dom_markedup, + "> ", obj.metainfo.dom_structure_markedup_tags_status, "; collapsed: ", obj.metainfo.heading_lev_collapsed, - "> ", obj.metainfo.dom_collapsed, + "> ", obj.metainfo.dom_structure_collapsed_tags_status, "; ocn: ", obj.metainfo.ocn, " node: ", obj.metainfo.node, "; parent: ", obj.metainfo.parent_lev_markup, -- cgit v1.2.3