aboutsummaryrefslogtreecommitdiffhomepage
path: root/org/ao_abstract_doc_source.org
diff options
context:
space:
mode:
Diffstat (limited to 'org/ao_abstract_doc_source.org')
-rw-r--r--org/ao_abstract_doc_source.org680
1 files changed, 349 insertions, 331 deletions
diff --git a/org/ao_abstract_doc_source.org b/org/ao_abstract_doc_source.org
index 49f3016..4aa20be 100644
--- a/org/ao_abstract_doc_source.org
+++ b/org/ao_abstract_doc_source.org
@@ -178,7 +178,9 @@ ObjGenericComposite[] the_dom_tail_section;
string[string] an_object, processing;
string an_object_key;
string[] anchor_tags;
+string anchor_tag_;
string segment_anchor_tag_that_object_belongs_to;
+string segment_anchor_tag_that_object_belongs_to_uri;
auto note_section = NotesSection();
/+ enum +/
enum State { off, on }
@@ -223,6 +225,58 @@ 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,];
enum DomTags { none, open, close, close_and_open, open_still, }
+void heading_ancestors(O)(
+ auto ref O obj,
+ ref string[] lv_ancestors,
+) {
+ switch (obj.heading_lev_markup) {
+ case 0:
+ lv_ancestors[0] = to!string(obj.text);
+ foreach(k; 1..8) { // 1 .. 7 ?
+ lv_ancestors[k] = "";
+ }
+ goto default;
+ case 1:
+ lv_ancestors[1] = to!string(obj.text);
+ foreach(k; 2..8) {
+ lv_ancestors[k] = "";
+ }
+ goto default;
+ case 2:
+ lv_ancestors[2] = to!string(obj.text);
+ foreach(k; 3..8) {
+ lv_ancestors[k] = "";
+ }
+ goto default;
+ case 3:
+ lv_ancestors[3] = to!string(obj.text);
+ foreach(k; 4..8) {
+ lv_ancestors[k] = "";
+ }
+ goto default;
+ case 4:
+ lv_ancestors[4] = to!string(obj.text);
+ foreach(k; 5..8) {
+ lv_ancestors[k] = "";
+ }
+ goto default;
+ case 5:
+ lv_ancestors[5] = to!string(obj.text);
+ foreach(k; 6..8) {
+ lv_ancestors[k] = "";
+ }
+ goto default;
+ case 6:
+ lv_ancestors[6] = to!string(obj.text);
+ lv_ancestors[7] = "";
+ goto default;
+ case 7:
+ lv_ancestors[7] = to!string(obj.text);
+ goto default;
+ default:
+ obj.heading_ancestors_text = lv_ancestors.dup;
+ }
+}
auto dom_set_markup_tags(int[] dom, int lev) {
foreach (i; 0 .. 8) {
if (i < lev) {
@@ -356,6 +410,7 @@ string[string] obj_cite_number_poem = [
"start" : "",
"end" : ""
];
+string[] lv_ancestors = [ "", "", "", "", "", "", "", "", ];
int[string] lv = [
"lv" : State.off,
"h0" : State.off,
@@ -955,9 +1010,16 @@ if ((type["heading"] == State.on)
anchor_tags = substantive_object_and_anchor_tags_tuple[1];
if (to!int(an_object["lev_markup_number"]) == 4) {
segment_anchor_tag_that_object_belongs_to = anchor_tags[0];
+ segment_anchor_tag_that_object_belongs_to_uri = anchor_tags[0] ~ ".fnSuffix";
+ anchor_tag_ = anchor_tags[0];
+ } else if (to!int(an_object["lev_markup_number"]) > 4) {
+ segment_anchor_tag_that_object_belongs_to = anchor_tag_;
+ segment_anchor_tag_that_object_belongs_to_uri = anchor_tag_ ~ ".fnSuffix#" ~ to!string(obj_cite_number);
} else if (to!int(an_object["lev_markup_number"]) < 4) {
segment_anchor_tag_that_object_belongs_to = "";
+ segment_anchor_tag_that_object_belongs_to_uri = "";
}
+ /+ (incrementally build toc) table of contents here! +/
_anchor_tag=to!string(obj_cite_number);
the_table_of_contents_section = obj_im.table_of_contents_gather_headings(
an_object,
@@ -982,6 +1044,7 @@ if ((type["heading"] == State.on)
obj_cite_number, // int
cntr, // int
heading_ptr, // int
+ lv_ancestors, // string[]
an_object["is"], // string
html_segnames_ptr, // int
);
@@ -1125,9 +1188,9 @@ debug(endnotes) {
writefln(
"%s %s",
__LINE__,
- the_endnotes_section["seg"].length
+ the_endnotes_section.length
);
- foreach (o; the_endnotes_section["seg"]) {
+ foreach (o; the_endnotes_section) {
writeln(o);
}
}
@@ -1365,9 +1428,9 @@ comp_obj_toc.obj_cite_number = "";
comp_obj_toc.indent_hang = indent["hang_position"];
comp_obj_toc.indent_base = indent["base_position"];
comp_obj_toc.bullet = false;
-if (the_endnotes_section["seg"].length > 1) {
+if (the_endnotes_section.length > 1) {
toc_txt_ = format(
- "{ %s }../%s.fn_suffix",
+ "{ %s }../%s.fnSuffix",
"Endnotes",
"endnotes", // segment_anchor_tag_that_object_belongs_to
);
@@ -1375,19 +1438,9 @@ if (the_endnotes_section["seg"].length > 1) {
comp_obj_toc.text = to!string(toc_txt_).strip;
the_table_of_contents_section["seg"] ~= comp_obj_toc;
}
-if (the_endnotes_section["scroll"].length > 1) {
- toc_txt_ = format(
- "{ %s }#%s",
- "Endnotes",
- "endnotes", // _anchor_tag
- );
- toc_txt_= munge.url_links(toc_txt_);
- comp_obj_toc.text = to!string(toc_txt_).strip;
- the_table_of_contents_section["scroll"] ~= comp_obj_toc;
-}
if (the_glossary_section.length > 1) {
toc_txt_ = format(
- "{ %s }../%s.fn_suffixs",
+ "{ %s }../%s.fnSuffixs",
"Glossary",
"glossary", // segment_anchor_tag_that_object_belongs_to
);
@@ -1405,7 +1458,7 @@ if (the_glossary_section.length > 1) {
}
if (the_bibliography_section.length > 1){
toc_txt_ = format(
- "{ %s }../%s.fn_suffix",
+ "{ %s }../%s.fnSuffix",
"Bibliography",
"bibliography", // segment_anchor_tag_that_object_belongs_to
);
@@ -1424,7 +1477,7 @@ if (the_bibliography_section.length > 1){
}
if (the_bookindex_section["seg"].length > 1) {
toc_txt_ = format(
- "{ %s }../%s.fn_suffix",
+ "{ %s }../%s.fnSuffix",
"Book Index",
"bookindex", // segment_anchor_tag_that_object_belongs_to
);
@@ -1444,7 +1497,7 @@ if (the_bookindex_section["scroll"].length > 1) {
}
if (the_blurb_section.length > 1) {
toc_txt_ = format(
- "{ %s }../%s.fn_suffix",
+ "{ %s }../%s.fnSuffix",
"Blurb",
"blurb", // segment_anchor_tag_that_object_belongs_to
);
@@ -1470,6 +1523,16 @@ debug(toc) {
writeln(mkup.indent_by_spaces_provided(toc_linked_heading.indent_hang), toc_linked_heading.text);
}
}
+debug(tocscroll) {
+ writefln(
+ "%s %s",
+ __LINE__,
+ the_table_of_contents_section["seg"].length
+ );
+ foreach (toc_linked_heading; the_table_of_contents_section["scroll"]) {
+ writeln(mkup.indent_by_spaces_provided(toc_linked_heading.indent_hang), toc_linked_heading.text);
+ }
+}
#+END_SRC
**** doc head (separate document head from body, make space for toc)
@@ -1492,16 +1555,10 @@ it is quite neat to have all in one place as we have here:
#+name: abs_post
#+BEGIN_SRC d
-if (the_endnotes_section["scroll"].length > 1) {
+if (the_endnotes_section.length > 1) {
html_segnames ~= "endnotes";
html_segnames_ptr = html_segnames_ptr_cntr;
- foreach (ref section; the_endnotes_section["scroll"]) {
- if (section.heading_lev_markup == 4) {
- section.ptr_html_segnames = html_segnames_ptr;
- break;
- }
- }
- foreach (ref section; the_endnotes_section["seg"]) {
+ foreach (ref section; the_endnotes_section) {
if (section.heading_lev_markup == 4) {
section.ptr_html_segnames = html_segnames_ptr;
break;
@@ -1561,237 +1618,273 @@ if (the_blurb_section.length > 1) {
}
#+END_SRC
-**** loop: all segments (as needed) up to document heading 1~, lev4 html: segnames & subtoc, backmatter pointers
+**** loop: all objects structural relationships (sections, segments, objects)
-could optimise by
-- skipping second and third pass unless the output html seg or epub is being made!
+needed for DOM structure, segnames & subtoc, backmatter pointers
+
+if used minimally only for DOM structure, segnames, subtoc, could optimise by
+- skipping second and third pass unless the output html seg or epub is being
+ made!
+
+or could conveniently be used more extensively for ancestors as well (though
+this can be extracted earlier)
+
+Build here:
+- DOM structure
+- ancestors and decendants
+
+(as needed) up to document heading 1~, lev4 html:
during the third pass all previous and next segment names are known
next are not yet known for backmatter during the second pass
#+name: abs_post
#+BEGIN_SRC d
-if ((opt_action_bool["html"])
-|| (opt_action_bool["html_scroll"])
-|| (opt_action_bool["html_seg"])
-|| (opt_action_bool["epub"])) {
- foreach (ref obj; the_document_head_section) {
+foreach (ref obj; the_document_head_section) {
+ if (obj.is_a == "heading") {
+ debug(dom) {
+ writeln(obj.text);
+ }
+ if ((opt_action_bool["html"])
+ || (opt_action_bool["html_scroll"])
+ || (opt_action_bool["html_seg"])
+ || (opt_action_bool["epub"])) {
+ obj.dom_markedup = dom_set_markup_tags(dom_markedup, obj.heading_lev_markup).dup;
+ obj.dom_collapsed = dom_set_collapsed_tags(dom_collapsed, obj.heading_lev_collapsed).dup;
+ }
+ heading_ancestors(obj, lv_ancestors);
+ }
+}
+if (the_table_of_contents_section["scroll"].length > 1) {
+ dom_markedup_buffer = dom_markedup.dup;
+ dom_collapsed_buffer = dom_collapsed.dup;
+ foreach (ref obj; the_table_of_contents_section["scroll"]) {
+ if (obj.is_a == "heading") {
+ debug(dom) {
+ // writeln(obj.text);
+ }
+ if (obj.heading_lev_markup == 4) {
+ obj.segname_next = html_segnames[obj.ptr_html_segnames + 1];
+ assert(obj.segment_anchor_tag == html_segnames[obj.ptr_html_segnames]);
+ }
+ if ((opt_action_bool["html"])
+ || (opt_action_bool["html_scroll"])
+ || (opt_action_bool["html_seg"])
+ || (opt_action_bool["epub"])) {
+ obj.dom_markedup = dom_set_markup_tags(dom_markedup, obj.heading_lev_markup).dup;
+ obj.dom_collapsed = dom_set_collapsed_tags(dom_collapsed, obj.heading_lev_collapsed).dup;
+ }
+ heading_ancestors(obj, lv_ancestors);
+ }
+ }
+ dom_markedup = dom_markedup_buffer.dup;
+ dom_collapsed = dom_collapsed_buffer.dup;
+ foreach (ref obj; the_table_of_contents_section["seg"]) {
if (obj.is_a == "heading") {
debug(dom) {
writeln(obj.text);
}
- dom_markedup = dom_set_markup_tags(dom_markedup, obj.heading_lev_markup);
- obj.dom_markedup = dom_markedup.dup;
- dom_collapsed = dom_set_collapsed_tags(dom_collapsed, obj.heading_lev_collapsed);
- obj.dom_collapsed = dom_collapsed.dup;
+ if (obj.heading_lev_markup == 4) {
+ obj.segname_next = html_segnames[obj.ptr_html_segnames + 1];
+ assert(obj.segment_anchor_tag == html_segnames[obj.ptr_html_segnames]);
+ }
+ if ((opt_action_bool["html"])
+ || (opt_action_bool["html_scroll"])
+ || (opt_action_bool["html_seg"])
+ || (opt_action_bool["epub"])) {
+ obj.dom_markedup = dom_set_markup_tags(dom_markedup, obj.heading_lev_markup).dup;
+ obj.dom_collapsed = dom_set_collapsed_tags(dom_collapsed, obj.heading_lev_collapsed).dup;
+ }
+ heading_ancestors(obj, lv_ancestors);
}
}
- if (the_table_of_contents_section["scroll"].length > 1) {
- dom_markedup_buffer = dom_markedup.dup;
- dom_collapsed_buffer = dom_collapsed.dup;
- foreach (ref obj; the_table_of_contents_section["scroll"]) {
- if (obj.is_a == "heading") {
- debug(dom) {
- // writeln(obj.text);
- }
- if (obj.heading_lev_markup == 4) {
- obj.segname_next = html_segnames[obj.ptr_html_segnames + 1];
- assert(obj.segment_anchor_tag == html_segnames[obj.ptr_html_segnames]);
- }
- dom_markedup = dom_set_markup_tags(dom_markedup, obj.heading_lev_markup);
- obj.dom_markedup = dom_markedup.dup;
- dom_collapsed = dom_set_collapsed_tags(dom_collapsed, obj.heading_lev_collapsed);
- obj.dom_collapsed = dom_collapsed.dup;
- }
- }
- dom_markedup = dom_markedup_buffer.dup;
- dom_collapsed = dom_collapsed_buffer.dup;
- foreach (ref obj; the_table_of_contents_section["seg"]) {
- if (obj.is_a == "heading") {
- debug(dom) {
- writeln(obj.text);
- }
- if (obj.heading_lev_markup == 4) {
+}
+/+ multiple 1~ levels, loop through document body +/
+if (the_document_body_section.length > 1) {
+ foreach (ref obj; the_document_body_section) {
+ if (obj.is_a == "heading") {
+ debug(dom) {
+ writeln(obj.text);
+ }
+ if (obj.heading_lev_markup == 4) {
+ obj.lev4_subtoc = lev4_subtoc[obj.segment_anchor_tag];
+ obj.segname_prev = html_segnames[obj.ptr_html_segnames - 1];
+ if (html_segnames.length > obj.ptr_html_segnames + 1) {
obj.segname_next = html_segnames[obj.ptr_html_segnames + 1];
- assert(obj.segment_anchor_tag == html_segnames[obj.ptr_html_segnames]);
}
- dom_markedup = dom_set_markup_tags(dom_markedup, obj.heading_lev_markup);
- obj.dom_markedup = dom_markedup.dup;
- dom_collapsed = dom_set_collapsed_tags(dom_collapsed, obj.heading_lev_collapsed);
- obj.dom_collapsed = dom_collapsed.dup;
+ assert(obj.segment_anchor_tag == html_segnames[obj.ptr_html_segnames]);
}
+ if ((opt_action_bool["html"])
+ || (opt_action_bool["html_scroll"])
+ || (opt_action_bool["html_seg"])
+ || (opt_action_bool["epub"])) {
+ obj.dom_markedup = dom_set_markup_tags(dom_markedup, obj.heading_lev_markup).dup;
+ obj.dom_collapsed = dom_set_collapsed_tags(dom_collapsed, obj.heading_lev_collapsed).dup;
+ }
+ heading_ancestors(obj, lv_ancestors);
}
}
- /+ multiple 1~ levels, loop through document body +/
- if (the_document_body_section.length > 1) {
- foreach (ref obj; the_document_body_section) {
- if (obj.is_a == "heading") {
- debug(dom) {
- writeln(obj.text);
- }
- if (obj.heading_lev_markup == 4) {
- obj.lev4_subtoc = lev4_subtoc[obj.segment_anchor_tag];
- obj.segname_prev = html_segnames[obj.ptr_html_segnames - 1];
- if (html_segnames.length > obj.ptr_html_segnames + 1) {
- obj.segname_next = html_segnames[obj.ptr_html_segnames + 1];
- }
- assert(obj.segment_anchor_tag == html_segnames[obj.ptr_html_segnames]);
+}
+/+ 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;
+ foreach (ref obj; the_endnotes_section) {
+ if (obj.is_a == "heading") {
+ debug(dom) {
+ writeln(obj.text);
+ }
+ if (obj.heading_lev_markup == 4) {
+ obj.segname_prev = html_segnames[obj.ptr_html_segnames - 1];
+ if (html_segnames.length > obj.ptr_html_segnames + 1) {
+ obj.segname_next = html_segnames[obj.ptr_html_segnames + 1];
}
- dom_markedup = dom_set_markup_tags(dom_markedup, obj.heading_lev_markup);
- obj.dom_markedup = dom_markedup.dup;
- dom_collapsed = dom_set_collapsed_tags(dom_collapsed, obj.heading_lev_collapsed);
- obj.dom_collapsed = dom_collapsed.dup;
+ assert(obj.segment_anchor_tag == html_segnames[obj.ptr_html_segnames]);
+ }
+ if ((opt_action_bool["html"])
+ || (opt_action_bool["html_scroll"])
+ || (opt_action_bool["html_seg"])
+ || (opt_action_bool["epub"])) {
+ obj.dom_markedup = dom_set_markup_tags(dom_markedup, obj.heading_lev_markup).dup;
+ obj.dom_collapsed = dom_set_collapsed_tags(dom_collapsed, obj.heading_lev_collapsed).dup;
}
+ heading_ancestors(obj, lv_ancestors);
}
}
- /+ optional only one 1~ level +/
- if (the_endnotes_section["scroll"].length > 1) {
- dom_markedup_buffer = dom_markedup.dup;
- dom_collapsed_buffer = dom_collapsed.dup;
- foreach (ref obj; the_endnotes_section["scroll"]) {
- if (obj.is_a == "heading") {
- debug(dom) {
- }
- if (obj.heading_lev_markup == 4) {
- obj.segname_prev = html_segnames[obj.ptr_html_segnames - 1];
- if (html_segnames.length > obj.ptr_html_segnames + 1) {
- obj.segname_next = html_segnames[obj.ptr_html_segnames + 1];
- }
- assert(obj.segment_anchor_tag == html_segnames[obj.ptr_html_segnames]);
- }
- dom_markedup = dom_set_markup_tags(dom_markedup, obj.heading_lev_markup);
- obj.dom_markedup = dom_markedup.dup;
- dom_collapsed = dom_set_collapsed_tags(dom_collapsed, obj.heading_lev_collapsed);
- obj.dom_collapsed = dom_collapsed.dup;
- }
- }
- dom_markedup = dom_markedup_buffer.dup;
- dom_collapsed = dom_collapsed_buffer.dup;
- foreach (ref obj; the_endnotes_section["seg"]) {
- if (obj.is_a == "heading") {
- debug(dom) {
- writeln(obj.text);
- }
- if (obj.heading_lev_markup == 4) {
- obj.segname_prev = html_segnames[obj.ptr_html_segnames - 1];
- if (html_segnames.length > obj.ptr_html_segnames + 1) {
- obj.segname_next = html_segnames[obj.ptr_html_segnames + 1];
- }
- assert(obj.segment_anchor_tag == html_segnames[obj.ptr_html_segnames]);
+}
+/+ optional only one 1~ level +/
+if (the_glossary_section.length > 1) {
+ foreach (ref obj; the_glossary_section) {
+ if (obj.is_a == "heading") {
+ debug(dom) {
+ writeln(obj.text);
+ }
+ if (obj.heading_lev_markup == 4) {
+ obj.segname_prev = html_segnames[obj.ptr_html_segnames - 1];
+ if (html_segnames.length > obj.ptr_html_segnames + 1) {
+ obj.segname_next = html_segnames[obj.ptr_html_segnames + 1];
}
- dom_markedup = dom_set_markup_tags(dom_markedup, obj.heading_lev_markup);
- obj.dom_markedup = dom_markedup.dup;
- dom_collapsed = dom_set_collapsed_tags(dom_collapsed, obj.heading_lev_collapsed);
- obj.dom_collapsed = dom_collapsed.dup;
+ assert(obj.segment_anchor_tag == html_segnames[obj.ptr_html_segnames]);
+ }
+ if ((opt_action_bool["html"])
+ || (opt_action_bool["html_scroll"])
+ || (opt_action_bool["html_seg"])
+ || (opt_action_bool["epub"])) {
+ obj.dom_markedup = dom_set_markup_tags(dom_markedup, obj.heading_lev_markup).dup;
+ obj.dom_collapsed = dom_set_collapsed_tags(dom_collapsed, obj.heading_lev_collapsed).dup;
}
+ heading_ancestors(obj, lv_ancestors);
}
}
- /+ optional only one 1~ level +/
- if (the_glossary_section.length > 1) {
- foreach (ref obj; the_glossary_section) {
- if (obj.is_a == "heading") {
- debug(dom) {
- writeln(obj.text);
- }
- if (obj.heading_lev_markup == 4) {
- obj.segname_prev = html_segnames[obj.ptr_html_segnames - 1];
- if (html_segnames.length > obj.ptr_html_segnames + 1) {
- obj.segname_next = html_segnames[obj.ptr_html_segnames + 1];
- }
- assert(obj.segment_anchor_tag == html_segnames[obj.ptr_html_segnames]);
+}
+/+ optional only one 1~ level +/
+if (the_bibliography_section.length > 1) {
+ foreach (ref obj; the_bibliography_section) {
+ if (obj.is_a == "heading") {
+ debug(dom) {
+ writeln(obj.text);
+ }
+ if (obj.heading_lev_markup == 4) {
+ obj.segname_prev = html_segnames[obj.ptr_html_segnames - 1];
+ if (html_segnames.length > obj.ptr_html_segnames + 1) {
+ obj.segname_next = html_segnames[obj.ptr_html_segnames + 1];
}
- dom_markedup = dom_set_markup_tags(dom_markedup, obj.heading_lev_markup);
- obj.dom_markedup = dom_markedup.dup;
- dom_collapsed = dom_set_collapsed_tags(dom_collapsed, obj.heading_lev_collapsed);
- obj.dom_collapsed = dom_collapsed.dup;
+ assert(obj.segment_anchor_tag == html_segnames[obj.ptr_html_segnames]);
+ }
+ if ((opt_action_bool["html"])
+ || (opt_action_bool["html_scroll"])
+ || (opt_action_bool["html_seg"])
+ || (opt_action_bool["epub"])) {
+ obj.dom_markedup = dom_set_markup_tags(dom_markedup, obj.heading_lev_markup).dup;
+ obj.dom_collapsed = dom_set_collapsed_tags(dom_collapsed, obj.heading_lev_collapsed).dup;
}
+ heading_ancestors(obj, lv_ancestors);
}
}
- /+ optional only one 1~ level +/
- if (the_bibliography_section.length > 1) {
- foreach (ref obj; the_bibliography_section) {
- if (obj.is_a == "heading") {
- debug(dom) {
- writeln(obj.text);
- }
- if (obj.heading_lev_markup == 4) {
- obj.segname_prev = html_segnames[obj.ptr_html_segnames - 1];
- if (html_segnames.length > obj.ptr_html_segnames + 1) {
- obj.segname_next = html_segnames[obj.ptr_html_segnames + 1];
- }
- assert(obj.segment_anchor_tag == html_segnames[obj.ptr_html_segnames]);
+}
+/+ optional only one 1~ level +/
+if (the_bookindex_section["scroll"].length > 1) {
+ dom_markedup_buffer = dom_markedup.dup;
+ dom_collapsed_buffer = dom_collapsed.dup;
+ foreach (ref obj; the_bookindex_section["scroll"]) {
+ if (obj.is_a == "heading") {
+ debug(dom) {
+ // writeln(obj.text);
+ }
+ if (obj.heading_lev_markup == 4) {
+ obj.segname_prev = html_segnames[obj.ptr_html_segnames - 1];
+ if (html_segnames.length > obj.ptr_html_segnames + 1) {
+ obj.segname_next = html_segnames[obj.ptr_html_segnames + 1];
}
- dom_markedup = dom_set_markup_tags(dom_markedup, obj.heading_lev_markup);
- obj.dom_markedup = dom_markedup.dup;
- dom_collapsed = dom_set_collapsed_tags(dom_collapsed, obj.heading_lev_collapsed);
- obj.dom_collapsed = dom_collapsed.dup;
+ assert(obj.segment_anchor_tag == html_segnames[obj.ptr_html_segnames]);
}
+ if ((opt_action_bool["html"])
+ || (opt_action_bool["html_scroll"])
+ || (opt_action_bool["html_seg"])
+ || (opt_action_bool["epub"])) {
+ obj.dom_markedup = dom_set_markup_tags(dom_markedup, obj.heading_lev_markup).dup;
+ obj.dom_collapsed = dom_set_collapsed_tags(dom_collapsed, obj.heading_lev_collapsed).dup;
+ }
+ heading_ancestors(obj, lv_ancestors);
}
}
- /+ optional only one 1~ level +/
- if (the_bookindex_section["scroll"].length > 1) {
- dom_markedup_buffer = dom_markedup.dup;
- dom_collapsed_buffer = dom_collapsed.dup;
- foreach (ref obj; the_bookindex_section["scroll"]) {
- if (obj.is_a == "heading") {
- debug(dom) {
- // writeln(obj.text);
- }
- if (obj.heading_lev_markup == 4) {
- obj.segname_prev = html_segnames[obj.ptr_html_segnames - 1];
- if (html_segnames.length > obj.ptr_html_segnames + 1) {
- obj.segname_next = html_segnames[obj.ptr_html_segnames + 1];
- }
- assert(obj.segment_anchor_tag == html_segnames[obj.ptr_html_segnames]);
- }
- dom_markedup = dom_set_markup_tags(dom_markedup, obj.heading_lev_markup);
- obj.dom_markedup = dom_markedup.dup;
- dom_collapsed = dom_set_collapsed_tags(dom_collapsed, obj.heading_lev_collapsed);
- obj.dom_collapsed = dom_collapsed.dup;
- }
- }
- dom_markedup = dom_markedup_buffer.dup;
- dom_collapsed = dom_collapsed_buffer.dup;
- foreach (ref obj; the_bookindex_section["seg"]) {
- if (obj.is_a == "heading") {
- debug(dom) {
- writeln(obj.text);
- }
- if (obj.heading_lev_markup == 4) {
- obj.segname_prev = html_segnames[obj.ptr_html_segnames - 1];
- if (html_segnames.length > obj.ptr_html_segnames + 1) {
- obj.segname_next = html_segnames[obj.ptr_html_segnames + 1];
- }
- assert(obj.segment_anchor_tag == html_segnames[obj.ptr_html_segnames]);
+ dom_markedup = dom_markedup_buffer.dup;
+ dom_collapsed = dom_collapsed_buffer.dup;
+ foreach (ref obj; the_bookindex_section["seg"]) {
+ if (obj.is_a == "heading") {
+ debug(dom) {
+ writeln(obj.text);
+ }
+ if (obj.heading_lev_markup == 4) {
+ obj.segname_prev = html_segnames[obj.ptr_html_segnames - 1];
+ if (html_segnames.length > obj.ptr_html_segnames + 1) {
+ obj.segname_next = html_segnames[obj.ptr_html_segnames + 1];
}
- dom_markedup = dom_set_markup_tags(dom_markedup, obj.heading_lev_markup);
- obj.dom_markedup = dom_markedup.dup;
- dom_collapsed = dom_set_collapsed_tags(dom_collapsed, obj.heading_lev_collapsed);
- obj.dom_collapsed = dom_collapsed.dup;
+ assert(obj.segment_anchor_tag == html_segnames[obj.ptr_html_segnames]);
}
+ if ((opt_action_bool["html"])
+ || (opt_action_bool["html_scroll"])
+ || (opt_action_bool["html_seg"])
+ || (opt_action_bool["epub"])) {
+ obj.dom_markedup = dom_set_markup_tags(dom_markedup, obj.heading_lev_markup).dup;
+ obj.dom_collapsed = dom_set_collapsed_tags(dom_collapsed, obj.heading_lev_collapsed).dup;
+ }
+ heading_ancestors(obj, lv_ancestors);
}
}
- /+ optional only one 1~ level +/
- if (the_blurb_section.length > 1) {
- foreach (ref obj; the_blurb_section) {
- if (obj.is_a == "heading") {
- debug(dom) {
- writeln(obj.text);
- }
- if (obj.heading_lev_markup == 4) {
- obj.segname_prev = html_segnames[obj.ptr_html_segnames - 1];
- if (html_segnames.length > obj.ptr_html_segnames + 1) {
- obj.segname_next = html_segnames[obj.ptr_html_segnames + 1];
- }
- assert(obj.segment_anchor_tag == html_segnames[obj.ptr_html_segnames]);
+}
+/+ optional only one 1~ level +/
+if (the_blurb_section.length > 1) {
+ foreach (ref obj; the_blurb_section) {
+ if (obj.is_a == "heading") {
+ debug(dom) {
+ writeln(obj.text);
+ }
+ if (obj.heading_lev_markup == 4) {
+ obj.segname_prev = html_segnames[obj.ptr_html_segnames - 1];
+ if (html_segnames.length > obj.ptr_html_segnames + 1) {
+ obj.segname_next = html_segnames[obj.ptr_html_segnames + 1];
}
- dom_markedup = dom_set_markup_tags(dom_markedup, obj.heading_lev_markup);
- obj.dom_markedup = dom_markedup.dup;
- dom_collapsed = dom_set_collapsed_tags(dom_collapsed, obj.heading_lev_collapsed);
- obj.dom_collapsed = dom_collapsed.dup;
+ assert(obj.segment_anchor_tag == html_segnames[obj.ptr_html_segnames]);
+ }
+ if ((opt_action_bool["html"])
+ || (opt_action_bool["html_scroll"])
+ || (opt_action_bool["html_seg"])
+ || (opt_action_bool["epub"])) {
+ obj.dom_markedup = dom_set_markup_tags(dom_markedup, obj.heading_lev_markup).dup;
+ obj.dom_collapsed = dom_set_collapsed_tags(dom_collapsed, obj.heading_lev_collapsed).dup;
}
+ heading_ancestors(obj, lv_ancestors);
}
}
+ /+ TODO
+ - note create/insert heading object sole purpose eof close all open tags
+ sort out:
+ - obj.dom_markedup = dom_markedup;
+ - obj.dom_collapsed = dom_collapsed;
+ +/
dom_markedup = dom_set_markup_tags(dom_markedup, 0);
dom_collapsed = dom_set_collapsed_tags(dom_collapsed, 0);
comp_obj_heading_ = comp_obj_heading_.init;
@@ -1824,8 +1917,7 @@ auto document_the = [
/+ substantive/body: +/
"body": the_document_body_section,
/+ backmatter: +/
- "endnotes_seg": the_endnotes_section["seg"],
- "endnotes_scroll": the_endnotes_section["scroll"],
+ "endnotes": the_endnotes_section,
"glossary": the_glossary_section,
"bibliography": the_bibliography_section,
"bookindex_scroll": the_bookindex_section["scroll"],
@@ -3792,7 +3884,7 @@ struct ObjInlineMarkup {
"hang_position" : 0,
"base_position" : 0,
];
- toc_txt_ = "{ Table of Contents }../toc.fn_suffix";
+ toc_txt_ = "{ Table of Contents }../toc.fnSuffix";
toc_txt_= munge.url_links(toc_txt_);
comp_obj_toc.indent_hang = indent["hang_position"];
comp_obj_toc.indent_base = indent["base_position"];
@@ -3816,7 +3908,7 @@ struct ObjInlineMarkup {
break;
case 4:
toc_txt_ = format(
- "{ %s }../%s.fn_suffix",
+ "{ %s }../%s.fnSuffix",
heading_toc_,
segment_anchor_tag_that_object_belongs_to,
);
@@ -3833,12 +3925,12 @@ struct ObjInlineMarkup {
break;
case 5: .. case 7:
toc_txt_ = format(
- "{ %s }../%s.fn_suffix#%s",
+ "{ %s }../%s.fnSuffix#%s",
heading_toc_,
segment_anchor_tag_that_object_belongs_to,
_anchor_tag,
);
- subtoc_txt_ = format( // 5 .. 7
+ subtoc_txt_ = format(
"{ %s }#%s",
heading_toc_,
_anchor_tag,
@@ -4609,7 +4701,7 @@ struct BookIndexReportSection {
bi_tmp_scroll ~= munge.url_links(" {" ~ ref_ ~ "}#" ~ go ~ ", ");
bi_tmp_seg ~= (segment_anchor_tag_that_object_belongs_to.empty)
? munge.url_links(" {" ~ ref_ ~ "}#" ~ go ~ ", ")
- : munge.url_links(" {" ~ ref_ ~ "}../" ~ segment_anchor_tag_that_object_belongs_to ~ ".fn_suffix#" ~ go ~ ", ");
+ : munge.url_links(" {" ~ ref_ ~ "}../" ~ segment_anchor_tag_that_object_belongs_to ~ ".fnSuffix#" ~ go ~ ", ");
}
bi_tmp_scroll ~= " \\\\\n ";
bi_tmp_seg ~= " \\\\\n ";
@@ -4626,7 +4718,7 @@ struct BookIndexReportSection {
bi_tmp_scroll ~= munge.url_links(" {" ~ ref_ ~ "}#" ~ go ~ ", ");
bi_tmp_seg ~= (segment_anchor_tag_that_object_belongs_to.empty)
? munge.url_links(" {" ~ ref_ ~ "}#" ~ go ~ ", ")
- : munge.url_links(" {" ~ ref_ ~ "}../" ~ segment_anchor_tag_that_object_belongs_to ~ ".fn_suffix#" ~ go ~ ", ");
+ : munge.url_links(" {" ~ ref_ ~ "}../" ~ segment_anchor_tag_that_object_belongs_to ~ ".fnSuffix#" ~ go ~ ", ");
}
bi_tmp_scroll ~= " \\\\\n ";
bi_tmp_seg ~= " \\\\\n ";
@@ -4721,25 +4813,21 @@ struct NotesSection {
) {
debug(endnotes_build) {
writeln(
- "{^{", m.captures[1], ".}^}../", segment_anchor_tag_that_object_belongs_to, ".fn_suffix#noteref_\n ", m.captures[1], " ",
+ "{^{", m.captures[1], ".}^}../", segment_anchor_tag_that_object_belongs_to, ".fnSuffix#noteref_\n ", m.captures[1], " ",
m.captures[2]); // sometimes need segment name (segmented html & epub)
}
// TODO NEXT you need anchor for segments at this point ->
object_notes["anchor"] ~= "#note_" ~ m.captures[1] ~ "』";
- object_notes["seg"] ~= (segment_anchor_tag_that_object_belongs_to.empty)
+ object_notes["notes"] ~= (segment_anchor_tag_that_object_belongs_to.empty)
? (munge.url_links(
"{^{" ~ m.captures[1] ~ ".}^}#noteref_" ~
m.captures[1]) ~ " " ~ m.captures[2] ~ "』"
)
: (munge.url_links(
- "{^{" ~ m.captures[1] ~ ".}^}../" ~ segment_anchor_tag_that_object_belongs_to ~ ".fn_suffix#noteref_" ~
+ "{^{" ~ m.captures[1] ~ ".}^}../" ~
+ segment_anchor_tag_that_object_belongs_to ~ ".fnSuffix#noteref_" ~
m.captures[1]) ~ " " ~ m.captures[2] ~ "』"
);
- object_notes["scroll"] ~=
- munge.url_links(
- "{^{" ~ m.captures[1] ~ ".}^}#noteref_" ~
- m.captures[1]
- ) ~ " " ~ m.captures[2] ~ "』";
}
return object_notes;
}
@@ -4755,12 +4843,10 @@ struct NotesSection {
body {
string[][string] endnotes_;
if (object_notes.length > 1) {
- endnotes_["seg"] = (split(object_notes["seg"], rgx.break_string))[0..$-1];
- endnotes_["scroll"] = (split(object_notes["scroll"], rgx.break_string))[0..$-1];
+ endnotes_["notes"] = (split(object_notes["notes"], rgx.break_string))[0..$-1];
endnotes_["anchor"] = (split(object_notes["anchor"], rgx.break_string))[0..$-1];
} else {
- endnotes_["seg"] = [];
- endnotes_["scroll"] = [];
+ endnotes_["notes"] = [];
endnotes_["anchor"] = [];
}
return endnotes_;
@@ -4779,14 +4865,14 @@ struct NotesSection {
}
body {
mixin SiSUnode;
- ObjGenericComposite[][string] the_endnotes_section;
+ ObjGenericComposite[] the_endnotes_section;
auto endnotes_ = gathered_notes();
string type_is;
string lev, lev_markup_number, lev_collapsed_number;
string attrib;
int[string] indent;
ObjGenericComposite comp_obj_heading_;
- if ((endnotes_["seg"].length > 0)
+ if ((endnotes_["notes"].length > 0)
&& (opt_action_bool["backmatter"] && opt_action_bool["section_endnotes"])) {
comp_obj_heading_ = comp_obj_heading_.init;
comp_obj_heading_.use = "backmatter";
@@ -4800,8 +4886,7 @@ struct NotesSection {
comp_obj_heading_.heading_lev_collapsed = 1;
comp_obj_heading_.parent_ocn = 1;
comp_obj_heading_.parent_lev_markup = 0;
- the_endnotes_section["seg"] ~= comp_obj_heading_;
- the_endnotes_section["scroll"] ~= comp_obj_heading_;
+ the_endnotes_section ~= comp_obj_heading_;
++obj_cite_number;
++mkn;
comp_obj_heading_ = comp_obj_heading_.init;
@@ -4818,8 +4903,7 @@ struct NotesSection {
comp_obj_heading_.parent_ocn = 1;
comp_obj_heading_.parent_lev_markup = 0;
comp_obj_heading_.anchor_tags = ["endnotes"];
- the_endnotes_section["seg"] ~= comp_obj_heading_;
- the_endnotes_section["scroll"] ~= comp_obj_heading_;
+ the_endnotes_section ~= comp_obj_heading_;
++obj_cite_number;
++mkn;
} else {
@@ -4835,8 +4919,7 @@ struct NotesSection {
comp_obj_heading_.heading_lev_collapsed = 1;
comp_obj_heading_.parent_ocn = 1;
comp_obj_heading_.parent_lev_markup = 0;
- the_endnotes_section["seg"] ~= comp_obj_heading_;
- the_endnotes_section["scroll"] ~= comp_obj_heading_;
+ the_endnotes_section ~= comp_obj_heading_;
}
if (opt_action_bool["backmatter"] && opt_action_bool["section_endnotes"]) {
ObjGenericComposite comp_obj_endnote_;
@@ -4849,21 +4932,13 @@ struct NotesSection {
comp_obj_endnote_.indent_hang = 0;
comp_obj_endnote_.indent_base = 0;
comp_obj_endnote_.bullet = false;
- foreach (i, endnote; endnotes_["seg"]) {
+ foreach (i, endnote; endnotes_["notes"]) {
auto m = (matchFirst(endnote, rgx.note_ref));
string notenumber = to!string(m.captures[1]);
string anchor_tag = "note_" ~ notenumber;
comp_obj_endnote_.anchor_tags ~= [ endnotes_["anchor"][i] ]; // fix
comp_obj_endnote_.text = endnote.strip;
- the_endnotes_section["seg"] ~= comp_obj_endnote_;
- }
- foreach (i, endnote; endnotes_["scroll"]) {
- auto m = (matchFirst(endnote, rgx.note_ref));
- string notenumber = to!string(m.captures[1]);
- string anchor_tag = "note_" ~ notenumber;
- comp_obj_endnote_.anchor_tags ~= [ endnotes_["anchor"][i] ]; // fix
- comp_obj_endnote_.text = endnote.strip;
- the_endnotes_section["scroll"] ~= comp_obj_endnote_;
+ the_endnotes_section ~= comp_obj_endnote_;
}
}
auto t = tuple(the_endnotes_section, obj_cite_number);
@@ -5076,6 +5151,7 @@ struct NodeStructureMetadata {
int obj_cite_number_,
int cntr_,
int ptr_,
+ string[] lv_ancestors,
string is_,
int html_segnames_ptr,
)
@@ -5177,22 +5253,23 @@ struct NodeStructureMetadata {
break;
}
ObjGenericComposite _comp_obj_heading_;
- _comp_obj_heading_ = _comp_obj_heading_.init;
- _comp_obj_heading_.use = "body";
- _comp_obj_heading_.is_of = "para";
- _comp_obj_heading_.is_a = "heading";
- _comp_obj_heading_.text = to!string(_text).strip;
- _comp_obj_heading_.ocn = obj_cite_number_;
- _comp_obj_heading_.obj_cite_number = (obj_cite_number==0) ? "" : to!string(obj_cite_number);
- _comp_obj_heading_.segment_anchor_tag = to!string(segment_anchor_tag);
- _comp_obj_heading_.marked_up_level = lev;
- _comp_obj_heading_.heading_lev_markup = (!(lev_markup_number.empty) ? to!int(lev_markup_number) : 0);
- _comp_obj_heading_.heading_lev_collapsed = (!(lev_collapsed_number.empty) ? to!int(lev_collapsed_number) : 0);
- _comp_obj_heading_.parent_ocn = p_["obj_cite_number"];
- _comp_obj_heading_.parent_lev_markup = p_["lev_markup_number"];
- _comp_obj_heading_.ptr_doc_object = cntr_;
- _comp_obj_heading_.ptr_html_segnames = ((lev_markup_number == "4") ? html_segnames_ptr : 0);
- _comp_obj_heading_.ptr_heading = ptr_;
+ _comp_obj_heading_ = _comp_obj_heading_.init;
+ _comp_obj_heading_.use = "body";
+ _comp_obj_heading_.is_of = "para";
+ _comp_obj_heading_.is_a = "heading"; // _node_heading_.is_a = is_; // check whether needed, constant???
+ _comp_obj_heading_.text = to!string(_text).strip;
+ _comp_obj_heading_.ocn = obj_cite_number_;
+ _comp_obj_heading_.obj_cite_number = (obj_cite_number==0) ? "" : to!string(obj_cite_number);
+ _comp_obj_heading_.segment_anchor_tag = to!string(segment_anchor_tag);
+ _comp_obj_heading_.marked_up_level = lev;
+ _comp_obj_heading_.heading_lev_markup = (!(lev_markup_number.empty) ? to!int(lev_markup_number) : 0);
+ _comp_obj_heading_.heading_lev_collapsed = (!(lev_collapsed_number.empty) ? to!int(lev_collapsed_number) : 0);
+ _comp_obj_heading_.parent_ocn = p_["obj_cite_number"];
+ _comp_obj_heading_.parent_lev_markup = p_["lev_markup_number"];
+ _comp_obj_heading_.heading_ancestors_text = lv_ancestors;
+ _comp_obj_heading_.ptr_doc_object = cntr_;
+ _comp_obj_heading_.ptr_html_segnames = ((lev_markup_number == "4") ? html_segnames_ptr : 0);
+ _comp_obj_heading_.ptr_heading = ptr_;
debug(node) {
if (match(lev_markup_number, rgx.levels_numbered_headings)) {
writeln("* ", to!string(_node));
@@ -5506,6 +5583,7 @@ struct ObjGenericComposite {
int heading_lev_collapsed = 9;
int[] heading_closes_lev_collapsed = [];
int[] heading_closes_lev_markup = [];
+ string[] heading_ancestors_text = [ "", "", "", "", "", "", "", "", ];
int heading_array_ptr = 0;
int ptr_doc_object = 0;
int ptr_html_segnames = 0;
@@ -5514,8 +5592,8 @@ struct ObjGenericComposite {
int heading_array_ptr_segments = 0;
string[] lev4_subtoc = [];
string[string][string] node;
- int[] dom_markedup = [ 0, 0, 0, 0, 0, 0, 0, 0,];
- int[] dom_collapsed = [ 0, 0, 0, 0, 0, 0, 0, 0,];
+ int[] dom_markedup = [ 0, 0, 0, 0, 0, 0, 0, 0,];
+ int[] dom_collapsed = [ 0, 0, 0, 0, 0, 0, 0, 0,];
}
#+END_SRC
@@ -5527,63 +5605,3 @@ struct TheObjects {
ObjGenericComposite[] oca;
}
#+END_SRC
-
-* Notes
-** abstract document structure
-
-#+BEGIN_SRC d
-auto document_abstract_objects = (
- "head": the_document_head_section, // split from rest of content
- "toc_seg": the_table_of_contents_section["seg"], // table of contents for seg
- "toc_scroll": the_table_of_contents_section["scroll"], // table of contents for scroll
- "body": the_document_body_section,
- "endnotes_seg": the_endnotes_section["seg"],
- "endnotes_scroll": the_endnotes_section["scroll"],
- "glossary": the_glossary_section,
- "bibliography": the_bibliography_section,
- "bookindex_scroll": the_bookindex_section["scroll"],
- "bookindex_seg": the_bookindex_section["seg"],
- "blurb": the_blurb_section,
-);
-#+END_SRC
-
-** TODO work on
-
-- bespoke struct for sisu objects to replace JSON strings
-- book index *sort* fix (Aa-Zz instead of A-Za-z)
-- determine what goes in node info
- - understand collapsed level
-- convert file utf8 for processing from to utf32
-
-- general concepts
- - ranges
- - templates
- - unitest?
-
-|---------------------+------------------------------------------+------------------------+--------|
-| header | sisu /header markup/ | markup | |
-| - metadata | | | |
-| - make instructions | | | |
-|---------------------+------------------------------------------+------------------------+--------|
-| table of contents | markup of headings | (regular content) | output |
-|---------------------+------------------------------------------+------------------------+--------|
-| substantive content | sisu /content markup/ | markup | output |
-| | headings (providing document structure), | (regular content) | |
-| | paragraphs, blocks | | |
-| | blocks (code, poem, group, table) | | |
-|---------------------+------------------------------------------+------------------------+--------|
-| endnotes | markup within substantive content | markup | output |
-| | (extracted from sisu /content markup/) | (from regular content) | |
-|---------------------+------------------------------------------+------------------------+--------|
-| glossary | identify special section | markup | output |
-| | regular /content markup/ | | |
-|---------------------+------------------------------------------+------------------------+--------|
-| bibliography | identify section, | markup (special) | output |
-| | special /bibliography markup/ | | |
-|---------------------+------------------------------------------+------------------------+--------|
-| book index | extracted from markup attached to | markup | output |
-| | related substantive content objects | | |
-| | (special tags in sisu /content markup/) | (from regular content) | |
-|---------------------+------------------------------------------+------------------------+--------|
-| metadata | | (from regular header) | output |
-|---------------------+------------------------------------------+------------------------+--------|