From 60f70c541879cccfd379c7f75ed6aff62e793caf Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Sun, 7 Oct 2018 12:12:33 -0400 Subject: xmls segmented heading inline links --- org/doc_reform.org | 8 +- org/meta_abstraction.org | 206 +++++++++++++++++++++------------ org/output_xmls.org | 94 +++++++++------ src/doc_reform/meta/metadoc.d | 8 +- src/doc_reform/meta/metadoc_from_src.d | 198 +++++++++++++++++++------------ src/doc_reform/meta/object_setter.d | 2 + src/doc_reform/output/epub3.d | 32 ++--- src/doc_reform/output/xmls.d | 60 +++++++--- 8 files changed, 386 insertions(+), 222 deletions(-) diff --git a/org/doc_reform.org b/org/doc_reform.org index f55349d..77b8b24 100644 --- a/org/doc_reform.org +++ b/org/doc_reform.org @@ -802,7 +802,7 @@ template DocReformAbstraction() { <> enum headBody { header, body_content, insert_file_list, image_list } enum makeMeta { make, meta } - enum docAbst { doc_abstraction, section_keys, segnames, segnames_0_4, images } + enum docAbst { doc_abstraction, section_keys, segnames, segnames_0_4, tag_assoc, images } static auto rgx = Rgx(); auto DocReformAbstraction(E,O,M)( E _env, @@ -926,11 +926,12 @@ auto da = DocReformDocAbstraction!()( true, ); static assert(!isTypeTuple!(da)); -static assert(da.length==5); +static assert(da.length==6); auto doc_abstraction = da[docAbst.doc_abstraction]; /+ head ~ toc ~ body ~ endnotes_seg ~ glossary ~ bibliography ~ bookindex ~ blurb; +/ auto _document_section_keys_sequenced = da[docAbst.section_keys]; string[] _doc_html_segnames = da[docAbst.segnames]; string[] _doc_epub_segnames_0_4 = da[docAbst.segnames_0_4]; +auto _doc_tag_assoc = da[docAbst.tag_assoc]; auto _images = da[docAbst.images]; debug(steps) { writeln("- step3 complete"); @@ -1014,6 +1015,9 @@ struct DocumentMatters { string[] segnames_lv_0_to_4() { return _doc_epub_segnames_0_4; } + auto tag_associations() { + return _doc_tag_assoc; + } } return XML_(); } diff --git a/org/meta_abstraction.org b/org/meta_abstraction.org index 39bc9eb..2a447bc 100644 --- a/org/meta_abstraction.org +++ b/org/meta_abstraction.org @@ -183,8 +183,11 @@ ObjGenericComposite[] the_dom_tail_section; string[string] an_object, processing; string an_object_key; string[] anchor_tags; +string anchor_tag; string anchor_tag_; string segment_anchor_tag_that_object_belongs_to; +string lev_anchor_tag; +string[][string] tag_assoc; string segment_anchor_tag_that_object_belongs_to_uri; /+ enum +/ enum State { off, on } @@ -412,7 +415,7 @@ string[][string][string] bookindex_unordered_hashes; /+ node +/ ObjGenericComposite comp_obj_heading, comp_obj_location, comp_obj_block, comp_obj_code, comp_obj_poem_ocn, comp_obj_comment; auto node_construct = NodeStructureMetadata(); -enum sObj { content, anchor_tags, notes_reg, notes_star, links, image_no_dimensions } +enum sObj { content, anchor_tag, notes_reg, notes_star, links, image_no_dimensions } #+END_SRC *** scope @@ -513,6 +516,7 @@ 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_.tags.segment_anchor_tag_is = comp_obj_heading_.tags.segment_anchor_tag; comp_obj_heading_.metainfo.heading_lev_markup = 4; comp_obj_heading_.metainfo.heading_lev_collapsed = 1; comp_obj_heading_.metainfo.parent_ocn = 1; @@ -600,7 +604,7 @@ debug(srclines) { } #+END_SRC -*** check whether object_number is on or turned off :ocn: +*** check whether object_number is on or turned off :ocn: #+name: abs_in_loop_body_00 #+BEGIN_SRC d @@ -688,6 +692,7 @@ if there is a glossary section you need to: comp_obj_heading_.metainfo.object_number_off = ""; comp_obj_heading_.metainfo.object_number_type = 0; comp_obj_heading_.tags.segment_anchor_tag = "_part_glossary"; + comp_obj_heading_.tags.segment_anchor_tag_is = comp_obj_heading_.tags.segment_anchor_tag; comp_obj_heading_.metainfo.heading_lev_markup = 1; comp_obj_heading_.metainfo.heading_lev_collapsed = 1; comp_obj_heading_.metainfo.parent_ocn = 1; @@ -705,6 +710,7 @@ if there is a glossary section you need to: comp_obj_heading_.metainfo.object_number_off = ""; comp_obj_heading_.metainfo.object_number_type = 0; comp_obj_heading_.tags.segment_anchor_tag = "glossary"; + comp_obj_heading_.tags.segment_anchor_tag_is = comp_obj_heading_.tags.segment_anchor_tag; comp_obj_heading_.metainfo.heading_lev_markup = 4; comp_obj_heading_.metainfo.heading_lev_collapsed = 2; comp_obj_heading_.metainfo.parent_ocn = 1; @@ -807,6 +813,7 @@ if there is a blurb section you need to: 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_.tags.segment_anchor_tag_is = comp_obj_heading_.tags.segment_anchor_tag; comp_obj_heading_.metainfo.heading_lev_markup = 1; comp_obj_heading_.metainfo.heading_lev_collapsed = 1; comp_obj_heading_.metainfo.parent_ocn = 1; @@ -824,6 +831,7 @@ if there is a blurb section you need to: 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_.tags.segment_anchor_tag_is = comp_obj_heading_.tags.segment_anchor_tag; comp_obj_heading_.metainfo.heading_lev_markup = 4; comp_obj_heading_.metainfo.heading_lev_collapsed = 2; comp_obj_heading_.metainfo.parent_ocn = 1; @@ -844,6 +852,7 @@ if there is a blurb section you need to: 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_.tags.segment_anchor_tag_is = comp_obj_heading_.tags.segment_anchor_tag; comp_obj_heading_.metainfo.heading_lev_markup = an_object["lev_markup_number"].to!int; // make int, remove need to conv 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; @@ -1159,7 +1168,7 @@ if ((obj_type_status["heading"] == State.on) auto substantive_object_and_anchor_tags_tuple = obj_im.obj_inline_markup_and_anchor_tags_and_misc(an_object, an_object_key, conf_make_meta, _new_doc); an_object["substantive"] = substantive_object_and_anchor_tags_tuple[sObj.content]; - anchor_tags = substantive_object_and_anchor_tags_tuple[sObj.anchor_tags]; + anchor_tag = substantive_object_and_anchor_tags_tuple[sObj.anchor_tag]; if (_new_doc) { cnt1 = 1; cnt2 = 1; @@ -1168,13 +1177,17 @@ if ((obj_type_status["heading"] == State.on) } if ( an_object["lev_markup_number"].to!int == 4 - && anchor_tags.length > 0 + && !(anchor_tag.empty) ) { - 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]; + segment_anchor_tag_that_object_belongs_to = anchor_tag; + lev_anchor_tag = anchor_tag; + tag_assoc[anchor_tag] = [segment_anchor_tag_that_object_belongs_to]; + segment_anchor_tag_that_object_belongs_to_uri = anchor_tag ~ ".fnSuffix"; + anchor_tag_ = anchor_tag; } else if (an_object["lev_markup_number"].to!int > 4) { segment_anchor_tag_that_object_belongs_to = anchor_tag_; + lev_anchor_tag = anchor_tag; + tag_assoc[anchor_tag] = [segment_anchor_tag_that_object_belongs_to]; segment_anchor_tag_that_object_belongs_to_uri = anchor_tag_ ~ ".fnSuffix#" ~ obj_cite_digits.on.to!string; } else if (an_object["lev_markup_number"].to!int < 4) { string segn; @@ -1205,7 +1218,7 @@ if ((obj_type_status["heading"] == State.on) bookindex_unordered_hashes = bookindex_extract_hash.bookindex_nugget_hash(an_object["bookindex_nugget"], obj_cite_digits, segment_anchor_tag_that_object_belongs_to); /+ (incrementally build toc) table of contents here! +/ - _anchor_tag=to!string(obj_cite_digits.on); + _anchor_tag=obj_cite_digits.on.to!string; the_table_of_contents_section = obj_im.table_of_contents_gather_headings( an_object, conf_make_meta, @@ -1225,6 +1238,8 @@ if ((obj_type_status["heading"] == State.on) an_object["lev_markup_number"], // string an_object["lev_collapsed_number"], // string segment_anchor_tag_that_object_belongs_to, // string + lev_anchor_tag, // string + tag_assoc, obj_cite_digits, // OCNset cntr, // int heading_ptr, // int @@ -1268,6 +1283,8 @@ if ((obj_type_status["heading"] == State.on) = node_construct.node_location_emitter( content_non_header, segment_anchor_tag_that_object_belongs_to, + lev_anchor_tag, + tag_assoc, obj_cite_digits, cntr, heading_ptr-1, @@ -1276,14 +1293,14 @@ if ((obj_type_status["heading"] == State.on) auto substantive_obj_misc_tuple = obj_im.obj_inline_markup_and_anchor_tags_and_misc(an_object, an_object_key, conf_make_meta, false); an_object["substantive"] = substantive_obj_misc_tuple[sObj.content]; - anchor_tags = substantive_obj_misc_tuple[sObj.anchor_tags]; + anchor_tag = substantive_obj_misc_tuple[sObj.anchor_tag]; comp_obj_para = comp_obj_para.init; comp_obj_para.metainfo.is_of_part = "body"; comp_obj_para.metainfo.is_of_section = "body"; comp_obj_para.metainfo.is_of_type = "para"; comp_obj_para.metainfo.is_a = "para"; comp_obj_para.text = an_object["substantive"].to!string.strip; - comp_obj_para.tags.segment_anchor_tag = segment_anchor_tag_that_object_belongs_to.to!string; // TODO + comp_obj_para.tags.segment_anchor_tag_is = segment_anchor_tag_that_object_belongs_to; comp_obj_para.metainfo.ocn = obj_cite_digits.digit; comp_obj_para.metainfo.object_number_off = (obj_cite_digits.off==0) ? "" : obj_cite_digits.off.to!string; comp_obj_para.metainfo.o_n_book_index = obj_cite_digits.bkidx; @@ -1291,7 +1308,7 @@ if ((obj_type_status["heading"] == State.on) comp_obj_para.attrib.indent_hang = indent["hang_position"]; comp_obj_para.attrib.indent_base = indent["base_position"]; comp_obj_para.attrib.bullet = bullet; - comp_obj_para.tags.anchor_tags = anchor_tags; + comp_obj_para.tags.anchor_tags = [anchor_tag]; comp_obj_para.has.inline_notes_reg = substantive_obj_misc_tuple[sObj.notes_reg]; comp_obj_para.has.inline_notes_star = substantive_obj_misc_tuple[sObj.notes_star]; comp_obj_para.has.inline_links = substantive_obj_misc_tuple[sObj.links]; @@ -1447,6 +1464,7 @@ if (biblio_ordered.length > 0) { comp_obj_heading_.metainfo.object_number_off = ""; comp_obj_heading_.metainfo.object_number_type = 0; comp_obj_heading_.tags.segment_anchor_tag = "_part_bibliography"; + comp_obj_heading_.tags.segment_anchor_tag_is = comp_obj_heading_.tags.segment_anchor_tag; comp_obj_heading_.metainfo.heading_lev_markup = 1; comp_obj_heading_.metainfo.heading_lev_collapsed = 1; comp_obj_heading_.metainfo.parent_ocn = 1; @@ -1462,6 +1480,7 @@ if (biblio_ordered.length > 0) { comp_obj_heading_.metainfo.object_number_off = ""; comp_obj_heading_.metainfo.object_number_type = 0; comp_obj_heading_.tags.segment_anchor_tag = "bibliography"; + comp_obj_heading_.tags.segment_anchor_tag_is = comp_obj_heading_.tags.segment_anchor_tag; comp_obj_heading_.metainfo.heading_lev_markup = 4; comp_obj_heading_.metainfo.heading_lev_collapsed = 2; comp_obj_heading_.metainfo.parent_ocn = 1; @@ -1518,7 +1537,7 @@ foreach (entry; biblio_ordered) { comp_obj_para.attrib.indent_hang = 0; comp_obj_para.attrib.indent_base = 1; comp_obj_para.attrib.bullet = bullet; - comp_obj_para.tags.anchor_tags = anchor_tags; + comp_obj_para.tags.anchor_tags = [anchor_tag]; the_bibliography_section ~= comp_obj_para; } #+END_SRC @@ -1601,6 +1620,7 @@ if (an_object["blurb_nugget"].length == 0) { comp_obj_para.metainfo.object_number_off = ""; comp_obj_para.metainfo.object_number_type = 0; comp_obj_heading_.tags.segment_anchor_tag = ""; + comp_obj_heading_.tags.segment_anchor_tag_is = comp_obj_heading_.tags.segment_anchor_tag; comp_obj_heading_.metainfo.heading_lev_markup = 1; comp_obj_heading_.metainfo.heading_lev_collapsed = 1; comp_obj_heading_.metainfo.parent_ocn = 1; @@ -1638,7 +1658,7 @@ if (the_endnotes_section.length > 1) { "{ %s }%s%s%s", "Endnotes", mkup.mark_internal_site_lnk, - "endnotes", // segment_anchor_tag_that_object_belongs_to + "endnotes", ".fnSuffix", ); toc_txt_= munge.url_links(toc_txt_); @@ -1651,7 +1671,7 @@ if (the_glossary_section.length > 1) { "{ %s }%s%s%s", "Glossary", mkup.mark_internal_site_lnk, - "glossary", // segment_anchor_tag_that_object_belongs_to + "glossary", ".fnSuffix", ); toc_txt_= munge.url_links(toc_txt_); @@ -1673,7 +1693,7 @@ if (the_bibliography_section.length > 1){ "{ %s }%s%s%s", "Bibliography", mkup.mark_internal_site_lnk, - "bibliography", // segment_anchor_tag_that_object_belongs_to + "bibliography", ".fnSuffix", ); toc_txt_= munge.url_links(toc_txt_); @@ -1696,7 +1716,7 @@ if (the_bookindex_section["seg"].length > 1) { "{ %s }%s%s%s", "Book Index", mkup.mark_internal_site_lnk, - "bookindex", // segment_anchor_tag_that_object_belongs_to + "bookindex", ".fnSuffix", ); toc_txt_= munge.url_links(toc_txt_); @@ -1720,7 +1740,7 @@ if (the_blurb_section.length > 1) { "{ %s }%s%s%s", "Blurb", mkup.mark_internal_site_lnk, - "blurb", // segment_anchor_tag_that_object_belongs_to + "blurb", ".fnSuffix", ); toc_txt_= munge.url_links(toc_txt_); @@ -1767,7 +1787,7 @@ the_document_head_section ~= the_document_body_section[0]; the_document_body_section=the_document_body_section[1..$]; #+END_SRC -*** ↻ *LOOPs* _post main-loop loops_ :post: +*** ↻ *LOOPs* _post main-loop loops_ :loop:post: **** 1. ↻ _Loop as required_ (e.g. backmatter): loop up to lev4, extract html_segnames, set pointers this extra loop is used/needed to determine pre and (in particular) next segment @@ -2207,7 +2227,7 @@ auto extract_images(S)(S content_block) { } return images_; } -string[] segnames_0_4; +string[] segnames_lv0_to_4; #+END_SRC ****** images: dimensions @@ -2260,7 +2280,7 @@ foreach (ref obj; the_document_head_section) { writeln(obj.text); } if (obj.metainfo.heading_lev_markup <= 4) { - segnames_0_4 ~= obj.tags.segment_anchor_tag; + segnames_lv0_to_4 ~= obj.tags.segment_anchor_tag; } if (obj.metainfo.heading_lev_markup == 0) { /+ TODO second hit (of two) with same assertion failure, check, fix and reinstate @@ -2296,7 +2316,7 @@ if (the_table_of_contents_section["scroll"].length > 1) { foreach (ref obj; the_table_of_contents_section["scroll"]) { if (obj.metainfo.is_a == "heading") { if (obj.metainfo.heading_lev_markup <= 4) { - segnames_0_4 ~= obj.tags.segment_anchor_tag; + segnames_lv0_to_4 ~= obj.tags.segment_anchor_tag; if (obj.metainfo.heading_lev_markup == 4) { obj.tags.segname_next = html_segnames[obj.ptr.html_segnames + 1]; assert(obj.tags.segment_anchor_tag == html_segnames[obj.ptr.html_segnames], @@ -2325,7 +2345,7 @@ if (the_table_of_contents_section["scroll"].length > 1) { writeln(obj.text); } if (obj.metainfo.heading_lev_markup <= 4) { - segnames_0_4 ~= obj.tags.segment_anchor_tag; + segnames_lv0_to_4 ~= obj.tags.segment_anchor_tag; if (obj.metainfo.heading_lev_markup == 4) { obj.tags.segname_next = html_segnames[obj.ptr.html_segnames + 1]; assert(obj.tags.segment_anchor_tag == html_segnames[obj.ptr.html_segnames], @@ -2357,7 +2377,7 @@ if (the_document_body_section.length > 1) { writeln(obj.text); } if (obj.metainfo.heading_lev_markup <= 4) { - segnames_0_4 ~= obj.tags.segment_anchor_tag; + segnames_lv0_to_4 ~= obj.tags.segment_anchor_tag; if (obj.metainfo.heading_lev_markup == 4) { obj.tags.lev4_subtoc = lev4_subtoc[obj.tags.segment_anchor_tag]; obj.tags.segname_prev = html_segnames[obj.ptr.html_segnames - 1]; @@ -2408,7 +2428,7 @@ if (the_endnotes_section.length > 1) { obj_cite_digits = ocn_emit(OCNstatus.on); obj.metainfo.ocn = obj_cite_digits.digit; if (obj.metainfo.heading_lev_markup <= 4) { - segnames_0_4 ~= obj.tags.segment_anchor_tag; + segnames_lv0_to_4 ~= obj.tags.segment_anchor_tag; if (obj.metainfo.heading_lev_markup == 4) { obj.tags.segname_prev = html_segnames[obj.ptr.html_segnames - 1]; if (html_segnames.length > obj.ptr.html_segnames + 1) { @@ -2450,7 +2470,7 @@ if (the_glossary_section.length > 1) { obj_cite_digits = ocn_emit(OCNstatus.on); obj.metainfo.ocn = obj_cite_digits.digit; if (obj.metainfo.heading_lev_markup <= 4) { - segnames_0_4 ~= obj.tags.segment_anchor_tag; + segnames_lv0_to_4 ~= obj.tags.segment_anchor_tag; if (obj.metainfo.heading_lev_markup == 4) { obj.tags.segname_prev = html_segnames[obj.ptr.html_segnames - 1]; if (html_segnames.length > obj.ptr.html_segnames + 1) { @@ -2495,7 +2515,7 @@ if (the_bibliography_section.length > 1) { obj_cite_digits = ocn_emit(OCNstatus.on); obj.metainfo.ocn = obj_cite_digits.digit; if (obj.metainfo.heading_lev_markup <= 4) { - segnames_0_4 ~= obj.tags.segment_anchor_tag; + segnames_lv0_to_4 ~= obj.tags.segment_anchor_tag; if (obj.metainfo.heading_lev_markup == 4) { obj.tags.segname_prev = html_segnames[obj.ptr.html_segnames - 1]; if (html_segnames.length > obj.ptr.html_segnames + 1) { @@ -2545,7 +2565,7 @@ if (the_bookindex_section["scroll"].length > 1) { obj_cite_digits = ocn_emit(OCNstatus.on); obj.metainfo.ocn = obj_cite_digits.on; if (obj.metainfo.heading_lev_markup <= 4) { - segnames_0_4 ~= obj.tags.segment_anchor_tag; + segnames_lv0_to_4 ~= obj.tags.segment_anchor_tag; if (obj.metainfo.heading_lev_markup == 4) { obj.tags.segname_prev = html_segnames[obj.ptr.html_segnames - 1]; if (html_segnames.length > obj.ptr.html_segnames + 1) { @@ -2583,7 +2603,7 @@ if (the_bookindex_section["scroll"].length > 1) { } obj.metainfo.ocn = ++ocn_; if (obj.metainfo.heading_lev_markup <= 4) { - segnames_0_4 ~= obj.tags.segment_anchor_tag; + segnames_lv0_to_4 ~= obj.tags.segment_anchor_tag; if (obj.metainfo.heading_lev_markup == 4) { obj.tags.segname_prev = html_segnames[obj.ptr.html_segnames - 1]; if (html_segnames.length > obj.ptr.html_segnames + 1) { @@ -2631,7 +2651,7 @@ if (the_blurb_section.length > 1) { obj_cite_digits = ocn_emit(OCNstatus.on); obj.metainfo.ocn = obj_cite_digits.on; if (obj.metainfo.heading_lev_markup <= 4) { - segnames_0_4 ~= obj.tags.segment_anchor_tag; + segnames_lv0_to_4 ~= obj.tags.segment_anchor_tag; if (obj.metainfo.heading_lev_markup == 4) { obj.tags.segname_prev = html_segnames[obj.ptr.html_segnames - 1]; if (html_segnames.length > obj.ptr.html_segnames + 1) { @@ -2862,7 +2882,7 @@ auto sequenced_document_keys = docSectKeysSeq!()(document_section_keys_sequenced #+name: abs_post #+BEGIN_SRC d -auto segnames = html_segnames.dup; +auto segnames_lv4 = html_segnames.dup; #+END_SRC *** clean out structure @@ -2951,8 +2971,9 @@ debug(abstraction) { auto t = tuple( document_the, sequenced_document_keys, - segnames, - segnames_0_4, + segnames_lv4, + segnames_lv0_to_4, + tag_assoc, images, ); return t; @@ -3002,7 +3023,7 @@ auto _common_reset_(L,O,T)( } #+END_SRC -*** check object_number status in document :ocn: +*** check object_number status in document :ocn: #+name: abs_functions_ocn_status #+BEGIN_SRC d @@ -3760,7 +3781,7 @@ void _poem_block_(L,O,T,C,N,CMM,Ts)( auto substantive_obj_misc_tuple = obj_im.obj_inline_markup_and_anchor_tags_and_misc(an_object, an_object_key, conf_make_meta, false); an_object["substantive"] = substantive_obj_misc_tuple[sObj.content]; - anchor_tags = substantive_obj_misc_tuple[sObj.anchor_tags]; + anchor_tag = substantive_obj_misc_tuple[sObj.anchor_tag]; comp_obj_block = comp_obj_block.init; comp_obj_block.metainfo.is_of_part = "body"; comp_obj_block.metainfo.is_of_section = "body"; @@ -3768,7 +3789,7 @@ void _poem_block_(L,O,T,C,N,CMM,Ts)( comp_obj_block.metainfo.is_a = "verse"; comp_obj_block.metainfo.ocn = obj_cite_digits.on; comp_obj_block.metainfo.object_number_off = (obj_cite_digits.off==0) ? "" : obj_cite_digits.off.to!string; - comp_obj_block.tags.segment_anchor_tag = segment_anchor_tag_that_object_belongs_to.to!string; // TODO + comp_obj_block.tags.segment_anchor_tag_is = segment_anchor_tag_that_object_belongs_to; comp_obj_block.metainfo.o_n_book_index = obj_cite_digits.bkidx; comp_obj_block.metainfo.object_number_type = obj_cite_digits.type; comp_obj_block.text = an_object["substantive"]; @@ -3810,6 +3831,8 @@ void _poem_block_(L,O,T,C,N,CMM,Ts)( auto comp_obj_location = node_construct.node_location_emitter( content_non_header, segment_anchor_tag_that_object_belongs_to, + lev_anchor_tag, + tag_assoc, obj_cite_digits, cntr, heading_ptr-1, @@ -3818,7 +3841,7 @@ void _poem_block_(L,O,T,C,N,CMM,Ts)( auto substantive_obj_misc_tuple = obj_im.obj_inline_markup_and_anchor_tags_and_misc(an_object, an_object_key, conf_make_meta, false); an_object["substantive"] = substantive_obj_misc_tuple[sObj.content]; - anchor_tags = substantive_obj_misc_tuple[sObj.anchor_tags]; + anchor_tag = substantive_obj_misc_tuple[sObj.anchor_tag]; comp_obj_block = comp_obj_block.init; comp_obj_block.metainfo.is_of_part = "body"; comp_obj_block.metainfo.is_of_section = "body"; @@ -3826,7 +3849,7 @@ void _poem_block_(L,O,T,C,N,CMM,Ts)( comp_obj_block.metainfo.is_a = "verse"; comp_obj_block.metainfo.ocn = obj_cite_digits.on; comp_obj_block.metainfo.object_number_off = (obj_cite_digits.off==0) ? "" : obj_cite_digits.off.to!string; - comp_obj_block.tags.segment_anchor_tag = segment_anchor_tag_that_object_belongs_to.to!string; // TODO + comp_obj_block.tags.segment_anchor_tag_is = segment_anchor_tag_that_object_belongs_to; comp_obj_block.metainfo.o_n_book_index = obj_cite_digits.bkidx; comp_obj_block.metainfo.object_number_type = obj_cite_digits.type; comp_obj_block.text = an_object["substantive"]; @@ -3861,7 +3884,7 @@ void _poem_block_(L,O,T,C,N,CMM,Ts)( auto substantive_obj_misc_tuple = obj_im.obj_inline_markup_and_anchor_tags_and_misc(an_object, an_object_key, conf_make_meta, false); an_object["substantive"] = substantive_obj_misc_tuple[sObj.content]; - anchor_tags = substantive_obj_misc_tuple[sObj.anchor_tags]; + anchor_tag = substantive_obj_misc_tuple[sObj.anchor_tag]; comp_obj_block = comp_obj_block.init; comp_obj_block.metainfo.is_of_part = "body"; comp_obj_block.metainfo.is_of_section = "body"; @@ -3869,7 +3892,7 @@ void _poem_block_(L,O,T,C,N,CMM,Ts)( comp_obj_block.metainfo.is_a = "verse"; comp_obj_block.metainfo.ocn = obj_cite_digits.on; comp_obj_block.metainfo.object_number_off = (obj_cite_digits.off==0) ? "" : obj_cite_digits.off.to!string; - comp_obj_block.tags.segment_anchor_tag = segment_anchor_tag_that_object_belongs_to.to!string; // TODO + comp_obj_block.tags.segment_anchor_tag_is = segment_anchor_tag_that_object_belongs_to; comp_obj_block.metainfo.o_n_book_index = obj_cite_digits.bkidx; comp_obj_block.metainfo.object_number_type = obj_cite_digits.type; comp_obj_block.text = an_object["substantive"]; @@ -3911,6 +3934,8 @@ void _poem_block_(L,O,T,C,N,CMM,Ts)( = node_construct.node_location_emitter( content_non_header, segment_anchor_tag_that_object_belongs_to, + lev_anchor_tag, + tag_assoc, obj_cite_digits, cntr, heading_ptr-1, @@ -3919,7 +3944,7 @@ void _poem_block_(L,O,T,C,N,CMM,Ts)( auto substantive_obj_misc_tuple = obj_im.obj_inline_markup_and_anchor_tags_and_misc(an_object, an_object_key, conf_make_meta, false); an_object["substantive"] = substantive_obj_misc_tuple[sObj.content]; - anchor_tags = substantive_obj_misc_tuple[sObj.anchor_tags]; + anchor_tag = substantive_obj_misc_tuple[sObj.anchor_tag]; comp_obj_block = comp_obj_block.init; comp_obj_block.metainfo.is_of_part = "body"; comp_obj_block.metainfo.is_of_section = "body"; @@ -3927,7 +3952,7 @@ void _poem_block_(L,O,T,C,N,CMM,Ts)( comp_obj_block.metainfo.is_a = "verse"; comp_obj_block.metainfo.ocn = obj_cite_digits.on; comp_obj_block.metainfo.object_number_off = (obj_cite_digits.off==0) ? "" : obj_cite_digits.off.to!string; - comp_obj_block.tags.segment_anchor_tag = segment_anchor_tag_that_object_belongs_to.to!string; // TODO + comp_obj_block.tags.segment_anchor_tag_is = segment_anchor_tag_that_object_belongs_to; comp_obj_block.metainfo.o_n_book_index = obj_cite_digits.bkidx; comp_obj_block.metainfo.object_number_type = obj_cite_digits.type; comp_obj_block.text = an_object["substantive"]; @@ -4055,6 +4080,8 @@ void _table_closed_make_special_notation_table_(N,CMM)( = node_construct.node_location_emitter( content_non_header, segment_anchor_tag_that_object_belongs_to, + lev_anchor_tag, + tag_assoc, obj_cite_digits, cntr, heading_ptr-1, @@ -4066,7 +4093,7 @@ void _table_closed_make_special_notation_table_(N,CMM)( an_object["substantive"] = substantive_obj_misc_tuple[sObj.content]; comp_obj_block.metainfo.ocn = obj_cite_digits.on; comp_obj_block.metainfo.object_number_off = (obj_cite_digits.off==0) ? "" : obj_cite_digits.off.to!string; - comp_obj_block.tags.segment_anchor_tag = segment_anchor_tag_that_object_belongs_to.to!string; // TODO + comp_obj_block.tags.segment_anchor_tag_is = segment_anchor_tag_that_object_belongs_to; comp_obj_block.metainfo.o_n_book_index = obj_cite_digits.bkidx; comp_obj_block.metainfo.object_number_type = obj_cite_digits.type; comp_obj_block = table_instructions(comp_obj_block, an_object["table_head"]); @@ -4129,6 +4156,8 @@ void _block_flag_line_empty_(B,N,CMM,Ts)( = node_construct.node_location_emitter( content_non_header, segment_anchor_tag_that_object_belongs_to, + lev_anchor_tag, + tag_assoc, obj_cite_digits, cntr, heading_ptr-1, @@ -4137,7 +4166,7 @@ void _block_flag_line_empty_(B,N,CMM,Ts)( auto substantive_obj_misc_tuple = obj_im.obj_inline_markup_and_anchor_tags_and_misc(an_object, an_object_key, conf_make_meta, false); an_object["substantive"] = substantive_obj_misc_tuple[sObj.content]; - anchor_tags = substantive_obj_misc_tuple[sObj.anchor_tags]; + anchor_tag = substantive_obj_misc_tuple[sObj.anchor_tag]; comp_obj_block = comp_obj_block.init; comp_obj_block.metainfo.is_of_part = "body"; comp_obj_block.metainfo.is_of_section = "body"; @@ -4145,7 +4174,7 @@ void _block_flag_line_empty_(B,N,CMM,Ts)( comp_obj_block.metainfo.is_a = "quote"; comp_obj_block.metainfo.ocn = obj_cite_digits.on; comp_obj_block.metainfo.object_number_off = (obj_cite_digits.off==0) ? "" : obj_cite_digits.off.to!string; - comp_obj_block.tags.segment_anchor_tag = segment_anchor_tag_that_object_belongs_to.to!string; // TODO + comp_obj_block.tags.segment_anchor_tag_is = segment_anchor_tag_that_object_belongs_to; comp_obj_block.metainfo.o_n_book_index = obj_cite_digits.bkidx; comp_obj_block.metainfo.object_number_type = obj_cite_digit_type; comp_obj_block.text = an_object["substantive"]; @@ -4179,6 +4208,8 @@ void _block_flag_line_empty_(B,N,CMM,Ts)( = node_construct.node_location_emitter( content_non_header, segment_anchor_tag_that_object_belongs_to, + lev_anchor_tag, + tag_assoc, obj_cite_digits, cntr, heading_ptr-1, @@ -4187,7 +4218,7 @@ void _block_flag_line_empty_(B,N,CMM,Ts)( auto substantive_obj_misc_tuple = obj_im.obj_inline_markup_and_anchor_tags_and_misc(an_object, an_object_key, conf_make_meta, false); an_object["substantive"] = substantive_obj_misc_tuple[sObj.content]; - anchor_tags = substantive_obj_misc_tuple[sObj.anchor_tags]; + anchor_tag = substantive_obj_misc_tuple[sObj.anchor_tag]; comp_obj_block = comp_obj_block.init; comp_obj_block.metainfo.is_of_part = "body"; comp_obj_block.metainfo.is_of_section = "body"; @@ -4195,7 +4226,7 @@ void _block_flag_line_empty_(B,N,CMM,Ts)( comp_obj_block.metainfo.is_a = "group"; comp_obj_block.metainfo.ocn = obj_cite_digits.on; comp_obj_block.metainfo.object_number_off = (obj_cite_digits.off==0) ? "" : obj_cite_digits.off.to!string; - comp_obj_block.tags.segment_anchor_tag = segment_anchor_tag_that_object_belongs_to.to!string; // TODO + comp_obj_block.tags.segment_anchor_tag_is = segment_anchor_tag_that_object_belongs_to; comp_obj_block.metainfo.o_n_book_index = obj_cite_digits.bkidx; comp_obj_block.metainfo.object_number_type = obj_cite_digits.type; comp_obj_block.text = an_object["substantive"]; @@ -4229,6 +4260,8 @@ void _block_flag_line_empty_(B,N,CMM,Ts)( = node_construct.node_location_emitter( content_non_header, segment_anchor_tag_that_object_belongs_to, + lev_anchor_tag, + tag_assoc, obj_cite_digits, cntr, heading_ptr-1, @@ -4244,7 +4277,7 @@ void _block_flag_line_empty_(B,N,CMM,Ts)( comp_obj_block.metainfo.is_a = "block"; comp_obj_block.metainfo.ocn = obj_cite_digits.on; comp_obj_block.metainfo.object_number_off = (obj_cite_digits.off==0) ? "" : obj_cite_digits.off.to!string; - comp_obj_block.tags.segment_anchor_tag = segment_anchor_tag_that_object_belongs_to.to!string; // TODO + comp_obj_block.tags.segment_anchor_tag_is = segment_anchor_tag_that_object_belongs_to; comp_obj_block.metainfo.o_n_book_index = obj_cite_digits.bkidx; comp_obj_block.metainfo.object_number_type = obj_cite_digit_type; comp_obj_block.text = an_object["substantive"]; @@ -4277,6 +4310,8 @@ void _block_flag_line_empty_(B,N,CMM,Ts)( = node_construct.node_location_emitter( content_non_header, segment_anchor_tag_that_object_belongs_to, + lev_anchor_tag, + tag_assoc, obj_cite_digits, cntr, heading_ptr-1, @@ -4318,6 +4353,8 @@ void _block_flag_line_empty_(B,N,CMM,Ts)( = node_construct.node_location_emitter( content_non_header, segment_anchor_tag_that_object_belongs_to, + lev_anchor_tag, + tag_assoc, obj_cite_digits, cntr, heading_ptr-1, @@ -4326,7 +4363,7 @@ void _block_flag_line_empty_(B,N,CMM,Ts)( auto substantive_obj_misc_tuple = obj_im.obj_inline_markup_and_anchor_tags_and_misc(an_object, an_object_key, conf_make_meta, false); an_object["substantive"] = substantive_obj_misc_tuple[sObj.content]; - anchor_tags = substantive_obj_misc_tuple[sObj.anchor_tags]; + anchor_tag = substantive_obj_misc_tuple[sObj.anchor_tag]; comp_obj_code = comp_obj_code.init; comp_obj_code.metainfo.is_of_part = "body"; comp_obj_code.metainfo.is_of_section = "body"; @@ -4334,7 +4371,7 @@ void _block_flag_line_empty_(B,N,CMM,Ts)( comp_obj_code.metainfo.is_a = "code"; comp_obj_code.metainfo.ocn = obj_cite_digits.on; comp_obj_code.metainfo.object_number_off = (obj_cite_digits.off==0) ? "" : obj_cite_digits.off.to!string; - comp_obj_code.tags.segment_anchor_tag = segment_anchor_tag_that_object_belongs_to.to!string; + comp_obj_code.tags.segment_anchor_tag_is = segment_anchor_tag_that_object_belongs_to; comp_obj_code.metainfo.o_n_book_index = obj_cite_digits.bkidx; comp_obj_code.metainfo.object_number_type = obj_cite_digits.type; comp_obj_code.text = an_object["substantive"]; @@ -4369,6 +4406,8 @@ void _block_flag_line_empty_(B,N,CMM,Ts)( = node_construct.node_location_emitter( content_non_header, segment_anchor_tag_that_object_belongs_to, + lev_anchor_tag, + tag_assoc, obj_cite_digits, cntr, heading_ptr-1, @@ -4380,7 +4419,7 @@ void _block_flag_line_empty_(B,N,CMM,Ts)( comp_obj_block = comp_obj_block.init; comp_obj_block.metainfo.ocn = obj_cite_digits.on; comp_obj_block.metainfo.object_number_off = (obj_cite_digits.off==0) ? "" : obj_cite_digits.off.to!string; - comp_obj_block.tags.segment_anchor_tag = segment_anchor_tag_that_object_belongs_to.to!string; // TODO + comp_obj_block.tags.segment_anchor_tag_is = segment_anchor_tag_that_object_belongs_to; comp_obj_block.metainfo.o_n_book_index = obj_cite_digits.bkidx; comp_obj_block.metainfo.object_number_type = obj_cite_digits.type; comp_obj_block = table_instructions(comp_obj_block, an_object["table_head"]); @@ -5337,7 +5376,7 @@ static struct ObjInlineMarkupMunge { n_foot=n_foot_reg; obj_txt_out ~= n.hit.to!string.replaceFirst( rgx.inline_al_delimiter_open_regular, - (mkup.en_a_o ~ to!string(n_foot) ~ " ") + (mkup.en_a_o ~ n_foot.to!string ~ " ") ) ~ "\n"; } else { obj_txt_out ~= n.hit.to!string ~ "\n"; @@ -5659,7 +5698,6 @@ static struct ObjInlineMarkup { static auto rgx = Rgx(); static auto munge = ObjInlineMarkupMunge(); string[string] obj_txt; - static string[] anchor_tags_ = []; static string anchor_tag = ""; #+END_SRC @@ -5685,7 +5723,7 @@ static struct ObjInlineMarkup { ? obj_txt["munge"] : obj_txt["munge"].strip; if (_new_doc) { - anchor_tags_ = []; + anchor_tag = ""; } auto x = munge.init; bool[string] obj_notes_and_links; @@ -5702,7 +5740,6 @@ static struct ObjInlineMarkup { obj_txt["munge"]=_make_segment_anchor_tags_if_none_provided(obj_txt["munge"], obj_["lev"], _new_doc); if (auto m = obj_txt["munge"].match(rgx.heading_anchor_tag)) { anchor_tag = m.captures[1]; - anchor_tags_ ~= anchor_tag; } else if (obj_["lev"] == "1") { writeln("heading anchor tag missing: ", obj_txt["munge"]); } @@ -5748,13 +5785,13 @@ static struct ObjInlineMarkup { } auto t = tuple( obj_txt["munge"], - anchor_tags_, + anchor_tag, obj_notes_and_links["notes_reg"], obj_notes_and_links["notes_star"], obj_notes_and_links["links"], obj_notes_and_links["image_no_dimensions"], ); - anchor_tags_=[]; + anchor_tag = ""; return t; } invariant() { @@ -6089,7 +6126,8 @@ private: rgx.heading_marker_missing_tag, "$1~" ~ m.captures[1].toLower ~ "_" ~ m.captures[2] ~ " "); if (auto n = munge_.match(rgx.heading_anchor_tag_plus_colon)) { - auto tag_remunge_ = n.captures[2].replaceAll(rgx.heading_marker_tag_has_colon, ".."); + auto tag_remunge_ = n.captures[2] + .replaceAll(rgx.heading_marker_tag_has_colon, ".."); munge_=(munge_).replaceFirst(rgx.heading_anchor_tag_plus_colon, n.captures[1] ~ tag_remunge_ ~ " "); } } else if (auto m = munge_.match(rgx.heading_extract_unnamed_anchor_tag)) { @@ -6562,7 +6600,8 @@ struct BookIndexNuggetHash { main_term = m.captures[1].strip; object_number_offset = m.captures[2].to!int; object_number_endpoint=(obj_cite_digits.on + object_number_offset); - object_numbers ~= (obj_cite_digits.on.to!string ~ "-" ~ to!string(object_number_endpoint) + object_numbers ~= (obj_cite_digits.on.to!string + ~ "-" ~ object_number_endpoint.to!string ~ ":" ~ segment_anchor_tag); } else { main_term = bi_main_term_and_rest[0].strip; @@ -6581,11 +6620,12 @@ struct BookIndexNuggetHash { sub_term = m.captures[1].strip; object_number_offset = m.captures[2].to!int; object_number_endpoint=(obj_cite_digits.on + object_number_offset); - object_numbers ~= (obj_cite_digits.on.to!string ~ " - " ~ to!string(object_number_endpoint) + object_numbers ~= (obj_cite_digits.on.to!string + ~ " - " ~ object_number_endpoint.to!string ~ ":" ~ segment_anchor_tag); } else { sub_term = sub_terms_bits.strip; - object_numbers ~= to!string(obj_cite_digits.on) + object_numbers ~= obj_cite_digits.on.to!string ~ ":" ~ segment_anchor_tag; } if (!empty(sub_term)) { @@ -6727,6 +6767,7 @@ struct BookIndexReportSection { comp_obj_heading_.metainfo.object_number_off = ""; comp_obj_heading_.metainfo.object_number_type = 0; comp_obj_heading_.tags.segment_anchor_tag = "_part_book_index"; + comp_obj_heading_.tags.segment_anchor_tag_is = comp_obj_heading_.tags.segment_anchor_tag; comp_obj_heading_.metainfo.heading_lev_markup = 1; comp_obj_heading_.metainfo.heading_lev_collapsed = 1; comp_obj_heading_.metainfo.parent_ocn = 1; @@ -6745,6 +6786,7 @@ struct BookIndexReportSection { comp_obj_heading_.metainfo.object_number_off = ""; comp_obj_heading_.metainfo.object_number_type = 0; comp_obj_heading_.tags.segment_anchor_tag = "bookindex"; + comp_obj_heading_.tags.segment_anchor_tag_is = comp_obj_heading_.tags.segment_anchor_tag; comp_obj_heading_.metainfo.heading_lev_markup = 4; comp_obj_heading_.metainfo.heading_lev_collapsed = 2; comp_obj_heading_.metainfo.parent_ocn = 1; @@ -6979,6 +7021,7 @@ struct NotesSection { comp_obj_heading_.metainfo.object_number_off = ""; comp_obj_heading_.metainfo.object_number_type = 0; comp_obj_heading_.tags.segment_anchor_tag = "_part_endnotes"; + comp_obj_heading_.tags.segment_anchor_tag_is = comp_obj_heading_.tags.segment_anchor_tag; comp_obj_heading_.metainfo.heading_lev_markup = 1; comp_obj_heading_.metainfo.heading_lev_collapsed = 1; comp_obj_heading_.metainfo.parent_ocn = 1; @@ -6995,6 +7038,7 @@ struct NotesSection { comp_obj_heading_.metainfo.object_number_off = ""; comp_obj_heading_.metainfo.object_number_type = 0; comp_obj_heading_.tags.segment_anchor_tag = "endnotes"; + comp_obj_heading_.tags.segment_anchor_tag_is = comp_obj_heading_.tags.segment_anchor_tag; comp_obj_heading_.metainfo.heading_lev_markup = 4; comp_obj_heading_.metainfo.heading_lev_collapsed = 2; comp_obj_heading_.metainfo.parent_ocn = 1; @@ -7205,9 +7249,11 @@ struct NodeStructureMetadata { #+name: meta_emitters_metadata #+BEGIN_SRC d - ObjGenericComposite node_location_emitter(Lv,Ta,N,C,P,I)( + ObjGenericComposite node_location_emitter(Lv,Tg,La,Ta,N,C,P,I)( Lv lev_markup_number, - Ta segment_anchor_tag, + Tg segment_anchor_tag, + La lev_anchor_tag, + Ta tag_assoc, N obj_cite_digits, C cntr_, P ptr_, @@ -7246,6 +7292,8 @@ struct NodeStructureMetadata { comp_obj_location.metainfo.is_a = is_; comp_obj_location.metainfo.ocn = obj_cite_digits.on; comp_obj_location.tags.segment_anchor_tag = segment_anchor_tag.to!string; + comp_obj_location.tags.segment_anchor_tag_is = comp_obj_location.tags.segment_anchor_tag; + comp_obj_location.tags.heading_lev_anchor_tag = lev_anchor_tag; comp_obj_location.metainfo.parent_ocn = p_["object_number"]; comp_obj_location.metainfo.parent_lev_markup = p_["lev_markup_number"]; debug(_node) { @@ -7268,11 +7316,13 @@ struct NodeStructureMetadata { #+name: meta_emitters_metadata #+BEGIN_SRC d - ObjGenericComposite node_emitter_heading(T,Lm,Lc,Ta,N,C,P,LA,I,PSn,fNr,fNs,fL)( + ObjGenericComposite node_emitter_heading(T,Lm,Lc,TaB,TaL,TA,N,C,P,LA,I,PSn,fNr,fNs,fL)( T _text, Lm lev_markup_number, Lc lev_collapsed_number, - Ta segment_anchor_tag, + TaB segment_anchor_tag_that_object_belongs_to, + TaL lev_anchor_tag, + TA tag_assoc, N obj_cite_digits, C cntr_, P ptr_, @@ -7285,17 +7335,17 @@ struct NodeStructureMetadata { ) in { debug(asserts) { - static assert(is(typeof(_text) == string)); - static assert(is(typeof(lev) == string)); - static assert(is(typeof(lev_markup_number) == string)); - static assert(is(typeof(lev_collapsed_number) == string)); - static assert(is(typeof(segment_anchor_tag) == string)); - static assert(is(typeof(obj_cite_digits.on) == int)); - static assert(is(typeof(cntr_) == int)); - static assert(is(typeof(ptr_) == int)); - static assert(is(typeof(lv_ancestors_txt) == string[])); - static assert(is(typeof(is_) == string)); - static assert(is(typeof(html_segnames_ptr) == int)); + static assert(is(typeof(_text) == string)); + static assert(is(typeof(lev) == string)); + static assert(is(typeof(lev_markup_number) == string)); + static assert(is(typeof(lev_collapsed_number) == string)); + static assert(is(typeof(segment_anchor_tag_that_object_belongs_to) == string)); + static assert(is(typeof(obj_cite_digits.on) == int)); + static assert(is(typeof(cntr_) == int)); + static assert(is(typeof(ptr_) == int)); + static assert(is(typeof(lv_ancestors_txt) == string[])); + static assert(is(typeof(is_) == string)); + static assert(is(typeof(html_segnames_ptr) == int)); } assert(is_ == "heading"); assert((obj_cite_digits.on).to!int >= 0); @@ -7407,7 +7457,9 @@ struct NodeStructureMetadata { _comp_obj_heading_.metainfo.ocn = obj_cite_digits.on; _comp_obj_heading_.metainfo.object_number_off = (obj_cite_digits.off==0) ? "" : obj_cite_digits.off.to!string; _comp_obj_heading_.metainfo.object_number_type = obj_cite_digits.type; - _comp_obj_heading_.tags.segment_anchor_tag = segment_anchor_tag.to!string; + _comp_obj_heading_.tags.segment_anchor_tag = segment_anchor_tag_that_object_belongs_to; + _comp_obj_heading_.tags.heading_lev_anchor_tag = lev_anchor_tag; + _comp_obj_heading_.tags.segment_anchor_tag_is = segment_anchor_tag_that_object_belongs_to; _comp_obj_heading_.metainfo.heading_lev_markup = (!(lev_markup_number.empty) ? lev_markup_number.to!int : 0); _comp_obj_heading_.metainfo.heading_lev_collapsed = (!(lev_collapsed_number.empty) ? lev_collapsed_number.to!int : 0); _comp_obj_heading_.metainfo.parent_ocn = p_["object_number"]; @@ -7848,6 +7900,8 @@ struct DocObj_Pointer_ { struct DocObj_Tags_ { string[] heading_ancestors_text = [ "", "", "", "", "", "", "", "", ]; // TODO redundant? see markedup and collapsed ancestors DONE string segment_anchor_tag = ""; + string segment_anchor_tag_is = ""; + string heading_lev_anchor_tag = ""; string segname_prev = ""; string segname_next = ""; string[] lev4_subtoc = []; diff --git a/org/output_xmls.org b/org/output_xmls.org index 441ed95..cb7830a 100644 --- a/org/output_xmls.org +++ b/org/output_xmls.org @@ -153,7 +153,8 @@ string font_face(string _txt){ #+name: xhtml_format_objects #+BEGIN_SRC d -string _xhtml_anchor_tags(const(string[]) anchor_tags) { +string _xhtml_anchor_tags(O)(O obj) { + const(string[]) anchor_tags = obj.tags.anchor_tags; string tags=""; if (anchor_tags.length > 0) { foreach (tag; anchor_tags) { @@ -466,13 +467,28 @@ auto inline_links(M,O)( } if (_xml_type == "seg" || _xml_type == "epub") { if (auto m = _txt.match(rgx.inline_link_hash)) { - foreach (segname; doc_matters.xml.segnames) { - if (auto n = segname.match(m.captures[3])) { + if (m.captures[3] in doc_matters.xml.tag_associations) { + if (m.captures[3] == doc_matters.xml.tag_associations[(m.captures[3])][0]) { _txt = _txt.replaceFirst( rgx.inline_link_hash, - "┥$1┝┤$3" ~ _suffix ~ "├"); - break; + "┥$1┝┤$3" ~ _suffix ~ "├" + ); + } else { + _txt = _txt.replaceFirst( + rgx.inline_link_hash, + "┥$1┝┤" + ~ doc_matters.xml.tag_associations[(m.captures[3])][0] + ~ _suffix + ~ "#" ~ "$3" + ~ "├" + ); } + } else { + writeln( + "WARNING on internal document links, anchor to link not found in document, " + ~ "anchor: " ~ m.captures[3] + ~ " document: " ~ doc_matters.src.filename + ); } } } @@ -753,7 +769,9 @@ auto heading(M,O)( string _txt, string _xml_type = "html", ) { - auto tags = _xhtml_anchor_tags(obj.tags.anchor_tags); + auto tags = _xhtml_anchor_tags(obj); + string seg_anchor_tag; + string heading_lev_anchor_tag; string _horizontal_rule = "
"; if ((_xml_type != "html") || (obj.metainfo.heading_lev_markup == 0 || obj.metainfo.heading_lev_markup > 4)) { @@ -761,10 +779,16 @@ auto heading(M,O)( } _txt = font_face(_txt); string o; + seg_anchor_tag = (obj.tags.segment_anchor_tag.empty) + ? "" + : ""; + heading_lev_anchor_tag = (obj.tags.heading_lev_anchor_tag.empty) + ? "" + : ""; if (obj.metainfo.object_number.empty) { o = format(q"¶%s
- %s + %s%s %s
¶", @@ -772,7 +796,7 @@ auto heading(M,O)( obj.metainfo.heading_lev_markup, obj.metainfo.is_a, tags, - obj.tags.segment_anchor_tag, + heading_lev_anchor_tag, _txt, obj.metainfo.heading_lev_markup, ); @@ -780,7 +804,7 @@ auto heading(M,O)( o = format(q"¶%s
- %s + %s%s %s
¶", @@ -792,7 +816,7 @@ auto heading(M,O)( obj.metainfo.object_number, obj.metainfo.object_number, tags, - obj.tags.segment_anchor_tag, + heading_lev_anchor_tag, _txt, obj.metainfo.heading_lev_markup, ); @@ -811,7 +835,7 @@ auto heading_scroll(M,O)( string _txt, string _suffix = ".html", ) { - auto tags = _xhtml_anchor_tags(obj.tags.anchor_tags); + auto tags = _xhtml_anchor_tags(obj); _txt = inline_markup_scroll(doc_matters, obj, _txt, _suffix); string o = heading(doc_matters, obj, _txt); return o; @@ -851,7 +875,7 @@ auto para(M,O)( const O obj, string _txt, ) { - auto tags = _xhtml_anchor_tags(obj.tags.anchor_tags); + auto tags = _xhtml_anchor_tags(obj); _txt = font_face(_txt); string o; _txt = (obj.attrib.bullet) ? ("●  " ~ _txt) : _txt; @@ -898,7 +922,7 @@ auto para_scroll(M,O)( string _txt, string _suffix = ".html", ) { - auto tags = _xhtml_anchor_tags(obj.tags.anchor_tags); + auto tags = _xhtml_anchor_tags(obj); _txt = inline_markup_scroll(doc_matters, obj, _txt, _suffix); string o = para(doc_matters, obj, _txt); return o; @@ -977,7 +1001,7 @@ auto quote_scroll(M,O)( string _txt, string _suffix = ".html", ) { - auto tags = _xhtml_anchor_tags(obj.tags.anchor_tags); + auto tags = _xhtml_anchor_tags(obj); _txt = inline_markup_scroll(doc_matters, obj, _txt, _suffix); string o = quote(doc_matters, obj, _txt); return o; @@ -1057,7 +1081,7 @@ auto group_scroll(M,O)( string _suffix = ".html", string _xml_type = "html", ) { - auto tags = _xhtml_anchor_tags(obj.tags.anchor_tags); + auto tags = _xhtml_anchor_tags(obj); _txt = inline_markup_scroll(doc_matters, obj, _txt, _suffix); string o = group(doc_matters, obj, _txt); return o; @@ -1133,7 +1157,7 @@ auto block_scroll(M,O)( string _suffix = ".html", string _xml_type = "html", ) { - auto tags = _xhtml_anchor_tags(obj.tags.anchor_tags); + auto tags = _xhtml_anchor_tags(obj); _txt = inline_markup_scroll(doc_matters, obj, _txt, _suffix); string o = block(doc_matters, obj, _txt); return o; @@ -1209,7 +1233,7 @@ auto verse_scroll(M,O)( string _suffix = ".html", string _xml_type = "html", ) { - auto tags = _xhtml_anchor_tags(obj.tags.anchor_tags); + auto tags = _xhtml_anchor_tags(obj); _txt = inline_markup_scroll(doc_matters, obj, _txt, _suffix); string o = verse(doc_matters, obj, _txt); return o; @@ -1330,7 +1354,7 @@ auto table(M,O)( const O obj, string _txt, ) { - auto tags = _xhtml_anchor_tags(obj.tags.anchor_tags); + auto tags = _xhtml_anchor_tags(obj); _txt = font_face(_txt); auto t = tablarize(doc_matters, obj, _txt); _txt = t[0]; @@ -1933,7 +1957,7 @@ template outputEPub3() { #+END_SRC ** special (epub) files :format: -*** DONE static +*** static **** _identify doc filetype_ (mimetype) [static] - mimetype file indicating that zip file contains an EPUB @@ -2114,7 +2138,7 @@ string epub3_oebps_toc_nav_xhtml(D,I)(D doc_abstraction, I doc_matters) { if (obj.metainfo.heading_lev_markup < 4) { toc ~= markup.indent_by_spaces_provided((n + 1), " ") ~ "
  • " ~ "\n" ~ markup.indent_by_spaces_provided((n + 2), " ") - ~ "" + ~ "" ~ _txt ~ "" ~ "\n"; } else { @@ -2123,7 +2147,7 @@ string epub3_oebps_toc_nav_xhtml(D,I)(D doc_abstraction, I doc_matters) { : ("#" ~ obj.metainfo.ocn.to!string); toc ~= markup.indent_by_spaces_provided((n + 1), " ") ~ "
  • " ~ "\n" ~ markup.indent_by_spaces_provided((n + 2), " ") - ~ "" + ~ "" ~ _txt ~ "" ~ "\n"; } @@ -2133,7 +2157,7 @@ string epub3_oebps_toc_nav_xhtml(D,I)(D doc_abstraction, I doc_matters) { if (obj.metainfo.heading_lev_markup < 4) { toc ~= markup.indent_by_spaces_provided((n + 1), " ") ~ "
  • " ~ "\n" ~ markup.indent_by_spaces_provided((n + 2), " ") - ~ "" + ~ "" ~ _txt ~ "" ~ "\n"; } else { @@ -2142,7 +2166,7 @@ string epub3_oebps_toc_nav_xhtml(D,I)(D doc_abstraction, I doc_matters) { : ("#" ~ obj.metainfo.ocn.to!string); toc ~= markup.indent_by_spaces_provided((n + 1), " ") ~ "
  • " ~ "\n" ~ markup.indent_by_spaces_provided((n + 2), " ") - ~ "" + ~ "" ~ _txt ~ "" ~ "\n"; } @@ -2225,7 +2249,7 @@ string epub2_oebps_toc_ncx(D,I)(D doc_abstraction, I doc_matters) { ¶", counter, _txt, - obj.tags.segment_anchor_tag, + obj.tags.segment_anchor_tag_is, hashtag, ); break; @@ -2239,7 +2263,7 @@ string epub2_oebps_toc_ncx(D,I)(D doc_abstraction, I doc_matters) { ¶", counter, _txt, - obj.tags.segment_anchor_tag, + obj.tags.segment_anchor_tag_is, hashtag, ); break; @@ -2481,41 +2505,41 @@ void outputEPub3(D,I)( oepbs_content_parts["manifest_documents"] ~= format(q"¶ ¶", - obj.tags.segment_anchor_tag, - obj.tags.segment_anchor_tag, + obj.tags.segment_anchor_tag_is, + obj.tags.segment_anchor_tag_is, ); oepbs_content_parts["spine"] ~= format(q"¶ ¶", - obj.tags.segment_anchor_tag, + obj.tags.segment_anchor_tag_is, ); oepbs_content_parts["guide"] ~= format(q"¶ ¶", - obj.tags.segment_anchor_tag, - obj.tags.segment_anchor_tag, + obj.tags.segment_anchor_tag_is, + obj.tags.segment_anchor_tag_is, ); } else if (obj.metainfo.heading_lev_markup > 4) { oepbs_content_parts["manifest_documents"] ~= format(q"¶ ¶", - obj.tags.segment_anchor_tag, + obj.tags.segment_anchor_tag_is, obj.metainfo.object_number, - obj.tags.segment_anchor_tag, + obj.tags.segment_anchor_tag_is, obj.metainfo.object_number, ); oepbs_content_parts["spine"] ~= format(q"¶ ¶", - obj.tags.segment_anchor_tag, + obj.tags.segment_anchor_tag_is, obj.metainfo.object_number, ); oepbs_content_parts["guide"] ~= format(q"¶ ¶", - obj.tags.segment_anchor_tag, + obj.tags.segment_anchor_tag_is, obj.metainfo.object_number, - obj.tags.segment_anchor_tag, + obj.tags.segment_anchor_tag_is, obj.metainfo.object_number, ); } diff --git a/src/doc_reform/meta/metadoc.d b/src/doc_reform/meta/metadoc.d index 071b166..13502b3 100644 --- a/src/doc_reform/meta/metadoc.d +++ b/src/doc_reform/meta/metadoc.d @@ -26,7 +26,7 @@ template DocReformAbstraction() { mixin outputHub; enum headBody { header, body_content, insert_file_list, image_list } enum makeMeta { make, meta } - enum docAbst { doc_abstraction, section_keys, segnames, segnames_0_4, images } + enum docAbst { doc_abstraction, section_keys, segnames, segnames_0_4, tag_assoc, images } static auto rgx = Rgx(); auto DocReformAbstraction(E,O,M)( E _env, @@ -80,11 +80,12 @@ template DocReformAbstraction() { true, ); static assert(!isTypeTuple!(da)); - static assert(da.length==5); + static assert(da.length==6); auto doc_abstraction = da[docAbst.doc_abstraction]; /+ head ~ toc ~ body ~ endnotes_seg ~ glossary ~ bibliography ~ bookindex ~ blurb; +/ auto _document_section_keys_sequenced = da[docAbst.section_keys]; string[] _doc_html_segnames = da[docAbst.segnames]; string[] _doc_epub_segnames_0_4 = da[docAbst.segnames_0_4]; + auto _doc_tag_assoc = da[docAbst.tag_assoc]; auto _images = da[docAbst.images]; debug(steps) { writeln("- step3 complete"); @@ -159,6 +160,9 @@ template DocReformAbstraction() { string[] segnames_lv_0_to_4() { return _doc_epub_segnames_0_4; } + auto tag_associations() { + return _doc_tag_assoc; + } } return XML_(); } diff --git a/src/doc_reform/meta/metadoc_from_src.d b/src/doc_reform/meta/metadoc_from_src.d index 7643a42..6d04725 100644 --- a/src/doc_reform/meta/metadoc_from_src.d +++ b/src/doc_reform/meta/metadoc_from_src.d @@ -29,8 +29,11 @@ template DocReformDocAbstraction() { string[string] an_object, processing; string an_object_key; string[] anchor_tags; + string anchor_tag; string anchor_tag_; string segment_anchor_tag_that_object_belongs_to; + string lev_anchor_tag; + string[][string] tag_assoc; string segment_anchor_tag_that_object_belongs_to_uri; /+ enum +/ enum State { off, on } @@ -234,7 +237,7 @@ template DocReformDocAbstraction() { /+ node +/ ObjGenericComposite comp_obj_heading, comp_obj_location, comp_obj_block, comp_obj_code, comp_obj_poem_ocn, comp_obj_comment; auto node_construct = NodeStructureMetadata(); - enum sObj { content, anchor_tags, notes_reg, notes_star, links, image_no_dimensions } + enum sObj { content, anchor_tag, notes_reg, notes_star, links, image_no_dimensions } /+ ↓ abstract marked up document +/ auto DocReformDocAbstraction(Src,CMM,Opt,Mfst)( Src markup_sourcefile_content, @@ -336,6 +339,7 @@ template DocReformDocAbstraction() { 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_.tags.segment_anchor_tag_is = comp_obj_heading_.tags.segment_anchor_tag; comp_obj_heading_.metainfo.heading_lev_markup = 4; comp_obj_heading_.metainfo.heading_lev_collapsed = 1; comp_obj_heading_.metainfo.parent_ocn = 1; @@ -475,6 +479,7 @@ template DocReformDocAbstraction() { comp_obj_heading_.metainfo.object_number_off = ""; comp_obj_heading_.metainfo.object_number_type = 0; comp_obj_heading_.tags.segment_anchor_tag = "_part_glossary"; + comp_obj_heading_.tags.segment_anchor_tag_is = comp_obj_heading_.tags.segment_anchor_tag; comp_obj_heading_.metainfo.heading_lev_markup = 1; comp_obj_heading_.metainfo.heading_lev_collapsed = 1; comp_obj_heading_.metainfo.parent_ocn = 1; @@ -492,6 +497,7 @@ template DocReformDocAbstraction() { comp_obj_heading_.metainfo.object_number_off = ""; comp_obj_heading_.metainfo.object_number_type = 0; comp_obj_heading_.tags.segment_anchor_tag = "glossary"; + comp_obj_heading_.tags.segment_anchor_tag_is = comp_obj_heading_.tags.segment_anchor_tag; comp_obj_heading_.metainfo.heading_lev_markup = 4; comp_obj_heading_.metainfo.heading_lev_collapsed = 2; comp_obj_heading_.metainfo.parent_ocn = 1; @@ -581,6 +587,7 @@ template DocReformDocAbstraction() { 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_.tags.segment_anchor_tag_is = comp_obj_heading_.tags.segment_anchor_tag; comp_obj_heading_.metainfo.heading_lev_markup = 1; comp_obj_heading_.metainfo.heading_lev_collapsed = 1; comp_obj_heading_.metainfo.parent_ocn = 1; @@ -598,6 +605,7 @@ template DocReformDocAbstraction() { 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_.tags.segment_anchor_tag_is = comp_obj_heading_.tags.segment_anchor_tag; comp_obj_heading_.metainfo.heading_lev_markup = 4; comp_obj_heading_.metainfo.heading_lev_collapsed = 2; comp_obj_heading_.metainfo.parent_ocn = 1; @@ -618,6 +626,7 @@ template DocReformDocAbstraction() { 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_.tags.segment_anchor_tag_is = comp_obj_heading_.tags.segment_anchor_tag; comp_obj_heading_.metainfo.heading_lev_markup = an_object["lev_markup_number"].to!int; // make int, remove need to conv 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; @@ -837,7 +846,7 @@ template DocReformDocAbstraction() { auto substantive_object_and_anchor_tags_tuple = obj_im.obj_inline_markup_and_anchor_tags_and_misc(an_object, an_object_key, conf_make_meta, _new_doc); an_object["substantive"] = substantive_object_and_anchor_tags_tuple[sObj.content]; - anchor_tags = substantive_object_and_anchor_tags_tuple[sObj.anchor_tags]; + anchor_tag = substantive_object_and_anchor_tags_tuple[sObj.anchor_tag]; if (_new_doc) { cnt1 = 1; cnt2 = 1; @@ -846,13 +855,17 @@ template DocReformDocAbstraction() { } if ( an_object["lev_markup_number"].to!int == 4 - && anchor_tags.length > 0 + && !(anchor_tag.empty) ) { - 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]; + segment_anchor_tag_that_object_belongs_to = anchor_tag; + lev_anchor_tag = anchor_tag; + tag_assoc[anchor_tag] = [segment_anchor_tag_that_object_belongs_to]; + segment_anchor_tag_that_object_belongs_to_uri = anchor_tag ~ ".fnSuffix"; + anchor_tag_ = anchor_tag; } else if (an_object["lev_markup_number"].to!int > 4) { segment_anchor_tag_that_object_belongs_to = anchor_tag_; + lev_anchor_tag = anchor_tag; + tag_assoc[anchor_tag] = [segment_anchor_tag_that_object_belongs_to]; segment_anchor_tag_that_object_belongs_to_uri = anchor_tag_ ~ ".fnSuffix#" ~ obj_cite_digits.on.to!string; } else if (an_object["lev_markup_number"].to!int < 4) { string segn; @@ -883,7 +896,7 @@ template DocReformDocAbstraction() { bookindex_unordered_hashes = bookindex_extract_hash.bookindex_nugget_hash(an_object["bookindex_nugget"], obj_cite_digits, segment_anchor_tag_that_object_belongs_to); /+ (incrementally build toc) table of contents here! +/ - _anchor_tag=to!string(obj_cite_digits.on); + _anchor_tag=obj_cite_digits.on.to!string; the_table_of_contents_section = obj_im.table_of_contents_gather_headings( an_object, conf_make_meta, @@ -903,6 +916,8 @@ template DocReformDocAbstraction() { an_object["lev_markup_number"], // string an_object["lev_collapsed_number"], // string segment_anchor_tag_that_object_belongs_to, // string + lev_anchor_tag, // string + tag_assoc, obj_cite_digits, // OCNset cntr, // int heading_ptr, // int @@ -940,6 +955,8 @@ template DocReformDocAbstraction() { = node_construct.node_location_emitter( content_non_header, segment_anchor_tag_that_object_belongs_to, + lev_anchor_tag, + tag_assoc, obj_cite_digits, cntr, heading_ptr-1, @@ -948,14 +965,14 @@ template DocReformDocAbstraction() { auto substantive_obj_misc_tuple = obj_im.obj_inline_markup_and_anchor_tags_and_misc(an_object, an_object_key, conf_make_meta, false); an_object["substantive"] = substantive_obj_misc_tuple[sObj.content]; - anchor_tags = substantive_obj_misc_tuple[sObj.anchor_tags]; + anchor_tag = substantive_obj_misc_tuple[sObj.anchor_tag]; comp_obj_para = comp_obj_para.init; comp_obj_para.metainfo.is_of_part = "body"; comp_obj_para.metainfo.is_of_section = "body"; comp_obj_para.metainfo.is_of_type = "para"; comp_obj_para.metainfo.is_a = "para"; comp_obj_para.text = an_object["substantive"].to!string.strip; - comp_obj_para.tags.segment_anchor_tag = segment_anchor_tag_that_object_belongs_to.to!string; // TODO + comp_obj_para.tags.segment_anchor_tag_is = segment_anchor_tag_that_object_belongs_to; comp_obj_para.metainfo.ocn = obj_cite_digits.digit; comp_obj_para.metainfo.object_number_off = (obj_cite_digits.off==0) ? "" : obj_cite_digits.off.to!string; comp_obj_para.metainfo.o_n_book_index = obj_cite_digits.bkidx; @@ -963,7 +980,7 @@ template DocReformDocAbstraction() { comp_obj_para.attrib.indent_hang = indent["hang_position"]; comp_obj_para.attrib.indent_base = indent["base_position"]; comp_obj_para.attrib.bullet = bullet; - comp_obj_para.tags.anchor_tags = anchor_tags; + comp_obj_para.tags.anchor_tags = [anchor_tag]; comp_obj_para.has.inline_notes_reg = substantive_obj_misc_tuple[sObj.notes_reg]; comp_obj_para.has.inline_notes_star = substantive_obj_misc_tuple[sObj.notes_star]; comp_obj_para.has.inline_links = substantive_obj_misc_tuple[sObj.links]; @@ -1083,6 +1100,7 @@ template DocReformDocAbstraction() { comp_obj_heading_.metainfo.object_number_off = ""; comp_obj_heading_.metainfo.object_number_type = 0; comp_obj_heading_.tags.segment_anchor_tag = "_part_bibliography"; + comp_obj_heading_.tags.segment_anchor_tag_is = comp_obj_heading_.tags.segment_anchor_tag; comp_obj_heading_.metainfo.heading_lev_markup = 1; comp_obj_heading_.metainfo.heading_lev_collapsed = 1; comp_obj_heading_.metainfo.parent_ocn = 1; @@ -1098,6 +1116,7 @@ template DocReformDocAbstraction() { comp_obj_heading_.metainfo.object_number_off = ""; comp_obj_heading_.metainfo.object_number_type = 0; comp_obj_heading_.tags.segment_anchor_tag = "bibliography"; + comp_obj_heading_.tags.segment_anchor_tag_is = comp_obj_heading_.tags.segment_anchor_tag; comp_obj_heading_.metainfo.heading_lev_markup = 4; comp_obj_heading_.metainfo.heading_lev_collapsed = 2; comp_obj_heading_.metainfo.parent_ocn = 1; @@ -1148,7 +1167,7 @@ template DocReformDocAbstraction() { comp_obj_para.attrib.indent_hang = 0; comp_obj_para.attrib.indent_base = 1; comp_obj_para.attrib.bullet = bullet; - comp_obj_para.tags.anchor_tags = anchor_tags; + comp_obj_para.tags.anchor_tags = [anchor_tag]; the_bibliography_section ~= comp_obj_para; } debug(bibliosection) { @@ -1183,6 +1202,7 @@ template DocReformDocAbstraction() { comp_obj_para.metainfo.object_number_off = ""; comp_obj_para.metainfo.object_number_type = 0; comp_obj_heading_.tags.segment_anchor_tag = ""; + comp_obj_heading_.tags.segment_anchor_tag_is = comp_obj_heading_.tags.segment_anchor_tag; comp_obj_heading_.metainfo.heading_lev_markup = 1; comp_obj_heading_.metainfo.heading_lev_collapsed = 1; comp_obj_heading_.metainfo.parent_ocn = 1; @@ -1214,7 +1234,7 @@ template DocReformDocAbstraction() { "{ %s }%s%s%s", "Endnotes", mkup.mark_internal_site_lnk, - "endnotes", // segment_anchor_tag_that_object_belongs_to + "endnotes", ".fnSuffix", ); toc_txt_= munge.url_links(toc_txt_); @@ -1227,7 +1247,7 @@ template DocReformDocAbstraction() { "{ %s }%s%s%s", "Glossary", mkup.mark_internal_site_lnk, - "glossary", // segment_anchor_tag_that_object_belongs_to + "glossary", ".fnSuffix", ); toc_txt_= munge.url_links(toc_txt_); @@ -1249,7 +1269,7 @@ template DocReformDocAbstraction() { "{ %s }%s%s%s", "Bibliography", mkup.mark_internal_site_lnk, - "bibliography", // segment_anchor_tag_that_object_belongs_to + "bibliography", ".fnSuffix", ); toc_txt_= munge.url_links(toc_txt_); @@ -1272,7 +1292,7 @@ template DocReformDocAbstraction() { "{ %s }%s%s%s", "Book Index", mkup.mark_internal_site_lnk, - "bookindex", // segment_anchor_tag_that_object_belongs_to + "bookindex", ".fnSuffix", ); toc_txt_= munge.url_links(toc_txt_); @@ -1296,7 +1316,7 @@ template DocReformDocAbstraction() { "{ %s }%s%s%s", "Blurb", mkup.mark_internal_site_lnk, - "blurb", // segment_anchor_tag_that_object_belongs_to + "blurb", ".fnSuffix", ); toc_txt_= munge.url_links(toc_txt_); @@ -1659,7 +1679,7 @@ template DocReformDocAbstraction() { } return images_; } - string[] segnames_0_4; + string[] segnames_lv0_to_4; auto _image_dimensions(M,O)(M manifest_matter, O obj) { if (obj.has.contains_image_without_dimensions) { import std.math; @@ -1700,7 +1720,7 @@ template DocReformDocAbstraction() { writeln(obj.text); } if (obj.metainfo.heading_lev_markup <= 4) { - segnames_0_4 ~= obj.tags.segment_anchor_tag; + segnames_lv0_to_4 ~= obj.tags.segment_anchor_tag; } if (obj.metainfo.heading_lev_markup == 0) { /+ TODO second hit (of two) with same assertion failure, check, fix and reinstate @@ -1730,7 +1750,7 @@ template DocReformDocAbstraction() { foreach (ref obj; the_table_of_contents_section["scroll"]) { if (obj.metainfo.is_a == "heading") { if (obj.metainfo.heading_lev_markup <= 4) { - segnames_0_4 ~= obj.tags.segment_anchor_tag; + segnames_lv0_to_4 ~= obj.tags.segment_anchor_tag; if (obj.metainfo.heading_lev_markup == 4) { obj.tags.segname_next = html_segnames[obj.ptr.html_segnames + 1]; assert(obj.tags.segment_anchor_tag == html_segnames[obj.ptr.html_segnames], @@ -1759,7 +1779,7 @@ template DocReformDocAbstraction() { writeln(obj.text); } if (obj.metainfo.heading_lev_markup <= 4) { - segnames_0_4 ~= obj.tags.segment_anchor_tag; + segnames_lv0_to_4 ~= obj.tags.segment_anchor_tag; if (obj.metainfo.heading_lev_markup == 4) { obj.tags.segname_next = html_segnames[obj.ptr.html_segnames + 1]; assert(obj.tags.segment_anchor_tag == html_segnames[obj.ptr.html_segnames], @@ -1785,7 +1805,7 @@ template DocReformDocAbstraction() { writeln(obj.text); } if (obj.metainfo.heading_lev_markup <= 4) { - segnames_0_4 ~= obj.tags.segment_anchor_tag; + segnames_lv0_to_4 ~= obj.tags.segment_anchor_tag; if (obj.metainfo.heading_lev_markup == 4) { obj.tags.lev4_subtoc = lev4_subtoc[obj.tags.segment_anchor_tag]; obj.tags.segname_prev = html_segnames[obj.ptr.html_segnames - 1]; @@ -1828,7 +1848,7 @@ template DocReformDocAbstraction() { obj_cite_digits = ocn_emit(OCNstatus.on); obj.metainfo.ocn = obj_cite_digits.digit; if (obj.metainfo.heading_lev_markup <= 4) { - segnames_0_4 ~= obj.tags.segment_anchor_tag; + segnames_lv0_to_4 ~= obj.tags.segment_anchor_tag; if (obj.metainfo.heading_lev_markup == 4) { obj.tags.segname_prev = html_segnames[obj.ptr.html_segnames - 1]; if (html_segnames.length > obj.ptr.html_segnames + 1) { @@ -1862,7 +1882,7 @@ template DocReformDocAbstraction() { obj_cite_digits = ocn_emit(OCNstatus.on); obj.metainfo.ocn = obj_cite_digits.digit; if (obj.metainfo.heading_lev_markup <= 4) { - segnames_0_4 ~= obj.tags.segment_anchor_tag; + segnames_lv0_to_4 ~= obj.tags.segment_anchor_tag; if (obj.metainfo.heading_lev_markup == 4) { obj.tags.segname_prev = html_segnames[obj.ptr.html_segnames - 1]; if (html_segnames.length > obj.ptr.html_segnames + 1) { @@ -1899,7 +1919,7 @@ template DocReformDocAbstraction() { obj_cite_digits = ocn_emit(OCNstatus.on); obj.metainfo.ocn = obj_cite_digits.digit; if (obj.metainfo.heading_lev_markup <= 4) { - segnames_0_4 ~= obj.tags.segment_anchor_tag; + segnames_lv0_to_4 ~= obj.tags.segment_anchor_tag; if (obj.metainfo.heading_lev_markup == 4) { obj.tags.segname_prev = html_segnames[obj.ptr.html_segnames - 1]; if (html_segnames.length > obj.ptr.html_segnames + 1) { @@ -1941,7 +1961,7 @@ template DocReformDocAbstraction() { obj_cite_digits = ocn_emit(OCNstatus.on); obj.metainfo.ocn = obj_cite_digits.on; if (obj.metainfo.heading_lev_markup <= 4) { - segnames_0_4 ~= obj.tags.segment_anchor_tag; + segnames_lv0_to_4 ~= obj.tags.segment_anchor_tag; if (obj.metainfo.heading_lev_markup == 4) { obj.tags.segname_prev = html_segnames[obj.ptr.html_segnames - 1]; if (html_segnames.length > obj.ptr.html_segnames + 1) { @@ -1979,7 +1999,7 @@ template DocReformDocAbstraction() { } obj.metainfo.ocn = ++ocn_; if (obj.metainfo.heading_lev_markup <= 4) { - segnames_0_4 ~= obj.tags.segment_anchor_tag; + segnames_lv0_to_4 ~= obj.tags.segment_anchor_tag; if (obj.metainfo.heading_lev_markup == 4) { obj.tags.segname_prev = html_segnames[obj.ptr.html_segnames - 1]; if (html_segnames.length > obj.ptr.html_segnames + 1) { @@ -2021,7 +2041,7 @@ template DocReformDocAbstraction() { obj_cite_digits = ocn_emit(OCNstatus.on); obj.metainfo.ocn = obj_cite_digits.on; if (obj.metainfo.heading_lev_markup <= 4) { - segnames_0_4 ~= obj.tags.segment_anchor_tag; + segnames_lv0_to_4 ~= obj.tags.segment_anchor_tag; if (obj.metainfo.heading_lev_markup == 4) { obj.tags.segname_prev = html_segnames[obj.ptr.html_segnames - 1]; if (html_segnames.length > obj.ptr.html_segnames + 1) { @@ -2221,7 +2241,7 @@ template DocReformDocAbstraction() { document_section_keys_sequenced["scroll"] ~= "tail"; } auto sequenced_document_keys = docSectKeysSeq!()(document_section_keys_sequenced); - auto segnames = html_segnames.dup; + auto segnames_lv4 = html_segnames.dup; destroy(the_document_head_section); destroy(the_table_of_contents_section); destroy(the_document_body_section); @@ -2290,8 +2310,9 @@ template DocReformDocAbstraction() { auto t = tuple( document_the, sequenced_document_keys, - segnames, - segnames_0_4, + segnames_lv4, + segnames_lv0_to_4, + tag_assoc, images, ); return t; @@ -2766,7 +2787,7 @@ template DocReformDocAbstraction() { auto substantive_obj_misc_tuple = obj_im.obj_inline_markup_and_anchor_tags_and_misc(an_object, an_object_key, conf_make_meta, false); an_object["substantive"] = substantive_obj_misc_tuple[sObj.content]; - anchor_tags = substantive_obj_misc_tuple[sObj.anchor_tags]; + anchor_tag = substantive_obj_misc_tuple[sObj.anchor_tag]; comp_obj_block = comp_obj_block.init; comp_obj_block.metainfo.is_of_part = "body"; comp_obj_block.metainfo.is_of_section = "body"; @@ -2774,7 +2795,7 @@ template DocReformDocAbstraction() { comp_obj_block.metainfo.is_a = "verse"; comp_obj_block.metainfo.ocn = obj_cite_digits.on; comp_obj_block.metainfo.object_number_off = (obj_cite_digits.off==0) ? "" : obj_cite_digits.off.to!string; - comp_obj_block.tags.segment_anchor_tag = segment_anchor_tag_that_object_belongs_to.to!string; // TODO + comp_obj_block.tags.segment_anchor_tag_is = segment_anchor_tag_that_object_belongs_to; comp_obj_block.metainfo.o_n_book_index = obj_cite_digits.bkidx; comp_obj_block.metainfo.object_number_type = obj_cite_digits.type; comp_obj_block.text = an_object["substantive"]; @@ -2816,6 +2837,8 @@ template DocReformDocAbstraction() { auto comp_obj_location = node_construct.node_location_emitter( content_non_header, segment_anchor_tag_that_object_belongs_to, + lev_anchor_tag, + tag_assoc, obj_cite_digits, cntr, heading_ptr-1, @@ -2824,7 +2847,7 @@ template DocReformDocAbstraction() { auto substantive_obj_misc_tuple = obj_im.obj_inline_markup_and_anchor_tags_and_misc(an_object, an_object_key, conf_make_meta, false); an_object["substantive"] = substantive_obj_misc_tuple[sObj.content]; - anchor_tags = substantive_obj_misc_tuple[sObj.anchor_tags]; + anchor_tag = substantive_obj_misc_tuple[sObj.anchor_tag]; comp_obj_block = comp_obj_block.init; comp_obj_block.metainfo.is_of_part = "body"; comp_obj_block.metainfo.is_of_section = "body"; @@ -2832,7 +2855,7 @@ template DocReformDocAbstraction() { comp_obj_block.metainfo.is_a = "verse"; comp_obj_block.metainfo.ocn = obj_cite_digits.on; comp_obj_block.metainfo.object_number_off = (obj_cite_digits.off==0) ? "" : obj_cite_digits.off.to!string; - comp_obj_block.tags.segment_anchor_tag = segment_anchor_tag_that_object_belongs_to.to!string; // TODO + comp_obj_block.tags.segment_anchor_tag_is = segment_anchor_tag_that_object_belongs_to; comp_obj_block.metainfo.o_n_book_index = obj_cite_digits.bkidx; comp_obj_block.metainfo.object_number_type = obj_cite_digits.type; comp_obj_block.text = an_object["substantive"]; @@ -2867,7 +2890,7 @@ template DocReformDocAbstraction() { auto substantive_obj_misc_tuple = obj_im.obj_inline_markup_and_anchor_tags_and_misc(an_object, an_object_key, conf_make_meta, false); an_object["substantive"] = substantive_obj_misc_tuple[sObj.content]; - anchor_tags = substantive_obj_misc_tuple[sObj.anchor_tags]; + anchor_tag = substantive_obj_misc_tuple[sObj.anchor_tag]; comp_obj_block = comp_obj_block.init; comp_obj_block.metainfo.is_of_part = "body"; comp_obj_block.metainfo.is_of_section = "body"; @@ -2875,7 +2898,7 @@ template DocReformDocAbstraction() { comp_obj_block.metainfo.is_a = "verse"; comp_obj_block.metainfo.ocn = obj_cite_digits.on; comp_obj_block.metainfo.object_number_off = (obj_cite_digits.off==0) ? "" : obj_cite_digits.off.to!string; - comp_obj_block.tags.segment_anchor_tag = segment_anchor_tag_that_object_belongs_to.to!string; // TODO + comp_obj_block.tags.segment_anchor_tag_is = segment_anchor_tag_that_object_belongs_to; comp_obj_block.metainfo.o_n_book_index = obj_cite_digits.bkidx; comp_obj_block.metainfo.object_number_type = obj_cite_digits.type; comp_obj_block.text = an_object["substantive"]; @@ -2917,6 +2940,8 @@ template DocReformDocAbstraction() { = node_construct.node_location_emitter( content_non_header, segment_anchor_tag_that_object_belongs_to, + lev_anchor_tag, + tag_assoc, obj_cite_digits, cntr, heading_ptr-1, @@ -2925,7 +2950,7 @@ template DocReformDocAbstraction() { auto substantive_obj_misc_tuple = obj_im.obj_inline_markup_and_anchor_tags_and_misc(an_object, an_object_key, conf_make_meta, false); an_object["substantive"] = substantive_obj_misc_tuple[sObj.content]; - anchor_tags = substantive_obj_misc_tuple[sObj.anchor_tags]; + anchor_tag = substantive_obj_misc_tuple[sObj.anchor_tag]; comp_obj_block = comp_obj_block.init; comp_obj_block.metainfo.is_of_part = "body"; comp_obj_block.metainfo.is_of_section = "body"; @@ -2933,7 +2958,7 @@ template DocReformDocAbstraction() { comp_obj_block.metainfo.is_a = "verse"; comp_obj_block.metainfo.ocn = obj_cite_digits.on; comp_obj_block.metainfo.object_number_off = (obj_cite_digits.off==0) ? "" : obj_cite_digits.off.to!string; - comp_obj_block.tags.segment_anchor_tag = segment_anchor_tag_that_object_belongs_to.to!string; // TODO + comp_obj_block.tags.segment_anchor_tag_is = segment_anchor_tag_that_object_belongs_to; comp_obj_block.metainfo.o_n_book_index = obj_cite_digits.bkidx; comp_obj_block.metainfo.object_number_type = obj_cite_digits.type; comp_obj_block.text = an_object["substantive"]; @@ -3218,6 +3243,8 @@ template DocReformDocAbstraction() { = node_construct.node_location_emitter( content_non_header, segment_anchor_tag_that_object_belongs_to, + lev_anchor_tag, + tag_assoc, obj_cite_digits, cntr, heading_ptr-1, @@ -3229,7 +3256,7 @@ template DocReformDocAbstraction() { an_object["substantive"] = substantive_obj_misc_tuple[sObj.content]; comp_obj_block.metainfo.ocn = obj_cite_digits.on; comp_obj_block.metainfo.object_number_off = (obj_cite_digits.off==0) ? "" : obj_cite_digits.off.to!string; - comp_obj_block.tags.segment_anchor_tag = segment_anchor_tag_that_object_belongs_to.to!string; // TODO + comp_obj_block.tags.segment_anchor_tag_is = segment_anchor_tag_that_object_belongs_to; comp_obj_block.metainfo.o_n_book_index = obj_cite_digits.bkidx; comp_obj_block.metainfo.object_number_type = obj_cite_digits.type; comp_obj_block = table_instructions(comp_obj_block, an_object["table_head"]); @@ -3278,6 +3305,8 @@ template DocReformDocAbstraction() { = node_construct.node_location_emitter( content_non_header, segment_anchor_tag_that_object_belongs_to, + lev_anchor_tag, + tag_assoc, obj_cite_digits, cntr, heading_ptr-1, @@ -3286,7 +3315,7 @@ template DocReformDocAbstraction() { auto substantive_obj_misc_tuple = obj_im.obj_inline_markup_and_anchor_tags_and_misc(an_object, an_object_key, conf_make_meta, false); an_object["substantive"] = substantive_obj_misc_tuple[sObj.content]; - anchor_tags = substantive_obj_misc_tuple[sObj.anchor_tags]; + anchor_tag = substantive_obj_misc_tuple[sObj.anchor_tag]; comp_obj_block = comp_obj_block.init; comp_obj_block.metainfo.is_of_part = "body"; comp_obj_block.metainfo.is_of_section = "body"; @@ -3294,7 +3323,7 @@ template DocReformDocAbstraction() { comp_obj_block.metainfo.is_a = "quote"; comp_obj_block.metainfo.ocn = obj_cite_digits.on; comp_obj_block.metainfo.object_number_off = (obj_cite_digits.off==0) ? "" : obj_cite_digits.off.to!string; - comp_obj_block.tags.segment_anchor_tag = segment_anchor_tag_that_object_belongs_to.to!string; // TODO + comp_obj_block.tags.segment_anchor_tag_is = segment_anchor_tag_that_object_belongs_to; comp_obj_block.metainfo.o_n_book_index = obj_cite_digits.bkidx; comp_obj_block.metainfo.object_number_type = obj_cite_digit_type; comp_obj_block.text = an_object["substantive"]; @@ -3322,6 +3351,8 @@ template DocReformDocAbstraction() { = node_construct.node_location_emitter( content_non_header, segment_anchor_tag_that_object_belongs_to, + lev_anchor_tag, + tag_assoc, obj_cite_digits, cntr, heading_ptr-1, @@ -3330,7 +3361,7 @@ template DocReformDocAbstraction() { auto substantive_obj_misc_tuple = obj_im.obj_inline_markup_and_anchor_tags_and_misc(an_object, an_object_key, conf_make_meta, false); an_object["substantive"] = substantive_obj_misc_tuple[sObj.content]; - anchor_tags = substantive_obj_misc_tuple[sObj.anchor_tags]; + anchor_tag = substantive_obj_misc_tuple[sObj.anchor_tag]; comp_obj_block = comp_obj_block.init; comp_obj_block.metainfo.is_of_part = "body"; comp_obj_block.metainfo.is_of_section = "body"; @@ -3338,7 +3369,7 @@ template DocReformDocAbstraction() { comp_obj_block.metainfo.is_a = "group"; comp_obj_block.metainfo.ocn = obj_cite_digits.on; comp_obj_block.metainfo.object_number_off = (obj_cite_digits.off==0) ? "" : obj_cite_digits.off.to!string; - comp_obj_block.tags.segment_anchor_tag = segment_anchor_tag_that_object_belongs_to.to!string; // TODO + comp_obj_block.tags.segment_anchor_tag_is = segment_anchor_tag_that_object_belongs_to; comp_obj_block.metainfo.o_n_book_index = obj_cite_digits.bkidx; comp_obj_block.metainfo.object_number_type = obj_cite_digits.type; comp_obj_block.text = an_object["substantive"]; @@ -3366,6 +3397,8 @@ template DocReformDocAbstraction() { = node_construct.node_location_emitter( content_non_header, segment_anchor_tag_that_object_belongs_to, + lev_anchor_tag, + tag_assoc, obj_cite_digits, cntr, heading_ptr-1, @@ -3381,7 +3414,7 @@ template DocReformDocAbstraction() { comp_obj_block.metainfo.is_a = "block"; comp_obj_block.metainfo.ocn = obj_cite_digits.on; comp_obj_block.metainfo.object_number_off = (obj_cite_digits.off==0) ? "" : obj_cite_digits.off.to!string; - comp_obj_block.tags.segment_anchor_tag = segment_anchor_tag_that_object_belongs_to.to!string; // TODO + comp_obj_block.tags.segment_anchor_tag_is = segment_anchor_tag_that_object_belongs_to; comp_obj_block.metainfo.o_n_book_index = obj_cite_digits.bkidx; comp_obj_block.metainfo.object_number_type = obj_cite_digit_type; comp_obj_block.text = an_object["substantive"]; @@ -3408,6 +3441,8 @@ template DocReformDocAbstraction() { = node_construct.node_location_emitter( content_non_header, segment_anchor_tag_that_object_belongs_to, + lev_anchor_tag, + tag_assoc, obj_cite_digits, cntr, heading_ptr-1, @@ -3443,6 +3478,8 @@ template DocReformDocAbstraction() { = node_construct.node_location_emitter( content_non_header, segment_anchor_tag_that_object_belongs_to, + lev_anchor_tag, + tag_assoc, obj_cite_digits, cntr, heading_ptr-1, @@ -3451,7 +3488,7 @@ template DocReformDocAbstraction() { auto substantive_obj_misc_tuple = obj_im.obj_inline_markup_and_anchor_tags_and_misc(an_object, an_object_key, conf_make_meta, false); an_object["substantive"] = substantive_obj_misc_tuple[sObj.content]; - anchor_tags = substantive_obj_misc_tuple[sObj.anchor_tags]; + anchor_tag = substantive_obj_misc_tuple[sObj.anchor_tag]; comp_obj_code = comp_obj_code.init; comp_obj_code.metainfo.is_of_part = "body"; comp_obj_code.metainfo.is_of_section = "body"; @@ -3459,7 +3496,7 @@ template DocReformDocAbstraction() { comp_obj_code.metainfo.is_a = "code"; comp_obj_code.metainfo.ocn = obj_cite_digits.on; comp_obj_code.metainfo.object_number_off = (obj_cite_digits.off==0) ? "" : obj_cite_digits.off.to!string; - comp_obj_code.tags.segment_anchor_tag = segment_anchor_tag_that_object_belongs_to.to!string; + comp_obj_code.tags.segment_anchor_tag_is = segment_anchor_tag_that_object_belongs_to; comp_obj_code.metainfo.o_n_book_index = obj_cite_digits.bkidx; comp_obj_code.metainfo.object_number_type = obj_cite_digits.type; comp_obj_code.text = an_object["substantive"]; @@ -3488,6 +3525,8 @@ template DocReformDocAbstraction() { = node_construct.node_location_emitter( content_non_header, segment_anchor_tag_that_object_belongs_to, + lev_anchor_tag, + tag_assoc, obj_cite_digits, cntr, heading_ptr-1, @@ -3499,7 +3538,7 @@ template DocReformDocAbstraction() { comp_obj_block = comp_obj_block.init; comp_obj_block.metainfo.ocn = obj_cite_digits.on; comp_obj_block.metainfo.object_number_off = (obj_cite_digits.off==0) ? "" : obj_cite_digits.off.to!string; - comp_obj_block.tags.segment_anchor_tag = segment_anchor_tag_that_object_belongs_to.to!string; // TODO + comp_obj_block.tags.segment_anchor_tag_is = segment_anchor_tag_that_object_belongs_to; comp_obj_block.metainfo.o_n_book_index = obj_cite_digits.bkidx; comp_obj_block.metainfo.object_number_type = obj_cite_digits.type; comp_obj_block = table_instructions(comp_obj_block, an_object["table_head"]); @@ -4345,7 +4384,7 @@ template DocReformDocAbstraction() { n_foot=n_foot_reg; obj_txt_out ~= n.hit.to!string.replaceFirst( rgx.inline_al_delimiter_open_regular, - (mkup.en_a_o ~ to!string(n_foot) ~ " ") + (mkup.en_a_o ~ n_foot.to!string ~ " ") ) ~ "\n"; } else { obj_txt_out ~= n.hit.to!string ~ "\n"; @@ -4557,7 +4596,6 @@ template DocReformDocAbstraction() { static auto rgx = Rgx(); static auto munge = ObjInlineMarkupMunge(); string[string] obj_txt; - static string[] anchor_tags_ = []; static string anchor_tag = ""; auto obj_inline_markup_and_anchor_tags_and_misc(O,K,CMM)( O obj_, @@ -4577,7 +4615,7 @@ template DocReformDocAbstraction() { ? obj_txt["munge"] : obj_txt["munge"].strip; if (_new_doc) { - anchor_tags_ = []; + anchor_tag = ""; } auto x = munge.init; bool[string] obj_notes_and_links; @@ -4594,7 +4632,6 @@ template DocReformDocAbstraction() { obj_txt["munge"]=_make_segment_anchor_tags_if_none_provided(obj_txt["munge"], obj_["lev"], _new_doc); if (auto m = obj_txt["munge"].match(rgx.heading_anchor_tag)) { anchor_tag = m.captures[1]; - anchor_tags_ ~= anchor_tag; } else if (obj_["lev"] == "1") { writeln("heading anchor tag missing: ", obj_txt["munge"]); } @@ -4640,13 +4677,13 @@ template DocReformDocAbstraction() { } auto t = tuple( obj_txt["munge"], - anchor_tags_, + anchor_tag, obj_notes_and_links["notes_reg"], obj_notes_and_links["notes_star"], obj_notes_and_links["links"], obj_notes_and_links["image_no_dimensions"], ); - anchor_tags_=[]; + anchor_tag = ""; return t; } invariant() { @@ -4957,7 +4994,8 @@ template DocReformDocAbstraction() { rgx.heading_marker_missing_tag, "$1~" ~ m.captures[1].toLower ~ "_" ~ m.captures[2] ~ " "); if (auto n = munge_.match(rgx.heading_anchor_tag_plus_colon)) { - auto tag_remunge_ = n.captures[2].replaceAll(rgx.heading_marker_tag_has_colon, ".."); + auto tag_remunge_ = n.captures[2] + .replaceAll(rgx.heading_marker_tag_has_colon, ".."); munge_=(munge_).replaceFirst(rgx.heading_anchor_tag_plus_colon, n.captures[1] ~ tag_remunge_ ~ " "); } } else if (auto m = munge_.match(rgx.heading_extract_unnamed_anchor_tag)) { @@ -5322,7 +5360,8 @@ template DocReformDocAbstraction() { main_term = m.captures[1].strip; object_number_offset = m.captures[2].to!int; object_number_endpoint=(obj_cite_digits.on + object_number_offset); - object_numbers ~= (obj_cite_digits.on.to!string ~ "-" ~ to!string(object_number_endpoint) + object_numbers ~= (obj_cite_digits.on.to!string + ~ "-" ~ object_number_endpoint.to!string ~ ":" ~ segment_anchor_tag); } else { main_term = bi_main_term_and_rest[0].strip; @@ -5341,11 +5380,12 @@ template DocReformDocAbstraction() { sub_term = m.captures[1].strip; object_number_offset = m.captures[2].to!int; object_number_endpoint=(obj_cite_digits.on + object_number_offset); - object_numbers ~= (obj_cite_digits.on.to!string ~ " - " ~ to!string(object_number_endpoint) + object_numbers ~= (obj_cite_digits.on.to!string + ~ " - " ~ object_number_endpoint.to!string ~ ":" ~ segment_anchor_tag); } else { sub_term = sub_terms_bits.strip; - object_numbers ~= to!string(obj_cite_digits.on) + object_numbers ~= obj_cite_digits.on.to!string ~ ":" ~ segment_anchor_tag; } if (!empty(sub_term)) { @@ -5462,6 +5502,7 @@ template DocReformDocAbstraction() { comp_obj_heading_.metainfo.object_number_off = ""; comp_obj_heading_.metainfo.object_number_type = 0; comp_obj_heading_.tags.segment_anchor_tag = "_part_book_index"; + comp_obj_heading_.tags.segment_anchor_tag_is = comp_obj_heading_.tags.segment_anchor_tag; comp_obj_heading_.metainfo.heading_lev_markup = 1; comp_obj_heading_.metainfo.heading_lev_collapsed = 1; comp_obj_heading_.metainfo.parent_ocn = 1; @@ -5480,6 +5521,7 @@ template DocReformDocAbstraction() { comp_obj_heading_.metainfo.object_number_off = ""; comp_obj_heading_.metainfo.object_number_type = 0; comp_obj_heading_.tags.segment_anchor_tag = "bookindex"; + comp_obj_heading_.tags.segment_anchor_tag_is = comp_obj_heading_.tags.segment_anchor_tag; comp_obj_heading_.metainfo.heading_lev_markup = 4; comp_obj_heading_.metainfo.heading_lev_collapsed = 2; comp_obj_heading_.metainfo.parent_ocn = 1; @@ -5685,6 +5727,7 @@ template DocReformDocAbstraction() { comp_obj_heading_.metainfo.object_number_off = ""; comp_obj_heading_.metainfo.object_number_type = 0; comp_obj_heading_.tags.segment_anchor_tag = "_part_endnotes"; + comp_obj_heading_.tags.segment_anchor_tag_is = comp_obj_heading_.tags.segment_anchor_tag; comp_obj_heading_.metainfo.heading_lev_markup = 1; comp_obj_heading_.metainfo.heading_lev_collapsed = 1; comp_obj_heading_.metainfo.parent_ocn = 1; @@ -5701,6 +5744,7 @@ template DocReformDocAbstraction() { comp_obj_heading_.metainfo.object_number_off = ""; comp_obj_heading_.metainfo.object_number_type = 0; comp_obj_heading_.tags.segment_anchor_tag = "endnotes"; + comp_obj_heading_.tags.segment_anchor_tag_is = comp_obj_heading_.tags.segment_anchor_tag; comp_obj_heading_.metainfo.heading_lev_markup = 4; comp_obj_heading_.metainfo.heading_lev_collapsed = 2; comp_obj_heading_.metainfo.parent_ocn = 1; @@ -5857,9 +5901,11 @@ template DocReformDocAbstraction() { int obj_cite_digit; int[string] p_; // p_ parent_ static auto rgx = Rgx(); - ObjGenericComposite node_location_emitter(Lv,Ta,N,C,P,I)( + ObjGenericComposite node_location_emitter(Lv,Tg,La,Ta,N,C,P,I)( Lv lev_markup_number, - Ta segment_anchor_tag, + Tg segment_anchor_tag, + La lev_anchor_tag, + Ta tag_assoc, N obj_cite_digits, C cntr_, P ptr_, @@ -5898,6 +5944,8 @@ template DocReformDocAbstraction() { comp_obj_location.metainfo.is_a = is_; comp_obj_location.metainfo.ocn = obj_cite_digits.on; comp_obj_location.tags.segment_anchor_tag = segment_anchor_tag.to!string; + comp_obj_location.tags.segment_anchor_tag_is = comp_obj_location.tags.segment_anchor_tag; + comp_obj_location.tags.heading_lev_anchor_tag = lev_anchor_tag; comp_obj_location.metainfo.parent_ocn = p_["object_number"]; comp_obj_location.metainfo.parent_lev_markup = p_["lev_markup_number"]; debug(_node) { @@ -5914,11 +5962,13 @@ template DocReformDocAbstraction() { } invariant() { } - ObjGenericComposite node_emitter_heading(T,Lm,Lc,Ta,N,C,P,LA,I,PSn,fNr,fNs,fL)( + ObjGenericComposite node_emitter_heading(T,Lm,Lc,TaB,TaL,TA,N,C,P,LA,I,PSn,fNr,fNs,fL)( T _text, Lm lev_markup_number, Lc lev_collapsed_number, - Ta segment_anchor_tag, + TaB segment_anchor_tag_that_object_belongs_to, + TaL lev_anchor_tag, + TA tag_assoc, N obj_cite_digits, C cntr_, P ptr_, @@ -5931,17 +5981,17 @@ template DocReformDocAbstraction() { ) in { debug(asserts) { - static assert(is(typeof(_text) == string)); - static assert(is(typeof(lev) == string)); - static assert(is(typeof(lev_markup_number) == string)); - static assert(is(typeof(lev_collapsed_number) == string)); - static assert(is(typeof(segment_anchor_tag) == string)); - static assert(is(typeof(obj_cite_digits.on) == int)); - static assert(is(typeof(cntr_) == int)); - static assert(is(typeof(ptr_) == int)); - static assert(is(typeof(lv_ancestors_txt) == string[])); - static assert(is(typeof(is_) == string)); - static assert(is(typeof(html_segnames_ptr) == int)); + static assert(is(typeof(_text) == string)); + static assert(is(typeof(lev) == string)); + static assert(is(typeof(lev_markup_number) == string)); + static assert(is(typeof(lev_collapsed_number) == string)); + static assert(is(typeof(segment_anchor_tag_that_object_belongs_to) == string)); + static assert(is(typeof(obj_cite_digits.on) == int)); + static assert(is(typeof(cntr_) == int)); + static assert(is(typeof(ptr_) == int)); + static assert(is(typeof(lv_ancestors_txt) == string[])); + static assert(is(typeof(is_) == string)); + static assert(is(typeof(html_segnames_ptr) == int)); } assert(is_ == "heading"); assert((obj_cite_digits.on).to!int >= 0); @@ -6053,7 +6103,9 @@ template DocReformDocAbstraction() { _comp_obj_heading_.metainfo.ocn = obj_cite_digits.on; _comp_obj_heading_.metainfo.object_number_off = (obj_cite_digits.off==0) ? "" : obj_cite_digits.off.to!string; _comp_obj_heading_.metainfo.object_number_type = obj_cite_digits.type; - _comp_obj_heading_.tags.segment_anchor_tag = segment_anchor_tag.to!string; + _comp_obj_heading_.tags.segment_anchor_tag = segment_anchor_tag_that_object_belongs_to; + _comp_obj_heading_.tags.heading_lev_anchor_tag = lev_anchor_tag; + _comp_obj_heading_.tags.segment_anchor_tag_is = segment_anchor_tag_that_object_belongs_to; _comp_obj_heading_.metainfo.heading_lev_markup = (!(lev_markup_number.empty) ? lev_markup_number.to!int : 0); _comp_obj_heading_.metainfo.heading_lev_collapsed = (!(lev_collapsed_number.empty) ? lev_collapsed_number.to!int : 0); _comp_obj_heading_.metainfo.parent_ocn = p_["object_number"]; diff --git a/src/doc_reform/meta/object_setter.d b/src/doc_reform/meta/object_setter.d index f481ec1..ee2dc78 100644 --- a/src/doc_reform/meta/object_setter.d +++ b/src/doc_reform/meta/object_setter.d @@ -105,6 +105,8 @@ template ObjectSetter() { struct DocObj_Tags_ { string[] heading_ancestors_text = [ "", "", "", "", "", "", "", "", ]; // TODO redundant? see markedup and collapsed ancestors DONE string segment_anchor_tag = ""; + string segment_anchor_tag_is = ""; + string heading_lev_anchor_tag = ""; string segname_prev = ""; string segname_next = ""; string[] lev4_subtoc = []; diff --git a/src/doc_reform/output/epub3.d b/src/doc_reform/output/epub3.d index 19c7934..18d9e03 100644 --- a/src/doc_reform/output/epub3.d +++ b/src/doc_reform/output/epub3.d @@ -160,7 +160,7 @@ template outputEPub3() { if (obj.metainfo.heading_lev_markup < 4) { toc ~= markup.indent_by_spaces_provided((n + 1), " ") ~ "
  • " ~ "\n" ~ markup.indent_by_spaces_provided((n + 2), " ") - ~ "" + ~ "" ~ _txt ~ "" ~ "\n"; } else { @@ -169,7 +169,7 @@ template outputEPub3() { : ("#" ~ obj.metainfo.ocn.to!string); toc ~= markup.indent_by_spaces_provided((n + 1), " ") ~ "
  • " ~ "\n" ~ markup.indent_by_spaces_provided((n + 2), " ") - ~ "" + ~ "" ~ _txt ~ "" ~ "\n"; } @@ -179,7 +179,7 @@ template outputEPub3() { if (obj.metainfo.heading_lev_markup < 4) { toc ~= markup.indent_by_spaces_provided((n + 1), " ") ~ "
  • " ~ "\n" ~ markup.indent_by_spaces_provided((n + 2), " ") - ~ "" + ~ "" ~ _txt ~ "" ~ "\n"; } else { @@ -188,7 +188,7 @@ template outputEPub3() { : ("#" ~ obj.metainfo.ocn.to!string); toc ~= markup.indent_by_spaces_provided((n + 1), " ") ~ "
  • " ~ "\n" ~ markup.indent_by_spaces_provided((n + 2), " ") - ~ "" + ~ "" ~ _txt ~ "" ~ "\n"; } @@ -262,7 +262,7 @@ template outputEPub3() { ¶", counter, _txt, - obj.tags.segment_anchor_tag, + obj.tags.segment_anchor_tag_is, hashtag, ); break; @@ -276,7 +276,7 @@ template outputEPub3() { ¶", counter, _txt, - obj.tags.segment_anchor_tag, + obj.tags.segment_anchor_tag_is, hashtag, ); break; @@ -512,41 +512,41 @@ template outputEPub3() { oepbs_content_parts["manifest_documents"] ~= format(q"¶ ¶", - obj.tags.segment_anchor_tag, - obj.tags.segment_anchor_tag, + obj.tags.segment_anchor_tag_is, + obj.tags.segment_anchor_tag_is, ); oepbs_content_parts["spine"] ~= format(q"¶ ¶", - obj.tags.segment_anchor_tag, + obj.tags.segment_anchor_tag_is, ); oepbs_content_parts["guide"] ~= format(q"¶ ¶", - obj.tags.segment_anchor_tag, - obj.tags.segment_anchor_tag, + obj.tags.segment_anchor_tag_is, + obj.tags.segment_anchor_tag_is, ); } else if (obj.metainfo.heading_lev_markup > 4) { oepbs_content_parts["manifest_documents"] ~= format(q"¶ ¶", - obj.tags.segment_anchor_tag, + obj.tags.segment_anchor_tag_is, obj.metainfo.object_number, - obj.tags.segment_anchor_tag, + obj.tags.segment_anchor_tag_is, obj.metainfo.object_number, ); oepbs_content_parts["spine"] ~= format(q"¶ ¶", - obj.tags.segment_anchor_tag, + obj.tags.segment_anchor_tag_is, obj.metainfo.object_number, ); oepbs_content_parts["guide"] ~= format(q"¶ ¶", - obj.tags.segment_anchor_tag, + obj.tags.segment_anchor_tag_is, obj.metainfo.object_number, - obj.tags.segment_anchor_tag, + obj.tags.segment_anchor_tag_is, obj.metainfo.object_number, ); } diff --git a/src/doc_reform/output/xmls.d b/src/doc_reform/output/xmls.d index 7a1a812..47053f3 100644 --- a/src/doc_reform/output/xmls.d +++ b/src/doc_reform/output/xmls.d @@ -89,7 +89,8 @@ template outputXHTMLs() { .replaceAll(rgx.inline_cite, ("$1")); return _txt; } - string _xhtml_anchor_tags(const(string[]) anchor_tags) { + string _xhtml_anchor_tags(O)(O obj) { + const(string[]) anchor_tags = obj.tags.anchor_tags; string tags=""; if (anchor_tags.length > 0) { foreach (tag; anchor_tags) { @@ -351,13 +352,28 @@ template outputXHTMLs() { } if (_xml_type == "seg" || _xml_type == "epub") { if (auto m = _txt.match(rgx.inline_link_hash)) { - foreach (segname; doc_matters.xml.segnames) { - if (auto n = segname.match(m.captures[3])) { + if (m.captures[3] in doc_matters.xml.tag_associations) { + if (m.captures[3] == doc_matters.xml.tag_associations[(m.captures[3])][0]) { _txt = _txt.replaceFirst( rgx.inline_link_hash, - "┥$1┝┤$3" ~ _suffix ~ "├"); - break; + "┥$1┝┤$3" ~ _suffix ~ "├" + ); + } else { + _txt = _txt.replaceFirst( + rgx.inline_link_hash, + "┥$1┝┤" + ~ doc_matters.xml.tag_associations[(m.captures[3])][0] + ~ _suffix + ~ "#" ~ "$3" + ~ "├" + ); } + } else { + writeln( + "WARNING on internal document links, anchor to link not found in document, " + ~ "anchor: " ~ m.captures[3] + ~ " document: " ~ doc_matters.src.filename + ); } } } @@ -592,7 +608,9 @@ template outputXHTMLs() { string _txt, string _xml_type = "html", ) { - auto tags = _xhtml_anchor_tags(obj.tags.anchor_tags); + auto tags = _xhtml_anchor_tags(obj); + string seg_anchor_tag; + string heading_lev_anchor_tag; string _horizontal_rule = "
    "; if ((_xml_type != "html") || (obj.metainfo.heading_lev_markup == 0 || obj.metainfo.heading_lev_markup > 4)) { @@ -600,10 +618,16 @@ template outputXHTMLs() { } _txt = font_face(_txt); string o; + seg_anchor_tag = (obj.tags.segment_anchor_tag.empty) + ? "" + : ""; + heading_lev_anchor_tag = (obj.tags.heading_lev_anchor_tag.empty) + ? "" + : ""; if (obj.metainfo.object_number.empty) { o = format(q"¶%s
    - %s + %s%s %s
    ¶", @@ -611,7 +635,7 @@ template outputXHTMLs() { obj.metainfo.heading_lev_markup, obj.metainfo.is_a, tags, - obj.tags.segment_anchor_tag, + heading_lev_anchor_tag, _txt, obj.metainfo.heading_lev_markup, ); @@ -619,7 +643,7 @@ template outputXHTMLs() { o = format(q"¶%s
    - %s + %s%s %s
    ¶", @@ -631,7 +655,7 @@ template outputXHTMLs() { obj.metainfo.object_number, obj.metainfo.object_number, tags, - obj.tags.segment_anchor_tag, + heading_lev_anchor_tag, _txt, obj.metainfo.heading_lev_markup, ); @@ -644,7 +668,7 @@ template outputXHTMLs() { string _txt, string _suffix = ".html", ) { - auto tags = _xhtml_anchor_tags(obj.tags.anchor_tags); + auto tags = _xhtml_anchor_tags(obj); _txt = inline_markup_scroll(doc_matters, obj, _txt, _suffix); string o = heading(doc_matters, obj, _txt); return o; @@ -671,7 +695,7 @@ template outputXHTMLs() { const O obj, string _txt, ) { - auto tags = _xhtml_anchor_tags(obj.tags.anchor_tags); + auto tags = _xhtml_anchor_tags(obj); _txt = font_face(_txt); string o; _txt = (obj.attrib.bullet) ? ("●  " ~ _txt) : _txt; @@ -712,7 +736,7 @@ template outputXHTMLs() { string _txt, string _suffix = ".html", ) { - auto tags = _xhtml_anchor_tags(obj.tags.anchor_tags); + auto tags = _xhtml_anchor_tags(obj); _txt = inline_markup_scroll(doc_matters, obj, _txt, _suffix); string o = para(doc_matters, obj, _txt); return o; @@ -772,7 +796,7 @@ template outputXHTMLs() { string _txt, string _suffix = ".html", ) { - auto tags = _xhtml_anchor_tags(obj.tags.anchor_tags); + auto tags = _xhtml_anchor_tags(obj); _txt = inline_markup_scroll(doc_matters, obj, _txt, _suffix); string o = quote(doc_matters, obj, _txt); return o; @@ -833,7 +857,7 @@ template outputXHTMLs() { string _suffix = ".html", string _xml_type = "html", ) { - auto tags = _xhtml_anchor_tags(obj.tags.anchor_tags); + auto tags = _xhtml_anchor_tags(obj); _txt = inline_markup_scroll(doc_matters, obj, _txt, _suffix); string o = group(doc_matters, obj, _txt); return o; @@ -890,7 +914,7 @@ template outputXHTMLs() { string _suffix = ".html", string _xml_type = "html", ) { - auto tags = _xhtml_anchor_tags(obj.tags.anchor_tags); + auto tags = _xhtml_anchor_tags(obj); _txt = inline_markup_scroll(doc_matters, obj, _txt, _suffix); string o = block(doc_matters, obj, _txt); return o; @@ -947,7 +971,7 @@ template outputXHTMLs() { string _suffix = ".html", string _xml_type = "html", ) { - auto tags = _xhtml_anchor_tags(obj.tags.anchor_tags); + auto tags = _xhtml_anchor_tags(obj); _txt = inline_markup_scroll(doc_matters, obj, _txt, _suffix); string o = verse(doc_matters, obj, _txt); return o; @@ -1008,7 +1032,7 @@ template outputXHTMLs() { const O obj, string _txt, ) { - auto tags = _xhtml_anchor_tags(obj.tags.anchor_tags); + auto tags = _xhtml_anchor_tags(obj); _txt = font_face(_txt); auto t = tablarize(doc_matters, obj, _txt); _txt = t[0]; -- cgit v1.2.3