diff options
author | Ralph Amissah <ralph.amissah@gmail.com> | 2018-10-07 12:12:33 -0400 |
---|---|---|
committer | Ralph Amissah <ralph.amissah@gmail.com> | 2019-04-10 15:14:15 -0400 |
commit | 60f70c541879cccfd379c7f75ed6aff62e793caf (patch) | |
tree | 0914c4410eabe2794d901bc95c2c14363724eebb /org | |
parent | output xmls, work on internal links (diff) |
xmls segmented heading inline links
Diffstat (limited to 'org')
-rw-r--r-- | org/doc_reform.org | 8 | ||||
-rw-r--r-- | org/meta_abstraction.org | 206 | ||||
-rw-r--r-- | org/output_xmls.org | 94 |
3 files changed, 195 insertions, 113 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() { <<doc_reform_mixin>> 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 = "<hr />"; 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) + ? "" + : "<a name=\"" ~ obj.tags.segment_anchor_tag ~ "\"></a>"; + heading_lev_anchor_tag = (obj.tags.heading_lev_anchor_tag.empty) + ? "" + : "<a name=\"" ~ obj.tags.heading_lev_anchor_tag ~ "\"></a>"; if (obj.metainfo.object_number.empty) { o = format(q"¶%s <div class="substance"> - <h%s class="%s">%s<a name="%s"></a> + <h%s class="%s">%s%s %s </h%s> </div>¶", @@ -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 <div class="substance"> <label class="ocn"><a href="#%s" class="lnkocn">%s</a></label> - <h%s class="%s" id="%s"><a name="%s"></a>%s<a name="%s"></a> + <h%s class="%s" id="%s"><a name="%s"></a>%s%s %s </h%s> </div>¶", @@ -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), " ") ~ "<li>" ~ "\n" ~ markup.indent_by_spaces_provided((n + 2), " ") - ~ "<a href=\"" ~ obj.tags.segment_anchor_tag ~ ".xhtml" ~ "\">" + ~ "<a href=\"" ~ obj.tags.segment_anchor_tag_is ~ ".xhtml" ~ "\">" ~ _txt ~ "</a>" ~ "\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), " ") ~ "<li>" ~ "\n" ~ markup.indent_by_spaces_provided((n + 2), " ") - ~ "<a href=\"" ~ obj.tags.segment_anchor_tag ~ ".xhtml" ~ hashtag ~ "\">" + ~ "<a href=\"" ~ obj.tags.segment_anchor_tag_is ~ ".xhtml" ~ hashtag ~ "\">" ~ _txt ~ "</a>" ~ "\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), " ") ~ "<li>" ~ "\n" ~ markup.indent_by_spaces_provided((n + 2), " ") - ~ "<a href=\"" ~ obj.tags.segment_anchor_tag ~ ".xhtml" ~ "\">" + ~ "<a href=\"" ~ obj.tags.segment_anchor_tag_is ~ ".xhtml" ~ "\">" ~ _txt ~ "</a>" ~ "\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), " ") ~ "<li>" ~ "\n" ~ markup.indent_by_spaces_provided((n + 2), " ") - ~ "<a href=\"" ~ obj.tags.segment_anchor_tag ~ ".xhtml" ~ hashtag ~ "\">" + ~ "<a href=\"" ~ obj.tags.segment_anchor_tag_is ~ ".xhtml" ~ hashtag ~ "\">" ~ _txt ~ "</a>" ~ "\n"; } @@ -2225,7 +2249,7 @@ string epub2_oebps_toc_ncx(D,I)(D doc_abstraction, I doc_matters) { <content src="%s.xhtml%s" />¶", 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) { <content src="%s.xhtml%s" />¶", 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"¶ <item id="%s.xhtml" href="%s.xhtml" media-type="application/xhtml+xml" /> ¶", - 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"¶ <itemref idref="%s.xhtml" linear="yes" /> ¶", - obj.tags.segment_anchor_tag, + obj.tags.segment_anchor_tag_is, ); oepbs_content_parts["guide"] ~= format(q"¶ <reference type="%s" href="%s" /> ¶", - 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"¶ <item id="%s.xhtml#%s" href="%s.xhtml#%s" media-type="application/xhtml+xml" /> ¶", - 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"¶ <itemref idref="%s.xhtml#%s" linear="yes" /> ¶", - obj.tags.segment_anchor_tag, + obj.tags.segment_anchor_tag_is, obj.metainfo.object_number, ); oepbs_content_parts["guide"] ~= format(q"¶ <reference type="%s#%s" href="%s#%s" /> ¶", - 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, ); } |