aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorRalph Amissah <ralph@amissah.com>2018-07-04 13:22:34 -0400
committerRalph Amissah <ralph@amissah.com>2019-04-10 15:14:15 -0400
commitab6a0ed892cf2e63c041318b71806ecee4e31ebe (patch)
tree1117b8dfd1e3f44aee939360f131160d536edca8
parentreconsider unecessary "return ref" (diff)
decendants
-rw-r--r--org/meta_abstraction.org148
-rw-r--r--org/meta_debugs.org39
-rw-r--r--src/sdp/meta/doc_debugs.d33
-rw-r--r--src/sdp/meta/metadoc_from_src.d135
-rw-r--r--src/sdp/meta/object_setter.d1
5 files changed, 332 insertions, 24 deletions
diff --git a/org/meta_abstraction.org b/org/meta_abstraction.org
index 384c8db..6b6ad9f 100644
--- a/org/meta_abstraction.org
+++ b/org/meta_abstraction.org
@@ -1977,6 +1977,7 @@ if (the_document_body_section.length > 1) {
foreach (ref obj; the_document_body_section) {
if (obj.metainfo.is_a == "heading") {
obj.metainfo.markedup_ancestors = _get_ancestors_markup(obj, _ancestors_markup);
+ obj.metainfo.collapsed_ancestors = _get_ancestors_collapsed(obj, _ancestors_collapsed);
}
}
debug(ancestors) {
@@ -2116,6 +2117,60 @@ Build here:
- next are not yet known for backmatter during the second pas
***** Methods
+****** decendants
+
+#+name: abs_post
+#+BEGIN_SRC d
+auto get_decendants(S)(S document_sections) {
+ int[string] _heading_ocn_decendants;
+ string[] _ocn_open_key = ["","","","","","","",""];
+ auto _doc_sect_length = document_sections.length - 1;
+ int _last_ocn;
+ foreach (_lg, ref obj; document_sections) { // TODO the_document_body_section
+ if (obj.metainfo.is_a == "heading") {
+ foreach (_dts_lv, dom_tag_status; obj.metainfo.dom_structure_markedup_tags_status) {
+ switch (dom_tag_status) {
+ case DomTags.none: break;
+ case DomTags.open:
+ _ocn_open_key[_dts_lv] = (obj.metainfo.ocn).to!string;
+ _heading_ocn_decendants[_ocn_open_key[_dts_lv]] = obj.metainfo.ocn;
+ break;
+ case DomTags.close:
+ if (_ocn_open_key[_dts_lv].empty) {
+ _ocn_open_key[_dts_lv] = "0";
+ }
+ _heading_ocn_decendants[_ocn_open_key[_dts_lv]] = obj.metainfo.ocn - 1;
+ _ocn_open_key[_dts_lv] = (0).to!string;
+ break;
+ case DomTags.close_and_open:
+ if (_ocn_open_key[_dts_lv].empty) {
+ _ocn_open_key[_dts_lv] = "0";
+ }
+ _heading_ocn_decendants[_ocn_open_key[_dts_lv]] = obj.metainfo.ocn - 1;
+ _ocn_open_key[_dts_lv] = (obj.metainfo.ocn).to!string;
+ _heading_ocn_decendants[_ocn_open_key[_dts_lv]] = obj.metainfo.ocn;
+ break;
+ case DomTags.open_still: break;
+ default: break;
+ }
+ }
+ }
+ if (obj.metainfo.ocn > 0) {
+ _last_ocn = obj.metainfo.ocn;
+ }
+ if (_lg == _doc_sect_length) {
+ _heading_ocn_decendants["1"] = _last_ocn; // close existing o_n key
+ }
+ }
+ Tuple!(int, int)[] pairs;
+ foreach (pair; _heading_ocn_decendants.byPair) {
+ pairs ~= tuple(pair[0].to!int, pair[1]);
+ // pairs ~= tuple(pair.key.to!int, pair.value);
+ }
+ return pairs.sort;
+}
+#+END_SRC
+
****** images: extract
#+name: abs_post
@@ -2591,6 +2646,98 @@ if (the_blurb_section.length > 1) {
}
#+END_SRC
+***** ↻ Loop sections: get decendants
+
+#+name: abs_post
+#+BEGIN_SRC d
+if (the_document_body_section.length > 1) {
+ auto pairs = get_decendants(
+ the_document_head_section ~
+ the_document_body_section ~
+ the_endnotes_section ~
+ the_glossary_section ~
+ the_bibliography_section ~
+ the_bookindex_section["scroll"] ~
+ the_blurb_section
+ );
+ foreach (ref obj; the_document_head_section) {
+ if (obj.metainfo.is_a == "heading") {
+ foreach (pair; pairs) {
+ if (obj.metainfo.ocn == pair[0]) {
+ obj.metainfo.last_decendant_ocn = pair[1];
+ }
+ }
+ }
+ }
+ if (the_document_body_section.length > 1) {
+ foreach (ref obj; the_document_body_section) {
+ if (obj.metainfo.is_a == "heading") {
+ foreach (pair; pairs) {
+ if (obj.metainfo.ocn == pair[0]) {
+ obj.metainfo.last_decendant_ocn = pair[1];
+ }
+ }
+ }
+ }
+ }
+ if (the_endnotes_section.length > 1) {
+ foreach (ref obj; the_endnotes_section) {
+ if (obj.metainfo.is_a == "heading") {
+ foreach (pair; pairs) {
+ if (obj.metainfo.ocn == pair[0]) {
+ obj.metainfo.last_decendant_ocn = pair[1];
+ }
+ }
+ }
+ }
+ }
+ if (the_glossary_section.length > 1) {
+ foreach (ref obj; the_glossary_section) {
+ if (obj.metainfo.is_a == "heading") {
+ foreach (pair; pairs) {
+ if (obj.metainfo.ocn == pair[0]) {
+ obj.metainfo.last_decendant_ocn = pair[1];
+ }
+ }
+ }
+ }
+ }
+ if (the_bibliography_section.length > 1) {
+ foreach (ref obj; the_bibliography_section) {
+ if (obj.metainfo.is_a == "heading") {
+ foreach (pair; pairs) {
+ if (obj.metainfo.ocn == pair[0]) {
+ obj.metainfo.last_decendant_ocn = pair[1];
+ }
+ }
+ }
+ }
+ }
+ if (the_bookindex_section["scroll"].length > 1) {
+ foreach (ref obj; the_bookindex_section["scroll"]) {
+ if (obj.metainfo.is_a == "heading") {
+ foreach (pair; pairs) {
+ if (obj.metainfo.ocn == pair[0]) {
+ obj.metainfo.last_decendant_ocn = pair[1];
+ }
+ }
+ }
+ }
+ }
+ if (the_blurb_section.length > 1) {
+ foreach (ref obj; the_blurb_section) {
+ if (obj.metainfo.is_a == "heading") {
+ foreach (pair; pairs) {
+ if (obj.metainfo.ocn == pair[0]) {
+ obj.metainfo.last_decendant_ocn = pair[1];
+ }
+ }
+ }
+ }
+ }
+}
+#+END_SRC
+
**** TODO update BUG?
#+name: abs_post
@@ -7613,6 +7760,7 @@ struct DocObj_MetaInfo_ { // metainfo
int[] dom_structure_collapsed_tags_status = [ 0, 0, 0, 0, 0, 0, 0, 0,];
int parent_lev_markup = 0;
int parent_ocn = 0;
+ int last_decendant_ocn = 0; // DONE
}
struct DocObj_TxtAttrib_ { // attrib
int indent_base = 0;
diff --git a/org/meta_debugs.org b/org/meta_debugs.org
index e34a95c..8542a32 100644
--- a/org/meta_debugs.org
+++ b/org/meta_debugs.org
@@ -115,18 +115,18 @@ debug(dumpdoc) {
__FILE__,
__LINE__,
);
- if (key.length > 0) {
- foreach (obj; contents[key]) {
- if (obj.metainfo.is_of_part != "empty") {
- writefln(
- "[%s][%s]\n%s",
- obj.object_number,
- obj.metainfo.is_a,
- obj.text
- );
- }
- }
- }
+ // if (key.length > 0) {
+ // foreach (obj; contents[key]) {
+ // if (obj.metainfo.is_of_part != "empty") {
+ // writefln(
+ // "[%s][%s]\n%s",
+ // obj.object_number,
+ // obj.metainfo.is_a,
+ // obj.text
+ // );
+ // }
+ // }
+ // }
}
#+END_SRC
@@ -362,6 +362,21 @@ debug(toc_nav_dom) {
}
#+END_SRC
+*** decendants
+
+#+name: meta_output_debugs
+#+BEGIN_SRC d
+debug(decendants) {
+ foreach (sect; doc_matters.xml.keys_seq.scroll) {
+ foreach (obj; contents[sect]) {
+ if (obj.metainfo.is_a == "heading") {
+ writeln(obj.metainfo.ocn, " .. ", obj.metainfo.last_decendant_ocn);
+ }
+ }
+ }
+}
+#+END_SRC
+
*** endnotes_section (seg & scroll) :endnotes:
**** endnotes
diff --git a/src/sdp/meta/doc_debugs.d b/src/sdp/meta/doc_debugs.d
index bc781ee..89ca3a7 100644
--- a/src/sdp/meta/doc_debugs.d
+++ b/src/sdp/meta/doc_debugs.d
@@ -59,18 +59,18 @@ template SiSUdebugs() {
__FILE__,
__LINE__,
);
- if (key.length > 0) {
- foreach (obj; contents[key]) {
- if (obj.metainfo.is_of_part != "empty") {
- writefln(
- "[%s][%s]\n%s",
- obj.object_number,
- obj.metainfo.is_a,
- obj.text
- );
- }
- }
- }
+ // if (key.length > 0) {
+ // foreach (obj; contents[key]) {
+ // if (obj.metainfo.is_of_part != "empty") {
+ // writefln(
+ // "[%s][%s]\n%s",
+ // obj.object_number,
+ // obj.metainfo.is_a,
+ // obj.text
+ // );
+ // }
+ // }
+ // }
}
debug(section_head) {
key="head";
@@ -170,6 +170,15 @@ template SiSUdebugs() {
}
}
}
+ debug(decendants) {
+ foreach (sect; doc_matters.xml.keys_seq.scroll) {
+ foreach (obj; contents[sect]) {
+ if (obj.metainfo.is_a == "heading") {
+ writeln(obj.metainfo.ocn, " .. ", obj.metainfo.last_decendant_ocn);
+ }
+ }
+ }
+ }
debug(section_endnotes) {
key="endnotes";
out_endnotes(contents, key);
diff --git a/src/sdp/meta/metadoc_from_src.d b/src/sdp/meta/metadoc_from_src.d
index 962fef9..f202b7c 100644
--- a/src/sdp/meta/metadoc_from_src.d
+++ b/src/sdp/meta/metadoc_from_src.d
@@ -1509,6 +1509,7 @@ template SiSUdocAbstraction() {
foreach (ref obj; the_document_body_section) {
if (obj.metainfo.is_a == "heading") {
obj.metainfo.markedup_ancestors = _get_ancestors_markup(obj, _ancestors_markup);
+ obj.metainfo.collapsed_ancestors = _get_ancestors_collapsed(obj, _ancestors_collapsed);
}
}
debug(ancestors) {
@@ -1577,6 +1578,54 @@ template SiSUdocAbstraction() {
}
html_segnames_ptr_cntr++;
}
+ auto get_decendants(S)(S document_sections) {
+ int[string] _heading_ocn_decendants;
+ string[] _ocn_open_key = ["","","","","","","",""];
+ auto _doc_sect_length = document_sections.length - 1;
+ int _last_ocn;
+ foreach (_lg, ref obj; document_sections) { // TODO the_document_body_section
+ if (obj.metainfo.is_a == "heading") {
+ foreach (_dts_lv, dom_tag_status; obj.metainfo.dom_structure_markedup_tags_status) {
+ switch (dom_tag_status) {
+ case DomTags.none: break;
+ case DomTags.open:
+ _ocn_open_key[_dts_lv] = (obj.metainfo.ocn).to!string;
+ _heading_ocn_decendants[_ocn_open_key[_dts_lv]] = obj.metainfo.ocn;
+ break;
+ case DomTags.close:
+ if (_ocn_open_key[_dts_lv].empty) {
+ _ocn_open_key[_dts_lv] = "0";
+ }
+ _heading_ocn_decendants[_ocn_open_key[_dts_lv]] = obj.metainfo.ocn - 1;
+ _ocn_open_key[_dts_lv] = (0).to!string;
+ break;
+ case DomTags.close_and_open:
+ if (_ocn_open_key[_dts_lv].empty) {
+ _ocn_open_key[_dts_lv] = "0";
+ }
+ _heading_ocn_decendants[_ocn_open_key[_dts_lv]] = obj.metainfo.ocn - 1;
+ _ocn_open_key[_dts_lv] = (obj.metainfo.ocn).to!string;
+ _heading_ocn_decendants[_ocn_open_key[_dts_lv]] = obj.metainfo.ocn;
+ break;
+ case DomTags.open_still: break;
+ default: break;
+ }
+ }
+ }
+ if (obj.metainfo.ocn > 0) {
+ _last_ocn = obj.metainfo.ocn;
+ }
+ if (_lg == _doc_sect_length) {
+ _heading_ocn_decendants["1"] = _last_ocn; // close existing o_n key
+ }
+ }
+ Tuple!(int, int)[] pairs;
+ foreach (pair; _heading_ocn_decendants.byPair) {
+ pairs ~= tuple(pair[0].to!int, pair[1]);
+ // pairs ~= tuple(pair.key.to!int, pair.value);
+ }
+ return pairs.sort;
+ }
string[] _images;
auto extract_images(S)(S content_block) {
string[] images_;
@@ -1984,6 +2033,92 @@ template SiSUdocAbstraction() {
}
}
}
+ if (the_document_body_section.length > 1) {
+ auto pairs = get_decendants(
+ the_document_head_section ~
+ the_document_body_section ~
+ the_endnotes_section ~
+ the_glossary_section ~
+ the_bibliography_section ~
+ the_bookindex_section["scroll"] ~
+ the_blurb_section
+ );
+ foreach (ref obj; the_document_head_section) {
+ if (obj.metainfo.is_a == "heading") {
+ foreach (pair; pairs) {
+ if (obj.metainfo.ocn == pair[0]) {
+ obj.metainfo.last_decendant_ocn = pair[1];
+ }
+ }
+ }
+ }
+ if (the_document_body_section.length > 1) {
+ foreach (ref obj; the_document_body_section) {
+ if (obj.metainfo.is_a == "heading") {
+ foreach (pair; pairs) {
+ if (obj.metainfo.ocn == pair[0]) {
+ obj.metainfo.last_decendant_ocn = pair[1];
+ }
+ }
+ }
+ }
+ }
+ if (the_endnotes_section.length > 1) {
+ foreach (ref obj; the_endnotes_section) {
+ if (obj.metainfo.is_a == "heading") {
+ foreach (pair; pairs) {
+ if (obj.metainfo.ocn == pair[0]) {
+ obj.metainfo.last_decendant_ocn = pair[1];
+ }
+ }
+ }
+ }
+ }
+ if (the_glossary_section.length > 1) {
+ foreach (ref obj; the_glossary_section) {
+ if (obj.metainfo.is_a == "heading") {
+ foreach (pair; pairs) {
+ if (obj.metainfo.ocn == pair[0]) {
+ obj.metainfo.last_decendant_ocn = pair[1];
+ }
+ }
+ }
+ }
+ }
+ if (the_bibliography_section.length > 1) {
+ foreach (ref obj; the_bibliography_section) {
+ if (obj.metainfo.is_a == "heading") {
+ foreach (pair; pairs) {
+ if (obj.metainfo.ocn == pair[0]) {
+ obj.metainfo.last_decendant_ocn = pair[1];
+ }
+ }
+ }
+ }
+ }
+ if (the_bookindex_section["scroll"].length > 1) {
+ foreach (ref obj; the_bookindex_section["scroll"]) {
+ if (obj.metainfo.is_a == "heading") {
+ foreach (pair; pairs) {
+ if (obj.metainfo.ocn == pair[0]) {
+ obj.metainfo.last_decendant_ocn = pair[1];
+ }
+ }
+ }
+ }
+ }
+ if (the_blurb_section.length > 1) {
+ foreach (ref obj; the_blurb_section) {
+ if (obj.metainfo.is_a == "heading") {
+ foreach (pair; pairs) {
+ if (obj.metainfo.ocn == pair[0]) {
+ obj.metainfo.last_decendant_ocn = pair[1];
+ }
+ }
+ }
+ }
+ }
+ }
/+ TODO
- note create/insert heading object sole purpose eof close all open tags
sort out:
diff --git a/src/sdp/meta/object_setter.d b/src/sdp/meta/object_setter.d
index a60d2b7..ed99b2a 100644
--- a/src/sdp/meta/object_setter.d
+++ b/src/sdp/meta/object_setter.d
@@ -73,6 +73,7 @@ template ObjectSetter() {
int[] dom_structure_collapsed_tags_status = [ 0, 0, 0, 0, 0, 0, 0, 0,];
int parent_lev_markup = 0;
int parent_ocn = 0;
+ int last_decendant_ocn = 0; // DONE
}
struct DocObj_TxtAttrib_ { // attrib
int indent_base = 0;