From a881c428c12f4948e4ea65b9315a3fabef8c7b4f Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Fri, 18 Nov 2016 10:17:40 -0500 Subject: munge links & urls for sections: toc, endnotes, book index --- org/ao_abstract_doc_source.org | 58 ++++++++++++++++++++++++++++++------------ 1 file changed, 42 insertions(+), 16 deletions(-) (limited to 'org/ao_abstract_doc_source.org') diff --git a/org/ao_abstract_doc_source.org b/org/ao_abstract_doc_source.org index 7c10dca..4934a5a 100644 --- a/org/ao_abstract_doc_source.org +++ b/org/ao_abstract_doc_source.org @@ -203,6 +203,8 @@ the_table_of_contents_section = [ "seg": [toc_head], "scroll": [toc_head], ]; +auto mkup = InlineMarkup(); +auto munge = ObjInlineMarkupMunge(); #+END_SRC ** _2. loop: process document body_ [+6] :loop: @@ -1079,6 +1081,7 @@ if (the_endnotes_section["seg"].length > 1) { "Endnotes", "endnotes", // segment_object_belongs_to ); + toc_txt_= munge.url_links(toc_txt_); the_table_of_contents_section["seg"] ~= set_abstract_object.contents_para( "toc", @@ -1095,6 +1098,7 @@ if (the_endnotes_section["scroll"].length > 1) { "Endnotes", "endnotes", // _anchor_tag ); + toc_txt_= munge.url_links(toc_txt_); the_table_of_contents_section["scroll"] ~= set_abstract_object.contents_para( "toc", @@ -1111,6 +1115,7 @@ if (the_glossary_section.length > 1) { "Glossary", "glossary", // segment_object_belongs_to ); + toc_txt_= munge.url_links(toc_txt_); the_table_of_contents_section["seg"] ~= set_abstract_object.contents_para( "toc", @@ -1125,6 +1130,7 @@ if (the_glossary_section.length > 1) { "Glossary", "glossary", // _anchor_tag ); + toc_txt_= munge.url_links(toc_txt_); the_table_of_contents_section["scroll"] ~= set_abstract_object.contents_para( "toc", @@ -1141,6 +1147,7 @@ if (the_bibliography_section.length > 1){ "Bibliography", "bibliography", // segment_object_belongs_to ); + toc_txt_= munge.url_links(toc_txt_); the_table_of_contents_section["seg"] ~= set_abstract_object.contents_para( "toc", @@ -1155,6 +1162,7 @@ if (the_bibliography_section.length > 1){ "Bibliography", "bibliography", // _anchor_tag ); + toc_txt_= munge.url_links(toc_txt_); the_table_of_contents_section["scroll"] ~= set_abstract_object.contents_para( "toc", @@ -1171,6 +1179,7 @@ if (the_bookindex_section["seg"].length > 1) { "Book Index", "bookindex", // segment_object_belongs_to ); + toc_txt_= munge.url_links(toc_txt_); the_table_of_contents_section["seg"] ~= set_abstract_object.contents_para( "toc", @@ -1187,6 +1196,7 @@ if (the_bookindex_section["scroll"].length > 1) { "Book Index", "bookindex", // _anchor_tag ); + toc_txt_= munge.url_links(toc_txt_); the_table_of_contents_section["scroll"] ~= set_abstract_object.contents_para( "toc", @@ -1203,6 +1213,7 @@ if (the_blurb_section.length > 1) { "Blurb", "blurb", // segment_object_belongs_to ); + toc_txt_= munge.url_links(toc_txt_); the_table_of_contents_section["seg"] ~= set_abstract_object.contents_para( "toc", @@ -1217,6 +1228,7 @@ if (the_blurb_section.length > 1) { "Blurb", "blurb", // _anchor_tag ); + toc_txt_= munge.url_links(toc_txt_); the_table_of_contents_section["scroll"] ~= set_abstract_object.contents_para( "toc", @@ -3128,7 +3140,12 @@ struct ObjInlineMarkup { char[] heading_toc_, ) { auto m = matchFirst(cast(char[]) heading_toc_, rgx.heading); - heading_toc_ = m.post; + heading_toc_ = + replaceAll( + m.post, + rgx.inline_notes_curly_gen, + ("") + ); return heading_toc_; }; auto table_of_contents_gather_headings( @@ -3152,6 +3169,7 @@ struct ObjInlineMarkup { heading_toc_, _anchor_tag, ); + toc_txt_= munge.url_links(toc_txt_); indent=[ "hang_position" : to!int(obj_["lev_markup_number"]), "base_position" : to!int(obj_["lev_markup_number"]), @@ -3161,6 +3179,7 @@ struct ObjInlineMarkup { heading_toc_, _anchor_tag, ); + toc_txt_= munge.url_links(toc_txt_); the_table_of_contents_section["scroll"] ~= set_abstract_object.contents_para( "toc", @@ -3191,10 +3210,12 @@ struct ObjInlineMarkup { "hang_position" : 0, "base_position" : 0, ]; + toc_txt_ = "{ Table of Contents }../toc.fn_suffix"; + toc_txt_= munge.url_links(toc_txt_); the_table_of_contents_section["seg"] ~= set_abstract_object.contents_para( "toc", - "{ Table of Contents }../toc.fn_suffix", + toc_txt_, "", // attrib 0, indent, @@ -3210,6 +3231,7 @@ struct ObjInlineMarkup { "%s", heading_toc_, ); + toc_txt_= munge.url_links(toc_txt_); the_table_of_contents_section["seg"] ~= set_abstract_object.contents_para( "toc", @@ -3226,6 +3248,7 @@ struct ObjInlineMarkup { heading_toc_, segment_object_belongs_to, ); + toc_txt_= munge.url_links(toc_txt_); indent=[ "hang_position" : to!int(obj_["lev_markup_number"]), "base_position" : to!int(obj_["lev_markup_number"]), @@ -3247,6 +3270,7 @@ struct ObjInlineMarkup { segment_object_belongs_to, _anchor_tag, ); + toc_txt_= munge.url_links(toc_txt_); indent=[ "hang_position" : to!int(obj_["lev_markup_number"]), "base_position" : to!int(obj_["lev_markup_number"]), @@ -3895,6 +3919,7 @@ struct BookIndexReportIndent { struct BookIndexReportSection { int mkn, skn; auto rgx = Rgx(); + auto munge = ObjInlineMarkupMunge(); #+END_SRC ***** bookindex write section @@ -4007,10 +4032,10 @@ struct BookIndexReportSection { bi_tmp_seg = "!{" ~ mainkey ~ "}! "; foreach (ref_; bookindex_unordered_hashes[mainkey]["_a"]) { auto go = replaceAll(ref_, rgx.book_index_go, "$1"); - bi_tmp_scroll ~= (" {" ~ ref_ ~ "}#" ~ go ~ ", "); + bi_tmp_scroll ~= munge.url_links(" {" ~ ref_ ~ "}#" ~ go ~ ", "); bi_tmp_seg ~= (segment_object_belongs_to.empty) - ? (" {" ~ ref_ ~ "}#" ~ go ~ ", ") - : (" {" ~ ref_ ~ "}../" ~ segment_object_belongs_to ~ ".fn_suffix#" ~ go ~ ", "); + ? munge.url_links(" {" ~ ref_ ~ "}#" ~ go ~ ", ") + : munge.url_links(" {" ~ ref_ ~ "}../" ~ segment_object_belongs_to ~ ".fn_suffix#" ~ go ~ ", "); } bi_tmp_scroll ~= " \\\\\n "; bi_tmp_seg ~= " \\\\\n "; @@ -4022,10 +4047,10 @@ struct BookIndexReportSection { bi_tmp_seg ~= subkey ~ ", "; foreach (ref_; bookindex_unordered_hashes[mainkey][subkey]) { auto go = replaceAll(ref_, rgx.book_index_go, "$1"); - bi_tmp_scroll ~= (" {" ~ ref_ ~ "}#" ~ go ~ ", "); + bi_tmp_scroll ~= munge.url_links(" {" ~ ref_ ~ "}#" ~ go ~ ", "); bi_tmp_seg ~= (segment_object_belongs_to.empty) - ? (" {" ~ ref_ ~ "}#" ~ go ~ ", ") - : (" {" ~ ref_ ~ "}../" ~ segment_object_belongs_to ~ ".fn_suffix#" ~ go ~ ", "); + ? munge.url_links(" {" ~ ref_ ~ "}#" ~ go ~ ", ") + : munge.url_links(" {" ~ ref_ ~ "}../" ~ segment_object_belongs_to ~ ".fn_suffix#" ~ go ~ ", "); } bi_tmp_scroll ~= " \\\\\n "; bi_tmp_seg ~= " \\\\\n "; @@ -4128,6 +4153,7 @@ struct NotesSection { ); } body { + auto munge = ObjInlineMarkupMunge(); foreach(m; matchAll(contents_am[counter].object, rgx.inline_notes_delimiter_al_regular_number_note)) { @@ -4138,16 +4164,16 @@ struct NotesSection { } // TODO NEXT you need anchor for segments at this point -> object_notes["seg"] ~= - "{^{" ~ m.captures[1] ~ ".}^}#noteref_" ~ - m.captures[1] ~ " " ~ m.captures[2] ~ "』"; + munge.url_links("{^{" ~ m.captures[1] ~ ".}^}#noteref_" ~ + m.captures[1]) ~ " " ~ m.captures[2] ~ "』"; object_notes["seg"] ~= (segment_object_belongs_to.empty) - ? ("{^{" ~ m.captures[1] ~ ".}^}#noteref_" ~ - m.captures[1] ~ " " ~ m.captures[2] ~ "』") - : ("{^{" ~ m.captures[1] ~ ".}^}../" ~ segment_object_belongs_to ~ ".fn_suffix#noteref_" ~ - m.captures[1] ~ " " ~ m.captures[2] ~ "』"); + ? (munge.url_links("{^{" ~ m.captures[1] ~ ".}^}#noteref_" ~ + m.captures[1]) ~ " " ~ m.captures[2] ~ "』") + : (munge.url_links("{^{" ~ m.captures[1] ~ ".}^}../" ~ segment_object_belongs_to ~ ".fn_suffix#noteref_" ~ + m.captures[1]) ~ " " ~ m.captures[2] ~ "』"); object_notes["scroll"] ~= - "{^{" ~ m.captures[1] ~ ".}^}#noteref_" ~ - m.captures[1] ~ " " ~ m.captures[2] ~ "』"; + munge.url_links("{^{" ~ m.captures[1] ~ ".}^}#noteref_" ~ + m.captures[1]) ~ " " ~ m.captures[2] ~ "』"; } return object_notes; } -- cgit v1.2.3