From 099d54647f0ff4bf7effb7c554e987eeff11fb85 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Sat, 14 Jan 2017 10:08:53 -0500 Subject: identify internal links for downstream munging --- org/ao_abstract_doc_source.org | 43 ++++++++++++++++++++++++++-------------- org/ao_defaults.org | 11 +++++----- org/ao_output_debugs.org | 2 -- src/sdp/ao_abstract_doc_source.d | 41 +++++++++++++++++++++++++------------- src/sdp/ao_defaults.d | 1 + src/sdp/ao_rgx.d | 10 +++++----- 6 files changed, 67 insertions(+), 41 deletions(-) diff --git a/org/ao_abstract_doc_source.org b/org/ao_abstract_doc_source.org index 4aa20be..e413570 100644 --- a/org/ao_abstract_doc_source.org +++ b/org/ao_abstract_doc_source.org @@ -197,7 +197,7 @@ enum DocStructMarkupHeading { h_text_5, // extra level, drop content_non_header } // header section A-D; header text 1-4 -enum DocStructCollapsedHeading { lv0, lv1, lv2, lv3, lv4, lv5, lv6, lv7 } // not yet used +enum DocStructCollapsedHeading { lv0, lv1, lv2, lv3, lv4, lv5, lv6, lv7 } /+ biblio variables +/ string biblio_tag_name, biblio_tag_entry, st; string[] biblio_arr_json; @@ -232,7 +232,7 @@ void heading_ancestors(O)( switch (obj.heading_lev_markup) { case 0: lv_ancestors[0] = to!string(obj.text); - foreach(k; 1..8) { // 1 .. 7 ? + foreach(k; 1..8) { lv_ancestors[k] = ""; } goto default; @@ -1430,8 +1430,9 @@ comp_obj_toc.indent_base = indent["base_position"]; comp_obj_toc.bullet = false; if (the_endnotes_section.length > 1) { toc_txt_ = format( - "{ %s }../%s.fnSuffix", + "{ %s }%s../%s.fnSuffix", "Endnotes", + mkup.mark_internal_site_lnk, "endnotes", // segment_anchor_tag_that_object_belongs_to ); toc_txt_= munge.url_links(toc_txt_); @@ -1440,8 +1441,9 @@ if (the_endnotes_section.length > 1) { } if (the_glossary_section.length > 1) { toc_txt_ = format( - "{ %s }../%s.fnSuffixs", + "{ %s }%s../%s.fnSuffixs", "Glossary", + mkup.mark_internal_site_lnk, "glossary", // segment_anchor_tag_that_object_belongs_to ); toc_txt_= munge.url_links(toc_txt_); @@ -1458,8 +1460,9 @@ if (the_glossary_section.length > 1) { } if (the_bibliography_section.length > 1){ toc_txt_ = format( - "{ %s }../%s.fnSuffix", + "{ %s }%s../%s.fnSuffix", "Bibliography", + mkup.mark_internal_site_lnk, "bibliography", // segment_anchor_tag_that_object_belongs_to ); toc_txt_= munge.url_links(toc_txt_); @@ -1477,8 +1480,9 @@ if (the_bibliography_section.length > 1){ } if (the_bookindex_section["seg"].length > 1) { toc_txt_ = format( - "{ %s }../%s.fnSuffix", + "{ %s }%s../%s.fnSuffix", "Book Index", + mkup.mark_internal_site_lnk, "bookindex", // segment_anchor_tag_that_object_belongs_to ); toc_txt_= munge.url_links(toc_txt_); @@ -1497,8 +1501,9 @@ if (the_bookindex_section["scroll"].length > 1) { } if (the_blurb_section.length > 1) { toc_txt_ = format( - "{ %s }../%s.fnSuffix", + "{ %s }%s../%s.fnSuffix", "Blurb", + mkup.mark_internal_site_lnk, "blurb", // segment_anchor_tag_that_object_belongs_to ); toc_txt_= munge.url_links(toc_txt_); @@ -1618,7 +1623,7 @@ if (the_blurb_section.length > 1) { } #+END_SRC -**** loop: all objects structural relationships (sections, segments, objects) +**** [#A] loop: all objects structural relationships (sections, segments, objects) needed for DOM structure, segnames & subtoc, backmatter pointers @@ -3827,6 +3832,8 @@ struct ObjInlineMarkup { in { } body { ObjGenericComposite comp_obj_toc; + mixin InternalMarkup; + auto mkup = InlineMarkup(); char[] heading_toc_ = to!(char[])(obj_["body_nugget"].dup.strip); heading_toc_ = _clean_heading_toc_(heading_toc_); auto attrib=""; @@ -3884,7 +3891,7 @@ struct ObjInlineMarkup { "hang_position" : 0, "base_position" : 0, ]; - toc_txt_ = "{ Table of Contents }../toc.fnSuffix"; + toc_txt_ = "{ Table of Contents }" ~ mkup.mark_internal_site_lnk ~ "../toc.fnSuffix"; toc_txt_= munge.url_links(toc_txt_); comp_obj_toc.indent_hang = indent["hang_position"]; comp_obj_toc.indent_base = indent["base_position"]; @@ -3908,8 +3915,9 @@ struct ObjInlineMarkup { break; case 4: toc_txt_ = format( - "{ %s }../%s.fnSuffix", + "{ %s }%s../%s.fnSuffix", heading_toc_, + mkup.mark_internal_site_lnk, segment_anchor_tag_that_object_belongs_to, ); lev4_subtoc[segment_anchor_tag_that_object_belongs_to] = []; @@ -3925,8 +3933,9 @@ struct ObjInlineMarkup { break; case 5: .. case 7: toc_txt_ = format( - "{ %s }../%s.fnSuffix#%s", + "{ %s }%s../%s.fnSuffix#%s", heading_toc_, + mkup.mark_internal_site_lnk, segment_anchor_tag_that_object_belongs_to, _anchor_tag, ); @@ -4638,6 +4647,8 @@ struct BookIndexReportSection { bool[string] opt_action_bool, ) { mixin SiSUnode; + mixin InternalMarkup; + auto mkup = InlineMarkup(); string type_is; string lev; int heading_lev_markup, heading_lev_collapsed; @@ -4701,7 +4712,7 @@ struct BookIndexReportSection { bi_tmp_scroll ~= munge.url_links(" {" ~ ref_ ~ "}#" ~ go ~ ", "); bi_tmp_seg ~= (segment_anchor_tag_that_object_belongs_to.empty) ? munge.url_links(" {" ~ ref_ ~ "}#" ~ go ~ ", ") - : munge.url_links(" {" ~ ref_ ~ "}../" ~ segment_anchor_tag_that_object_belongs_to ~ ".fnSuffix#" ~ go ~ ", "); + : munge.url_links(" {" ~ ref_ ~ "}" ~ mkup.mark_internal_site_lnk ~ "../" ~ segment_anchor_tag_that_object_belongs_to ~ ".fnSuffix#" ~ go ~ ", "); } bi_tmp_scroll ~= " \\\\\n "; bi_tmp_seg ~= " \\\\\n "; @@ -4718,7 +4729,7 @@ struct BookIndexReportSection { bi_tmp_scroll ~= munge.url_links(" {" ~ ref_ ~ "}#" ~ go ~ ", "); bi_tmp_seg ~= (segment_anchor_tag_that_object_belongs_to.empty) ? munge.url_links(" {" ~ ref_ ~ "}#" ~ go ~ ", ") - : munge.url_links(" {" ~ ref_ ~ "}../" ~ segment_anchor_tag_that_object_belongs_to ~ ".fnSuffix#" ~ go ~ ", "); + : munge.url_links(" {" ~ ref_ ~ "}" ~ mkup.mark_internal_site_lnk ~ "../" ~ segment_anchor_tag_that_object_belongs_to ~ ".fnSuffix#" ~ go ~ ", "); } bi_tmp_scroll ~= " \\\\\n "; bi_tmp_seg ~= " \\\\\n "; @@ -4803,6 +4814,8 @@ struct NotesSection { ); } body { + mixin InternalMarkup; + auto mkup = InlineMarkup(); auto munge = ObjInlineMarkupMunge(); foreach( m; @@ -4813,7 +4826,7 @@ struct NotesSection { ) { debug(endnotes_build) { writeln( - "{^{", m.captures[1], ".}^}../", segment_anchor_tag_that_object_belongs_to, ".fnSuffix#noteref_\n ", m.captures[1], " ", + "{^{", m.captures[1], ".}^}" ~ mkup.mark_internal_site_lnk ~ "../", segment_anchor_tag_that_object_belongs_to, ".fnSuffix#noteref_\n ", m.captures[1], " ", m.captures[2]); // sometimes need segment name (segmented html & epub) } // TODO NEXT you need anchor for segments at this point -> @@ -4824,7 +4837,7 @@ struct NotesSection { m.captures[1]) ~ " " ~ m.captures[2] ~ "』" ) : (munge.url_links( - "{^{" ~ m.captures[1] ~ ".}^}../" ~ + "{^{" ~ m.captures[1] ~ ".}^}" ~ mkup.mark_internal_site_lnk ~ "../" ~ segment_anchor_tag_that_object_belongs_to ~ ".fnSuffix#noteref_" ~ m.captures[1]) ~ " " ~ m.captures[2] ~ "』" ); diff --git a/org/ao_defaults.org b/org/ao_defaults.org index 28ed15c..e54d360 100644 --- a/org/ao_defaults.org +++ b/org/ao_defaults.org @@ -709,6 +709,7 @@ template InternalMarkup() { auto en_b_o = "〖"; auto en_b_c = "〗"; // endnote en_b_o: '~['; en_b_c: ']~'; auto lnk_o = "┥"; auto lnk_c = "┝"; auto url_o = "┤"; auto url_c = "├"; + auto mark_internal_site_lnk = "¤"; auto nbsp = "░"; auto br_line = "┘"; auto br_nl = "┙"; @@ -954,11 +955,11 @@ static inline_text_and_note_al_ = ctRegex!(`(.+?(?:【[*+] #+name: ao_rgx #+BEGIN_SRC d -static inline_url = ctRegex!(`((?:(?:https?|git):\/\/|\.\.\/|\.\/|#)\S+)`, "mg"); -static inline_link_naked_url = ctRegex!(`(^|[ ])((?:(?:https?|git):\/\/|\.\.\/|\.\/|#)\S+?)([.,;:?!]?(?:[ ]|$))`, "mg"); -static inline_link_markup_regular = ctRegex!(`(^|[ ])\{\s*(.+?)\s*\}((?:(?:https?|git):\/\/|\.\.\/|\.\/|#)\S+?)([.,;:?!]?(?:[ ]|$))`, "mg"); -static inline_link_endnote_url_helper_punctuated = ctRegex!(`\{~\^\s+(.+?)\}((?:(?:https?|git):\/\/|\.\.\/|\.\/|#)\S+?)([.,;:?!]?(?:[ ]|$))`, "mg"); -static inline_link_endnote_url_helper = ctRegex!(`\{~\^\s+(.+?)\}((?:(?:https?|git):\/\/|\.\.\/|\.\/|#)\S+)`, "mg"); +static inline_url = ctRegex!(`((?:(?:https?|git):\/\/|¤?\.\.\/|¤?\.\/|#)\S+)`, "mg"); +static inline_link_naked_url = ctRegex!(`(^|[ ])((?:(?:https?|git):\/\/|¤?\.\.\/|¤?\.\/|#)\S+?)([.,;:?!]?(?:[ ]|$))`, "mg"); +static inline_link_markup_regular = ctRegex!(`(^|[ ])\{\s*(.+?)\s*\}((?:(?:https?|git):\/\/|¤?\.\.\/|¤?\.\/|#)\S+?)([.,;:?!]?(?:[ ]|$))`, "mg"); +static inline_link_endnote_url_helper_punctuated = ctRegex!(`\{~\^\s+(.+?)\}((?:(?:https?|git):\/\/|¤?\.\.\/|¤?\.\/|#)\S+?)([.,;:?!]?(?:[ ]|$))`, "mg"); +static inline_link_endnote_url_helper = ctRegex!(`\{~\^\s+(.+?)\}((?:(?:https?|git):\/\/|¤?\.\.\/|¤?\.\/|#)\S+)`, "mg"); static inline_a_url = ctRegex!(`(┤)(\S+?)(├)`, "mg"); #+END_SRC diff --git a/org/ao_output_debugs.org b/org/ao_output_debugs.org index f0a8cab..43e1142 100644 --- a/org/ao_output_debugs.org +++ b/org/ao_output_debugs.org @@ -320,7 +320,6 @@ debug(dom) { #+END_SRC *** endnotes_section (seg & scroll) :endnotes: - **** endnotes #+name: ao_output_debugs @@ -380,7 +379,6 @@ debug(section_bibliography) { #+END_SRC *** bookindex_section (seg & scroll) :bookindex: - **** bookindex #+name: ao_output_debugs diff --git a/src/sdp/ao_abstract_doc_source.d b/src/sdp/ao_abstract_doc_source.d index ec1536e..e813260 100644 --- a/src/sdp/ao_abstract_doc_source.d +++ b/src/sdp/ao_abstract_doc_source.d @@ -42,7 +42,7 @@ template SiSUdocAbstraction() { h_text_5, // extra level, drop content_non_header } // header section A-D; header text 1-4 - enum DocStructCollapsedHeading { lv0, lv1, lv2, lv3, lv4, lv5, lv6, lv7 } // not yet used + enum DocStructCollapsedHeading { lv0, lv1, lv2, lv3, lv4, lv5, lv6, lv7 } /+ biblio variables +/ string biblio_tag_name, biblio_tag_entry, st; string[] biblio_arr_json; @@ -77,7 +77,7 @@ template SiSUdocAbstraction() { switch (obj.heading_lev_markup) { case 0: lv_ancestors[0] = to!string(obj.text); - foreach(k; 1..8) { // 1 .. 7 ? + foreach(k; 1..8) { lv_ancestors[k] = ""; } goto default; @@ -1030,8 +1030,9 @@ template SiSUdocAbstraction() { comp_obj_toc.bullet = false; if (the_endnotes_section.length > 1) { toc_txt_ = format( - "{ %s }../%s.fnSuffix", + "{ %s }%s../%s.fnSuffix", "Endnotes", + mkup.mark_internal_site_lnk, "endnotes", // segment_anchor_tag_that_object_belongs_to ); toc_txt_= munge.url_links(toc_txt_); @@ -1040,8 +1041,9 @@ template SiSUdocAbstraction() { } if (the_glossary_section.length > 1) { toc_txt_ = format( - "{ %s }../%s.fnSuffixs", + "{ %s }%s../%s.fnSuffixs", "Glossary", + mkup.mark_internal_site_lnk, "glossary", // segment_anchor_tag_that_object_belongs_to ); toc_txt_= munge.url_links(toc_txt_); @@ -1058,8 +1060,9 @@ template SiSUdocAbstraction() { } if (the_bibliography_section.length > 1){ toc_txt_ = format( - "{ %s }../%s.fnSuffix", + "{ %s }%s../%s.fnSuffix", "Bibliography", + mkup.mark_internal_site_lnk, "bibliography", // segment_anchor_tag_that_object_belongs_to ); toc_txt_= munge.url_links(toc_txt_); @@ -1077,8 +1080,9 @@ template SiSUdocAbstraction() { } if (the_bookindex_section["seg"].length > 1) { toc_txt_ = format( - "{ %s }../%s.fnSuffix", + "{ %s }%s../%s.fnSuffix", "Book Index", + mkup.mark_internal_site_lnk, "bookindex", // segment_anchor_tag_that_object_belongs_to ); toc_txt_= munge.url_links(toc_txt_); @@ -1097,8 +1101,9 @@ template SiSUdocAbstraction() { } if (the_blurb_section.length > 1) { toc_txt_ = format( - "{ %s }../%s.fnSuffix", + "{ %s }%s../%s.fnSuffix", "Blurb", + mkup.mark_internal_site_lnk, "blurb", // segment_anchor_tag_that_object_belongs_to ); toc_txt_= munge.url_links(toc_txt_); @@ -3135,6 +3140,8 @@ template SiSUdocAbstraction() { in { } body { ObjGenericComposite comp_obj_toc; + mixin InternalMarkup; + auto mkup = InlineMarkup(); char[] heading_toc_ = to!(char[])(obj_["body_nugget"].dup.strip); heading_toc_ = _clean_heading_toc_(heading_toc_); auto attrib=""; @@ -3192,7 +3199,7 @@ template SiSUdocAbstraction() { "hang_position" : 0, "base_position" : 0, ]; - toc_txt_ = "{ Table of Contents }../toc.fnSuffix"; + toc_txt_ = "{ Table of Contents }" ~ mkup.mark_internal_site_lnk ~ "../toc.fnSuffix"; toc_txt_= munge.url_links(toc_txt_); comp_obj_toc.indent_hang = indent["hang_position"]; comp_obj_toc.indent_base = indent["base_position"]; @@ -3216,8 +3223,9 @@ template SiSUdocAbstraction() { break; case 4: toc_txt_ = format( - "{ %s }../%s.fnSuffix", + "{ %s }%s../%s.fnSuffix", heading_toc_, + mkup.mark_internal_site_lnk, segment_anchor_tag_that_object_belongs_to, ); lev4_subtoc[segment_anchor_tag_that_object_belongs_to] = []; @@ -3233,8 +3241,9 @@ template SiSUdocAbstraction() { break; case 5: .. case 7: toc_txt_ = format( - "{ %s }../%s.fnSuffix#%s", + "{ %s }%s../%s.fnSuffix#%s", heading_toc_, + mkup.mark_internal_site_lnk, segment_anchor_tag_that_object_belongs_to, _anchor_tag, ); @@ -3789,6 +3798,8 @@ template SiSUdocAbstraction() { bool[string] opt_action_bool, ) { mixin SiSUnode; + mixin InternalMarkup; + auto mkup = InlineMarkup(); string type_is; string lev; int heading_lev_markup, heading_lev_collapsed; @@ -3852,7 +3863,7 @@ template SiSUdocAbstraction() { bi_tmp_scroll ~= munge.url_links(" {" ~ ref_ ~ "}#" ~ go ~ ", "); bi_tmp_seg ~= (segment_anchor_tag_that_object_belongs_to.empty) ? munge.url_links(" {" ~ ref_ ~ "}#" ~ go ~ ", ") - : munge.url_links(" {" ~ ref_ ~ "}../" ~ segment_anchor_tag_that_object_belongs_to ~ ".fnSuffix#" ~ go ~ ", "); + : munge.url_links(" {" ~ ref_ ~ "}" ~ mkup.mark_internal_site_lnk ~ "../" ~ segment_anchor_tag_that_object_belongs_to ~ ".fnSuffix#" ~ go ~ ", "); } bi_tmp_scroll ~= " \\\\\n "; bi_tmp_seg ~= " \\\\\n "; @@ -3869,7 +3880,7 @@ template SiSUdocAbstraction() { bi_tmp_scroll ~= munge.url_links(" {" ~ ref_ ~ "}#" ~ go ~ ", "); bi_tmp_seg ~= (segment_anchor_tag_that_object_belongs_to.empty) ? munge.url_links(" {" ~ ref_ ~ "}#" ~ go ~ ", ") - : munge.url_links(" {" ~ ref_ ~ "}../" ~ segment_anchor_tag_that_object_belongs_to ~ ".fnSuffix#" ~ go ~ ", "); + : munge.url_links(" {" ~ ref_ ~ "}" ~ mkup.mark_internal_site_lnk ~ "../" ~ segment_anchor_tag_that_object_belongs_to ~ ".fnSuffix#" ~ go ~ ", "); } bi_tmp_scroll ~= " \\\\\n "; bi_tmp_seg ~= " \\\\\n "; @@ -3937,6 +3948,8 @@ template SiSUdocAbstraction() { ); } body { + mixin InternalMarkup; + auto mkup = InlineMarkup(); auto munge = ObjInlineMarkupMunge(); foreach( m; @@ -3947,7 +3960,7 @@ template SiSUdocAbstraction() { ) { debug(endnotes_build) { writeln( - "{^{", m.captures[1], ".}^}../", segment_anchor_tag_that_object_belongs_to, ".fnSuffix#noteref_\n ", m.captures[1], " ", + "{^{", m.captures[1], ".}^}" ~ mkup.mark_internal_site_lnk ~ "../", segment_anchor_tag_that_object_belongs_to, ".fnSuffix#noteref_\n ", m.captures[1], " ", m.captures[2]); // sometimes need segment name (segmented html & epub) } // TODO NEXT you need anchor for segments at this point -> @@ -3958,7 +3971,7 @@ template SiSUdocAbstraction() { m.captures[1]) ~ " " ~ m.captures[2] ~ "』" ) : (munge.url_links( - "{^{" ~ m.captures[1] ~ ".}^}../" ~ + "{^{" ~ m.captures[1] ~ ".}^}" ~ mkup.mark_internal_site_lnk ~ "../" ~ segment_anchor_tag_that_object_belongs_to ~ ".fnSuffix#noteref_" ~ m.captures[1]) ~ " " ~ m.captures[2] ~ "』" ); diff --git a/src/sdp/ao_defaults.d b/src/sdp/ao_defaults.d index c80933c..1e88e3b 100644 --- a/src/sdp/ao_defaults.d +++ b/src/sdp/ao_defaults.d @@ -619,6 +619,7 @@ template InternalMarkup() { auto en_b_o = "〖"; auto en_b_c = "〗"; // endnote en_b_o: '~['; en_b_c: ']~'; auto lnk_o = "┥"; auto lnk_c = "┝"; auto url_o = "┤"; auto url_c = "├"; + auto mark_internal_site_lnk = "¤"; auto nbsp = "░"; auto br_line = "┘"; auto br_nl = "┙"; diff --git a/src/sdp/ao_rgx.d b/src/sdp/ao_rgx.d index 6641d6a..f800a12 100644 --- a/src/sdp/ao_rgx.d +++ b/src/sdp/ao_rgx.d @@ -149,11 +149,11 @@ template RgxInit() { static inline_al_delimiter_open_plus = ctRegex!(`【\+`, "m"); static inline_text_and_note_al = ctRegex!(`(?P.+?)【(?:[*+ ]*)(?P.+?)】`, "mg"); static inline_text_and_note_al_ = ctRegex!(`(.+?(?:【[*+]*\s+.+?】|$))`, "mg"); - static inline_url = ctRegex!(`((?:(?:https?|git):\/\/|\.\.\/|\.\/|#)\S+)`, "mg"); - static inline_link_naked_url = ctRegex!(`(^|[ ])((?:(?:https?|git):\/\/|\.\.\/|\.\/|#)\S+?)([.,;:?!]?(?:[ ]|$))`, "mg"); - static inline_link_markup_regular = ctRegex!(`(^|[ ])\{\s*(.+?)\s*\}((?:(?:https?|git):\/\/|\.\.\/|\.\/|#)\S+?)([.,;:?!]?(?:[ ]|$))`, "mg"); - static inline_link_endnote_url_helper_punctuated = ctRegex!(`\{~\^\s+(.+?)\}((?:(?:https?|git):\/\/|\.\.\/|\.\/|#)\S+?)([.,;:?!]?(?:[ ]|$))`, "mg"); - static inline_link_endnote_url_helper = ctRegex!(`\{~\^\s+(.+?)\}((?:(?:https?|git):\/\/|\.\.\/|\.\/|#)\S+)`, "mg"); + static inline_url = ctRegex!(`((?:(?:https?|git):\/\/|¤?\.\.\/|¤?\.\/|#)\S+)`, "mg"); + static inline_link_naked_url = ctRegex!(`(^|[ ])((?:(?:https?|git):\/\/|¤?\.\.\/|¤?\.\/|#)\S+?)([.,;:?!]?(?:[ ]|$))`, "mg"); + static inline_link_markup_regular = ctRegex!(`(^|[ ])\{\s*(.+?)\s*\}((?:(?:https?|git):\/\/|¤?\.\.\/|¤?\.\/|#)\S+?)([.,;:?!]?(?:[ ]|$))`, "mg"); + static inline_link_endnote_url_helper_punctuated = ctRegex!(`\{~\^\s+(.+?)\}((?:(?:https?|git):\/\/|¤?\.\.\/|¤?\.\/|#)\S+?)([.,;:?!]?(?:[ ]|$))`, "mg"); + static inline_link_endnote_url_helper = ctRegex!(`\{~\^\s+(.+?)\}((?:(?:https?|git):\/\/|¤?\.\.\/|¤?\.\/|#)\S+)`, "mg"); static inline_a_url = ctRegex!(`(┤)(\S+?)(├)`, "mg"); /+ inline markup book index +/ static book_index = ctRegex!(`^=\{\s*(.+?)\}$`, "m"); -- cgit v1.2.3