diff options
Diffstat (limited to 'org/ao_abstract_doc_source.org')
-rw-r--r-- | org/ao_abstract_doc_source.org | 539 |
1 files changed, 494 insertions, 45 deletions
diff --git a/org/ao_abstract_doc_source.org b/org/ao_abstract_doc_source.org index c4733cc..49f3016 100644 --- a/org/ao_abstract_doc_source.org +++ b/org/ao_abstract_doc_source.org @@ -174,6 +174,7 @@ mixin InternalMarkup; auto rgx = Rgx(); ObjGenericComposite[][string] the_table_of_contents_section; ObjGenericComposite[] the_document_head_section, the_document_body_section, the_bibliography_section, the_glossary_section, the_blurb_section; +ObjGenericComposite[] the_dom_tail_section; string[string] an_object, processing; string an_object_key; string[] anchor_tags; @@ -204,10 +205,10 @@ int bib_entry; /+ counters +/ int cntr, previous_count, previous_length; int[string] line_occur; -int verse_line, heading_ptr; -string[] html_segnames=[]; +string[] html_segnames=["toc"]; int html_segnames_ptr=0; int html_segnames_ptr_cntr=0; +int verse_line, heading_ptr; /+ paragraph attributes +/ int[string] indent; bool bullet = true; @@ -217,6 +218,89 @@ auto obj_att = ObjAttributes(); /+ ocn +/ int obj_cite_number, obj_cite_number_; 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,]; +enum DomTags { none, open, close, close_and_open, open_still, } +auto dom_set_markup_tags(int[] dom, int lev) { + foreach (i; 0 .. 8) { + if (i < lev) { + if (dom[i] == DomTags.open + || dom[i] == DomTags.close_and_open + ) { + dom[i] = DomTags.open_still; + } else if (dom[i] == DomTags.close) { + dom[i] = DomTags.none; + } + } else if (i == lev) { + if (lev == 0 + && dom[i] == DomTags.open_still + ) { + dom[i] = DomTags.close; + } else if (dom[i] == DomTags.open + || dom[i] == DomTags.open_still + || dom[i] == DomTags.close_and_open + ) { + dom[i] = DomTags.close_and_open; + } else { + dom[i] = DomTags.open; + } + } else if (i > lev) { + if (dom[i] == DomTags.close) { + dom[i] = DomTags.none; + } else if (dom[i] == DomTags.open + || dom[i] == DomTags.open_still + || dom[i] == DomTags.close_and_open + ) { + dom[i] = DomTags.close; + } + } + } + debug(dom) { + writeln(lev, ": ", dom); + } + return dom; +} +auto dom_set_collapsed_tags(int[] dom, int lev) { + foreach (i; 0 .. 8) { + if (i < lev) { + if (dom[i] == DomTags.open + || dom[i] == DomTags.close_and_open + ) { + dom[i] = DomTags.open_still; + } else if (dom[i] == DomTags.close) { + dom[i] = DomTags.none; + } + } else if (i == lev) { + if (lev == 0 + && dom[i] == DomTags.open_still + ) { + dom[i] = DomTags.close; + } else if (dom[i] == DomTags.open + || dom[i] == DomTags.open_still + || dom[i] == DomTags.close_and_open + ) { + dom[i] = DomTags.close_and_open; + } else { + dom[i] = DomTags.open; + } + } else if (i > lev) { + if (dom[i] == DomTags.close) { + dom[i] = DomTags.none; + } else if (dom[i] == DomTags.open + || dom[i] == DomTags.open_still + || dom[i] == DomTags.close_and_open + ) { + dom[i] = DomTags.close; + } + } + } + debug(dom) { + writeln(lev, ": ", dom); + } + return dom; +} int ocn_emit(int ocn_status_flag) { return object_citation_number.ocn_emitter(ocn_status_flag); } @@ -319,7 +403,7 @@ string toc_txt_; an_object["glossary_nugget"] = ""; an_object["blurb_nugget"] = ""; comp_obj_heading_ = comp_obj_heading_.init; -comp_obj_heading_.use = "body"; +comp_obj_heading_.use = "frontmatter"; comp_obj_heading_.is_of = "para"; comp_obj_heading_.is_a = "heading"; comp_obj_heading_.text = "Table of Contents"; @@ -328,17 +412,20 @@ comp_obj_heading_.obj_cite_number = ""; comp_obj_heading_.segment_anchor_tag = "toc"; comp_obj_heading_.marked_up_level = "1"; comp_obj_heading_.heading_lev_markup = 4; -comp_obj_heading_.heading_lev_collapsed = 2; +comp_obj_heading_.heading_lev_collapsed = 1; comp_obj_heading_.parent_ocn = 1; comp_obj_heading_.parent_lev_markup = 0; +comp_obj_heading_.ptr_html_segnames = html_segnames_ptr; comp_obj_heading_.anchor_tags = ["toc"]; -auto toc_head = comp_obj_heading_; +auto toc_head = comp_obj_heading_; +html_segnames_ptr_cntr++; the_table_of_contents_section = [ "seg": [toc_head], "scroll": [toc_head], ]; auto mkup = InlineMarkup(); auto munge = ObjInlineMarkupMunge(); +string[][string] lev4_subtoc; #+END_SRC ** _2. loop: process document body_ [+6] :loop: @@ -393,9 +480,8 @@ continue; #+END_SRC **** non code objects (other blocks or regular text) [+4] :non_code: - ***** in section (biblio, glossary, blurb) (block group) [+1] :block:active: -****** DONE within block group: biblio :biblio: +****** within section: biblio :biblio: #+name: abs_in_loop_body_non_code_obj #+BEGIN_SRC d @@ -418,7 +504,7 @@ if ((matchFirst(line, rgx.heading_biblio) continue; #+END_SRC -****** within section: glossary :glossary: +****** within section: glossary :glossary: if there is a glossary section you need to: - extract it @@ -480,7 +566,7 @@ if there is a glossary section you need to: comp_obj_heading_.parent_ocn = 1; comp_obj_heading_.parent_lev_markup = 0; comp_obj_heading_.anchor_tags = ["glossary"]; - the_glossary_section ~= comp_obj_heading_; + the_glossary_section ~= comp_obj_heading_; // } else if (matchFirst(line, rgx.heading)) { // _heading_matched_(line, line_occur, an_object, an_object_key, lv, collapsed_lev, type, dochead_meta_aa); // levels? } else { @@ -502,7 +588,7 @@ if there is a glossary section you need to: continue; #+END_SRC -****** within section: blurb :blurb: +****** within section: blurb :blurb: if there is a blurb section you need to: - extract it @@ -588,8 +674,8 @@ if there is a blurb section you need to: comp_obj_para.is_of = "para"; comp_obj_para.is_a = "blurb"; comp_obj_para.text = to!string(line).strip; - comp_obj_para.ocn = obj_cite_number; - comp_obj_para.obj_cite_number = (obj_cite_number==0) ? "" : to!string(obj_cite_number); + comp_obj_para.ocn = 0; + comp_obj_para.obj_cite_number = ""; comp_obj_para.indent_hang = indent["hang_position"]; comp_obj_para.indent_base = indent["base_position"]; comp_obj_para.bullet = bullet; @@ -600,8 +686,8 @@ if there is a blurb section you need to: continue; #+END_SRC -***** in block group [+1] :block:active: -****** within block group: poem :poem: +***** in blocks [+1] :block:active: +****** within block: poem :poem: #+name: abs_in_loop_body_non_code_obj #+BEGIN_SRC d @@ -611,7 +697,7 @@ if there is a blurb section you need to: continue; #+END_SRC -****** within block group: group :group: +****** within block: group :group: #+name: abs_in_loop_body_non_code_obj #+BEGIN_SRC d @@ -622,7 +708,7 @@ if there is a blurb section you need to: continue; #+END_SRC -****** within block group: block :block: +****** within block: block :block: #+name: abs_in_loop_body_non_code_obj #+BEGIN_SRC d @@ -632,7 +718,7 @@ if there is a blurb section you need to: continue; #+END_SRC -****** within block group: quote :quote: +****** within block: quote :quote: #+name: abs_in_loop_body_non_code_obj #+BEGIN_SRC d @@ -642,7 +728,7 @@ if there is a blurb section you need to: continue; #+END_SRC -****** within block group: table :table: +****** within block: table :table: #+name: abs_in_loop_body_non_code_obj #+BEGIN_SRC d @@ -653,7 +739,6 @@ if there is a blurb section you need to: #+END_SRC ***** not identified as being within block group (could still be, or not) [+3] - ****** assert #+name: abs_in_loop_body_open_block_obj_assert @@ -879,6 +964,7 @@ if ((type["heading"] == State.on) dochead_make_aa, segment_anchor_tag_that_object_belongs_to, _anchor_tag, + lev4_subtoc, the_table_of_contents_section, ); if (an_object["lev_markup_number"] == "4") { @@ -1025,8 +1111,8 @@ debug(objectrelated2) { // check // obj_im.obj_inline_markup_and_anchor_tags("doc_end_reset", an_object_key, "", dochead_make_aa); #+END_SRC -*** document sections -**** endnotes section (scroll & seg) :endnotes: +*** tie up preparation of document sections +**** endnotes section (scroll & seg) :endnotes: #+name: abs_post #+BEGIN_SRC d @@ -1047,7 +1133,7 @@ debug(endnotes) { } #+END_SRC -**** glossary section? +**** no glossary section? :glossary: #+name: abs_post #+BEGIN_SRC d @@ -1064,7 +1150,7 @@ if (an_object["glossary_nugget"].length == 0) { comp_obj_heading_.heading_lev_collapsed = 1; comp_obj_heading_.parent_ocn = 1; comp_obj_heading_.parent_lev_markup = 0; - the_glossary_section ~= comp_obj_heading_; + the_glossary_section ~= comp_obj_heading_; } else { writeln("gloss"); } @@ -1075,7 +1161,7 @@ debug(glossary) { } #+END_SRC -**** [#B] bibliography section (objects) :bibliography: +**** bibliography section (objects) :bibliography: #+name: abs_post #+BEGIN_SRC d @@ -1211,13 +1297,13 @@ auto biblio_entry_tags_jsonstr = `{ "id" : "" }`; // is: book, article, magazine, newspaper, blog, other -**** [#B] bookindex section (scroll & seg) :book:index: +**** bookindex section (scroll & seg) :book:index: #+name: abs_post #+BEGIN_SRC d auto bi = BookIndexReportSection(); auto bi_tuple = - bi.bookindex_build_section( + bi.bookindex_build_abstraction_section( bookindex_unordered_hashes, obj_cite_number, segment_anchor_tag_that_object_belongs_to, @@ -1233,7 +1319,7 @@ debug(bookindex) { // bookindex } #+END_SRC -**** blurb section? +**** no blurb section? :blurb: #+name: abs_post #+BEGIN_SRC d @@ -1245,13 +1331,13 @@ if (an_object["blurb_nugget"].length == 0) { comp_obj_heading_.text = "(skip) there is no Blurb section"; comp_obj_heading_.ocn = 0; comp_obj_para.obj_cite_number = ""; - comp_obj_heading_.segment_anchor_tag = "bibliography"; - comp_obj_heading_.marked_up_level = "1"; - comp_obj_heading_.heading_lev_markup = 4; - comp_obj_heading_.heading_lev_collapsed = 2; + comp_obj_heading_.segment_anchor_tag = ""; + comp_obj_heading_.marked_up_level = "B"; + comp_obj_heading_.heading_lev_markup = 1; + comp_obj_heading_.heading_lev_collapsed = 1; comp_obj_heading_.parent_ocn = 1; comp_obj_heading_.parent_lev_markup = 0; - the_blurb_section ~= comp_obj_heading_; + the_blurb_section ~= comp_obj_heading_; } else { writeln("blurb"); } @@ -1262,17 +1348,16 @@ debug(blurb) { } #+END_SRC -**** [#B] toc, table of contents section (scroll & seg) :contents: +**** toc backmatter, table of contents backmatter (scroll & seg) :contents: #+name: abs_post #+BEGIN_SRC d - indent=[ "hang_position" : 1, "base_position" : 1, ]; comp_obj_toc = comp_obj_toc.init; -comp_obj_toc.use = "body"; +comp_obj_toc.use = "frontmatter"; comp_obj_toc.is_of = "para"; comp_obj_toc.is_a = "toc"; comp_obj_toc.ocn = 0; @@ -1387,12 +1472,351 @@ debug(toc) { } #+END_SRC -*** [#B] the document :document: +**** doc head (separate document head from body, make space for toc) #+name: abs_post #+BEGIN_SRC d the_document_head_section ~= the_document_body_section[0]; the_document_body_section=the_document_body_section[1..$]; +#+END_SRC + +**** loop: backmatter loop up to lev4: html_segnames, set backmatter pointers + +could optimise by +- skipping second and third pass unless the output html seg or epub is being made! +NOTE there are issues attempting to do this on first pass +- as + - backmatter is created out of sequence and + - it is not certain which are present +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) { + 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"]) { + if (section.heading_lev_markup == 4) { + section.ptr_html_segnames = html_segnames_ptr; + break; + } + } + html_segnames_ptr_cntr++; +} +if (the_glossary_section.length > 1) { + html_segnames ~= "glossary"; + html_segnames_ptr = html_segnames_ptr_cntr; + foreach (ref section; the_glossary_section) { + if (section.heading_lev_markup == 4) { + section.ptr_html_segnames = html_segnames_ptr; + break; + } + } + html_segnames_ptr_cntr++; +} +if (the_bibliography_section.length > 1) { + html_segnames ~= "bibliography"; + html_segnames_ptr = html_segnames_ptr_cntr; + foreach (ref section; the_bibliography_section) { + if (section.heading_lev_markup == 4) { + section.ptr_html_segnames = html_segnames_ptr; + break; + } + } + html_segnames_ptr_cntr++; +} +if (the_bookindex_section["scroll"].length > 1) { + html_segnames ~= "bookindex"; + html_segnames_ptr = html_segnames_ptr_cntr; + foreach (ref section; the_bookindex_section["scroll"]) { + if (section.heading_lev_markup == 4) { + section.ptr_html_segnames = html_segnames_ptr; + break; + } + } + foreach (ref section; the_bookindex_section["seg"]) { + if (section.heading_lev_markup == 4) { + section.ptr_html_segnames = html_segnames_ptr; + break; + } + } + html_segnames_ptr_cntr++; +} +if (the_blurb_section.length > 1) { + html_segnames ~= "blurb"; + html_segnames_ptr = html_segnames_ptr_cntr; + foreach (ref section; the_blurb_section) { + if (section.heading_lev_markup == 4) { + section.ptr_html_segnames = html_segnames_ptr; + break; + } + } + html_segnames_ptr_cntr++; +} +#+END_SRC + +**** loop: all segments (as needed) up to document heading 1~, lev4 html: segnames & subtoc, backmatter pointers + +could optimise by +- skipping second and third pass unless the output html seg or epub is being made! + +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) { + 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 (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) { + 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; + } + } + } + /+ 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; + } + } + } + /+ 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]); + } + 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; + } + } + } + /+ 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]); + } + 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; + } + } + } + /+ 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]); + } + 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; + } + } + } + /+ 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_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; + } + } + } + /+ 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]); + } + 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_set_markup_tags(dom_markedup, 0); + dom_collapsed = dom_set_collapsed_tags(dom_collapsed, 0); + comp_obj_heading_ = comp_obj_heading_.init; + comp_obj_heading_.use = "empty"; + comp_obj_heading_.is_of = "para"; + comp_obj_heading_.is_a = "heading"; + // comp_obj_heading_.text = "(skip) this is the DOM tail"; + comp_obj_heading_.ocn = 0; + comp_obj_para.obj_cite_number = ""; + comp_obj_heading_.segment_anchor_tag = ""; + comp_obj_heading_.marked_up_level = ""; + comp_obj_heading_.heading_lev_markup = 9; + comp_obj_heading_.heading_lev_collapsed = 9; + comp_obj_heading_.parent_ocn = 0; + comp_obj_heading_.parent_lev_markup = 0; + comp_obj_heading_.dom_markedup = dom_markedup.dup; + comp_obj_heading_.dom_collapsed = dom_collapsed.dup; + the_dom_tail_section ~= comp_obj_heading_; +} +#+END_SRC + +*** [#B] the document :document: + +#+name: abs_post +#+BEGIN_SRC d auto document_the = [ "head": the_document_head_section, "toc_seg": the_table_of_contents_section["seg"], @@ -1407,6 +1831,8 @@ auto document_the = [ "bookindex_scroll": the_bookindex_section["scroll"], "bookindex_seg": the_bookindex_section["seg"], "blurb": the_blurb_section, + /+ dom tail only +/ + "tail": the_dom_tail_section, ]; #+END_SRC @@ -2772,7 +3198,7 @@ auto _heading_matched_( rgx.variable_doc_title, (dochead_meta_aa["title"]["full"] ~ ",")); an_object[an_object_key]=replaceFirst(an_object[an_object_key], rgx.variable_doc_author, dochead_meta_aa["creator"]["author"]); - collapsed_lev["h0"] = 1; + collapsed_lev["h0"] = 0; an_object["lev_collapsed_number"] = to!string(collapsed_lev["h0"]); lv["lv"] = DocStructMarkupHeading.h_sect_A; @@ -3201,7 +3627,7 @@ struct ObjInlineMarkupMunge { } #+END_SRC -***** object inline markup :markup:inline: +***** toc, tags, object inline markup :markup:inline: ****** open #+name: ao_emitters_obj_inline_markup @@ -3282,7 +3708,7 @@ struct ObjInlineMarkup { } #+END_SRC -****** table of contents objects :markup:inline: +****** toc, table of contents build, gather headings :markup:inline: #+name: ao_emitters_obj_inline_markup_table_of_contents #+BEGIN_SRC d @@ -3303,6 +3729,7 @@ struct ObjInlineMarkup { string[string][string] dochead_make_aa, string segment_anchor_tag_that_object_belongs_to, string _anchor_tag, + ref string[][string] lev4_subtoc, ObjGenericComposite[][string] the_table_of_contents_section, ) in { } @@ -3311,7 +3738,7 @@ struct ObjInlineMarkup { char[] heading_toc_ = to!(char[])(obj_["body_nugget"].dup.strip); heading_toc_ = _clean_heading_toc_(heading_toc_); auto attrib=""; - string toc_txt_; + string toc_txt_, subtoc_txt_; int[string] indent; if (to!int(obj_["lev_markup_number"]) > 0) { indent=[ @@ -3325,7 +3752,7 @@ struct ObjInlineMarkup { ); toc_txt_= munge.url_links(toc_txt_); comp_obj_toc = comp_obj_toc.init; - comp_obj_toc.use = "body"; + comp_obj_toc.use = "frontmatter"; comp_obj_toc.is_of = "para"; comp_obj_toc.is_a = "toc"; comp_obj_toc.ocn = 0; @@ -3341,7 +3768,7 @@ struct ObjInlineMarkup { "base_position" : 0, ]; comp_obj_toc = comp_obj_toc.init; - comp_obj_toc.use = "body"; + comp_obj_toc.use = "frontmatter"; comp_obj_toc.is_of = "para"; comp_obj_toc.is_a = "toc"; comp_obj_toc.ocn = 0; @@ -3353,7 +3780,7 @@ struct ObjInlineMarkup { the_table_of_contents_section["scroll"] ~= comp_obj_toc; } comp_obj_toc = comp_obj_toc.init; - comp_obj_toc.use = "body"; + comp_obj_toc.use = "frontmatter"; comp_obj_toc.is_of = "para"; comp_obj_toc.is_a = "toc"; comp_obj_toc.ocn = 0; @@ -3393,6 +3820,7 @@ struct ObjInlineMarkup { heading_toc_, segment_anchor_tag_that_object_belongs_to, ); + lev4_subtoc[segment_anchor_tag_that_object_belongs_to] = []; toc_txt_= munge.url_links(toc_txt_); indent=[ "hang_position" : to!int(obj_["lev_markup_number"]), @@ -3410,6 +3838,12 @@ struct ObjInlineMarkup { segment_anchor_tag_that_object_belongs_to, _anchor_tag, ); + subtoc_txt_ = format( // 5 .. 7 + "{ %s }#%s", + heading_toc_, + _anchor_tag, + ); + lev4_subtoc[segment_anchor_tag_that_object_belongs_to] ~= obj_["lev_markup_number"] ~ "~ " ~ to!string(subtoc_txt_).strip; toc_txt_= munge.url_links(toc_txt_); indent=[ "hang_position" : to!int(obj_["lev_markup_number"]), @@ -4105,7 +4539,7 @@ struct BookIndexReportSection { #+name: ao_emitters_book_index_report_section #+BEGIN_SRC d - auto bookindex_build_section( + auto bookindex_build_abstraction_section( string[][string][string] bookindex_unordered_hashes, int obj_cite_number, string segment_anchor_tag_that_object_belongs_to, @@ -4126,6 +4560,7 @@ struct BookIndexReportSection { if ((mainkeys.length > 0) && (opt_action_bool["backmatter"] && opt_action_bool["section_bookindex"])) { string bi_tmp_seg, bi_tmp_scroll; + string[] bi_tmp_tags; comp_obj_heading_ = comp_obj_heading_.init; comp_obj_heading_.use = "backmatter"; comp_obj_heading_.is_of = "para"; @@ -4160,8 +4595,14 @@ struct BookIndexReportSection { bookindex_section["seg"] ~= comp_obj_heading_; ++obj_cite_number; ++mkn; + import std.array : appender; + auto buffer = appender!(char[])(); + string[dchar] transTable = [' ' : "_"]; foreach (mainkey; mainkeys) { + bi_tmp_tags = [""]; bi_tmp_scroll = "!{" ~ mainkey ~ "}! "; + buffer.clear(); + bi_tmp_tags ~= translate(mainkey, transTable); bi_tmp_seg = "!{" ~ mainkey ~ "}! "; foreach (ref_; bookindex_unordered_hashes[mainkey]["_a"]) { auto go = replaceAll(ref_, rgx.book_index_go, "$1"); @@ -4177,6 +4618,8 @@ struct BookIndexReportSection { bookindex_unordered_hashes[mainkey].byKey.array.sort().release; foreach (subkey; subkeys) { bi_tmp_scroll ~= subkey ~ ", "; + buffer.clear(); + bi_tmp_tags ~= translate(subkey, transTable); bi_tmp_seg ~= subkey ~ ", "; foreach (ref_; bookindex_unordered_hashes[mainkey][subkey]) { auto go = replaceAll(ref_, rgx.book_index_go, "$1"); @@ -4198,6 +4641,7 @@ struct BookIndexReportSection { comp_obj_para.text = to!string(bi_tmp_scroll).strip; comp_obj_para.ocn = obj_cite_number; comp_obj_para.obj_cite_number = (obj_cite_number==0) ? "" : to!string(obj_cite_number); + comp_obj_para.anchor_tags = bi_tmp_tags; comp_obj_para.indent_hang = 0; comp_obj_para.indent_base = 1; comp_obj_para.bullet = false; @@ -4619,7 +5063,7 @@ struct NodeStructureMetadata { } #+END_SRC -***** TODO node metadata emitter heading +***** TODO node metadata emitter heading, (including most segnames & their pointers) #+name: ao_emitters_metadata #+BEGIN_SRC d @@ -5053,6 +5497,8 @@ struct ObjGenericComposite { string syntax = ""; int ocn = 0; string segment_anchor_tag = ""; + string segname_prev = ""; + string segname_next = ""; int parent_lev_markup = 0; int parent_ocn = 0; int[] ancestors = []; @@ -5066,7 +5512,10 @@ struct ObjGenericComposite { int ptr_heading = 0; int array_ptr = 0; 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,]; } #+END_SRC |