From a263d67a5dfb5fad70059f63c1029f9174bf7ff0 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Mon, 30 Apr 2018 21:05:13 -0400 Subject: link url matching - smid: sisu markup identify - inline_link_markup_regular matches series of marked up urls, e.g. { link txt }http://url, { link txt }http://url --- src/sdp/meta/conf_make_meta_structs.d | 8 ++++---- src/sdp/meta/metadoc_from_src.d | 24 ++++++++++++------------ src/sdp/meta/rgx.d | 12 ++++++------ src/sdp/output/epub3.d | 8 ++++---- src/sdp/output/html.d | 16 ++++++++-------- src/sdp/output/rgx.d | 2 +- src/sdp/output/xmls.d | 16 ++++++++-------- 7 files changed, 43 insertions(+), 43 deletions(-) (limited to 'src/sdp') diff --git a/src/sdp/meta/conf_make_meta_structs.d b/src/sdp/meta/conf_make_meta_structs.d index 64e45d9..b67b9ad 100644 --- a/src/sdp/meta/conf_make_meta_structs.d +++ b/src/sdp/meta/conf_make_meta_structs.d @@ -19,17 +19,17 @@ auto _mkup = InlineMarkup(); auto url_markup(string line) { auto line_ = (line) .replaceAll( - _rgx.inline_link_markup_regular, + _rgx.smid_inline_link_markup_regular, ("$1" ~ _mkup.lnk_o ~ "$2" ~ _mkup.lnk_c - ~ _mkup.url_o ~ "$3" ~ _mkup.url_c + ~ _mkup.url_o ~ "$3" ~ _mkup.url_c ~ "$4") // ("$1{ $2 }$3$4") ) .replaceAll( - _rgx.inline_link_naked_url, + _rgx.smid_inline_link_naked_url, ("$1" ~ _mkup.lnk_o ~ "$2" ~ _mkup.lnk_c - ~ _mkup.url_o ~ "$2" ~ _mkup.url_c + ~ _mkup.url_o ~ "$2" ~ _mkup.url_c ~ "$3") // ("$1{ $2 }$2$3") ) .replaceAll( diff --git a/src/sdp/meta/metadoc_from_src.d b/src/sdp/meta/metadoc_from_src.d index 9859f7b..f4701dc 100644 --- a/src/sdp/meta/metadoc_from_src.d +++ b/src/sdp/meta/metadoc_from_src.d @@ -3816,11 +3816,11 @@ template SiSUdocAbstraction() { obj_txt_in = obj_txt_in.replaceAll(rgx.inline_mono, (mng.mono ~ "{$1}" ~ mng.mono)); /+ url matched +/ obj_txt_in = obj_txt_in.replaceAll(rgx.inline_notes_al_special, ""); // TODO reinstate when special footnotes are implemented - if (obj_txt_in.match(rgx.inline_url_generic)) { + if (obj_txt_in.match(rgx.smid_inline_url_generic)) { /+ link: naked url: http://url +/ - if (obj_txt_in.match(rgx.inline_link_naked_url)) { + if (obj_txt_in.match(rgx.smid_inline_link_naked_url)) { obj_txt_in = (obj_txt_in).replaceAll( - rgx.inline_link_naked_url, + rgx.smid_inline_link_naked_url, ("$1" ~ mkup.lnk_o ~ "$2" ~ mkup.lnk_c ~ mkup.url_o ~ "$2" ~ mkup.url_c @@ -3832,10 +3832,10 @@ template SiSUdocAbstraction() { maps to: { link which includes url as footnote }http://url~{ { http://url }http://url }~ +/ - if (obj_txt_in.match(rgx.inline_link_endnote_url_helper)) { + if (obj_txt_in.match(rgx.smid_inline_link_endnote_url_helper)) { obj_txt_in = (obj_txt_in) .replaceAll( - rgx.inline_link_endnote_url_helper_punctuated, + rgx.smid_inline_link_endnote_url_helper_punctuated, (mkup.lnk_o ~ "$1" ~ mkup.lnk_c ~ mkup.url_o ~ "$2" ~ mkup.url_c ~ "~{ " ~ mkup.lnk_o ~ " $2 " ~ mkup.lnk_c @@ -3843,7 +3843,7 @@ template SiSUdocAbstraction() { ~ " }~$3") // ("{ $1 }$2~{ { $2 }$2 }~$3") ) .replaceAll( - rgx.inline_link_endnote_url_helper, + rgx.smid_inline_link_endnote_url_helper, (mkup.lnk_o ~ "$1" ~ mkup.lnk_c ~ mkup.url_o ~ "$2" ~ mkup.url_c ~ "~{ " ~ mkup.lnk_o ~ " $2 " ~ mkup.lnk_c @@ -3854,9 +3854,9 @@ template SiSUdocAbstraction() { /+ link with regular markup: { linked text or image }http://url +/ - if (obj_txt_in.match(rgx.inline_link_markup_regular)) { + if (obj_txt_in.match(rgx.smid_inline_link_markup_regular)) { obj_txt_in = (obj_txt_in).replaceAll( - rgx.inline_link_markup_regular, + rgx.smid_inline_link_markup_regular, ("$1" ~ mkup.lnk_o ~ "$2" ~ mkup.lnk_c ~ mkup.url_o ~ "$3" ~ mkup.url_c @@ -3955,7 +3955,7 @@ template SiSUdocAbstraction() { (mkup.en_a_o ~ "+" ~ " $1" ~ mkup.en_a_c) ); /+ url matched +/ - if (obj_txt_in.match(rgx.inline_url)) { + if (obj_txt_in.match(rgx.smid_inline_url)) { urls = true; obj_txt_in = url_links(obj_txt_in); } @@ -4134,7 +4134,7 @@ template SiSUdocAbstraction() { obj_txt["munge"] = obj_[obj_key_].dup; obj_txt["munge"] = (obj_["is"].match(ctRegex!(`verse|code`))) ? obj_txt["munge"] - : strip(obj_txt["munge"]); + : obj_txt["munge"].strip; static __gshared string[] anchor_tags_ = []; auto x = munge.init; bool[string] obj_notes_and_links; @@ -4152,7 +4152,7 @@ template SiSUdocAbstraction() { } else if (obj_["lev"] == "1") { writeln("heading anchor tag missing: ", obj_txt["munge"]); } - x =munge.munge_heading(obj_txt["munge"], reset_note_numbers); + x = munge.munge_heading(obj_txt["munge"], reset_note_numbers); reset_note_numbers=false; goto default; case "para": @@ -4653,7 +4653,7 @@ template SiSUdocAbstraction() { } else if (auto m = obj_txt_in.matchFirst(rgx.para_indent_hang)) { _obj_attributes =" \"bullet\": \"false\"," ~ " \"indent_hang\": " ~ m.captures[1].to!string ~ "," - ~ " \"indent_base\": " ~ m.captures[2].to!string ~ ","; + ~ " \"indent_base\": " ~ m.captures[2].to!string ~ ","; } else if (auto m = obj_txt_in.matchFirst(rgx.para_indent)) { _obj_attributes =" \"bullet\": \"false\"," ~ " \"indent_hang\": " ~ m.captures[1].to!string ~ "," diff --git a/src/sdp/meta/rgx.d b/src/sdp/meta/rgx.d index 6006122..d15f90a 100644 --- a/src/sdp/meta/rgx.d +++ b/src/sdp/meta/rgx.d @@ -143,12 +143,12 @@ static template SiSUrgxInit() { static inline_curly_delimiter_close_regular = ctRegex!(`\s*\}~`, "m"); static inline_text_and_note_curly = ctRegex!(`(?P.+?)(?:(?:[~])[{][*+ ]*)(?P.+?)(?:[}][~])`, "mg"); static note_ref = ctRegex!(`^\S+?noteref_([0-9]+)`, "mg"); // {^{73.}^}#noteref_73 - static inline_url_generic = ctRegex!(`(?:^|[}(\[ ])(?:(?:https?|git):\/\/|¤?\.\.\/|¤?\.\/|¤|#)[a-zA-Z0-9_#]`, "mg"); - static inline_url = ctRegex!(`((?:(?:https?|git):\/\/|¤?\.\.\/|¤?\.\/|¤|#)[a-zA-Z0-9_]\S*)`, "mg"); - static inline_link_naked_url = ctRegex!(`(?P^|[ ])(?P(?:(?:https?|git):\/\/|¤?\.\.\/|¤?\.\/|¤)\S+?)(?P[.,;:?!'"]?(?:[ ]|$))`, "mg"); - static inline_link_markup_regular = ctRegex!(`(?P^|[ ])\{\s*(?P.+?)\s*\}(?P(?:(?:https?|git):\/\/|¤?\.\.\/|¤?\.\/|¤|#)\S+?)(?P(?:[,;:? ]|[!.]?(?:[ ]|$)))`, "mg"); - static inline_link_endnote_url_helper_punctuated = ctRegex!(`\{~\^\s+(?P.+?)\}(?P(?:(?:https?|git):\/\/|¤?\.\.\/|¤?\.\/|¤|#)\S+?)(?P[.,;:?!]?(?:[ ]|$))`, "mg"); - static inline_link_endnote_url_helper = ctRegex!(`\{~\^\s+(?P.+?)\}(?P(?:(?:https?|git):\/\/|¤?\.\.\/|¤?\.\/|¤|#)\S+)`, "mg"); + static smid_inline_url_generic = ctRegex!(`(?:^|[}(\[ ])(?:(?:https?|git):\/\/|¤?\.\.\/|¤?\.\/|¤|#)[a-zA-Z0-9_#]`, "mg"); + static smid_inline_url = ctRegex!(`((?:(?:https?|git):\/\/|¤?\.\.\/|¤?\.\/|¤|#)[a-zA-Z0-9_]\S*)`, "mg"); + static smid_inline_link_naked_url = ctRegex!(`(?P
^|[ ])(?P(?:(?:https?|git):\/\/|¤?\.\.\/|¤?\.\/|¤)\S+?)(?P[.,;:?!'"]?(?:[ ]|$))`, "mg"); // issue with #link #32
+    static smid_inline_link_markup_regular                = ctRegex!(`(?P
^|[ ]|[^\S]?)\{\s*(?P.+?)\s*\}(?P(?:(?:https?|git):\/\/|¤?\.\.\/|¤?\.\/|¤|#)\S+?)(?P[;:!,?.]?(?:[ )\]]|$))`, "mg"); // NEXT
+    static smid_inline_link_endnote_url_helper_punctuated = ctRegex!(`\{~\^\s+(?P.+?)\}(?P(?:(?:https?|git):\/\/|¤?\.\.\/|¤?\.\/|¤|#)\S+?)(?P[.,;:?!]?(?:[ ]|$))`, "mg");
+    static smid_inline_link_endnote_url_helper            = ctRegex!(`\{~\^\s+(?P.+?)\}(?P(?:(?:https?|git):\/\/|¤?\.\.\/|¤?\.\/|¤|#)\S+)`, "mg");
     static image                                           = ctRegex!(`([a-zA-Z0-9._-]+?\.(?:png|gif|jpg))`, "mg");
     /+ inline markup book index +/
     static book_index                                     = ctRegex!(`^=\{\s*(.+?)\}$`, "m");
diff --git a/src/sdp/output/epub3.d b/src/sdp/output/epub3.d
index 15e3d35..321ef9b 100644
--- a/src/sdp/output/epub3.d
+++ b/src/sdp/output/epub3.d
@@ -413,24 +413,24 @@ template outputEPub3() {
               switch (obj.is_a) {
               case "quote":
                 auto t = xhtml_format.quote_seg(obj, _txt, suffix);
-                doc_epub3[segment_filename] ~= to!string(t[0]);
+                doc_epub3[segment_filename] ~= t[0].to!string;
                 doc_epub3_endnotes[segment_filename] ~= t[1];
                 break;
               case "group":
                 auto t = xhtml_format.group_seg(obj, _txt, suffix);
-                doc_epub3[segment_filename] ~= to!string(t[0]);
+                doc_epub3[segment_filename] ~= t[0].to!string;
                 doc_epub3_endnotes[segment_filename] ~= t[1];
                 break;
               case "block":
                 auto t = xhtml_format.block_seg(obj, _txt, suffix);
-                doc_epub3[segment_filename] ~= to!string(t[0]);
+                doc_epub3[segment_filename] ~= t[0].to!string;
                 doc_epub3_endnotes[segment_filename] ~= t[1];
                 break;
               case "poem":
                 break;
               case "verse":
                 auto t = xhtml_format.verse_seg(obj, _txt, suffix);
-                doc_epub3[segment_filename] ~= to!string(t[0]);
+                doc_epub3[segment_filename] ~= t[0].to!string;
                 doc_epub3_endnotes[segment_filename] ~= t[1];
                 break;
               case "code":
diff --git a/src/sdp/output/html.d b/src/sdp/output/html.d
index 10539a5..35e3027 100644
--- a/src/sdp/output/html.d
+++ b/src/sdp/output/html.d
@@ -241,13 +241,13 @@ template outputHTML() {
               doc_html[segment_filename] ~= top_level_heading;
             }
             auto t = xhtml_format.heading_seg(obj, _txt, suffix);
-            doc_html[segment_filename] ~= to!string(t[0]);
+            doc_html[segment_filename] ~= t[0].to!string;
             doc_html[segment_filename] ~= xhtml_format.lev4_heading_subtoc(obj);
             doc_html_endnotes[segment_filename] ~= t[1];
             break;
           case 5: .. case 7:
             auto t = xhtml_format.heading_seg(obj, _txt, suffix);
-            doc_html[segment_filename] ~= to!string(t[0]);
+            doc_html[segment_filename] ~= t[0].to!string;
             doc_html_endnotes[segment_filename] ~= t[1];
             break;
           case 8: .. case 9:
@@ -271,7 +271,7 @@ template outputHTML() {
               switch (obj.is_a) {
               case "toc":
                 auto t = xhtml_format.para_seg(obj, _txt, suffix);
-                doc_html[segment_filename] ~= to!string(t[0]);
+                doc_html[segment_filename] ~= t[0].to!string;
                 break;
               default:
                 if ((doc_matters.opt.action.debug_do)) {
@@ -293,7 +293,7 @@ template outputHTML() {
               switch (obj.is_a) {
               case "para":
                 auto t = xhtml_format.para_seg(obj, _txt, suffix);
-                doc_html[segment_filename] ~= to!string(t[0]);
+                doc_html[segment_filename] ~= t[0].to!string;
                 doc_html_endnotes[segment_filename] ~= t[1];
                 break;
               default:
@@ -307,24 +307,24 @@ template outputHTML() {
               switch (obj.is_a) {
               case "quote":
                 auto t = xhtml_format.quote_seg(obj, _txt, suffix);
-                doc_html[segment_filename] ~= to!string(t[0]);
+                doc_html[segment_filename] ~= t[0].to!string;
                 doc_html_endnotes[segment_filename] ~= t[1];
                 break;
               case "group":
                 auto t = xhtml_format.group_seg(obj, _txt, suffix);
-                doc_html[segment_filename] ~= to!string(t[0]);
+                doc_html[segment_filename] ~= t[0].to!string;
                 doc_html_endnotes[segment_filename] ~= t[1];
                 break;
               case "block":
                 auto t = xhtml_format.block_seg(obj, _txt, suffix);
-                doc_html[segment_filename] ~= to!string(t[0]);
+                doc_html[segment_filename] ~= t[0].to!string;
                 doc_html_endnotes[segment_filename] ~= t[1];
                 break;
               case "poem":
                 break;
               case "verse":
                 auto t = xhtml_format.verse_seg(obj, _txt, suffix);
-                doc_html[segment_filename] ~= to!string(t[0]);
+                doc_html[segment_filename] ~= t[0].to!string;
                 doc_html_endnotes[segment_filename] ~= t[1];
                 break;
               case "code":
diff --git a/src/sdp/output/rgx.d b/src/sdp/output/rgx.d
index 4bfa72a..0227902 100644
--- a/src/sdp/output/rgx.d
+++ b/src/sdp/output/rgx.d
@@ -96,7 +96,7 @@ static template SiSUoutputRgxInit() {
     static table_delimiter_col                           = ctRegex!("[ ]*[┊][ ]*", "mg");
     static table_delimiter_row                           = ctRegex!("[ ]*\n", "mg");
     static xhtml_ampersand                            = ctRegex!(`[&]`);      // &
-    static xhtml_quotation                            = ctRegex!(`[&]`);      // "
+    static xhtml_quotation                            = ctRegex!(`["]`);      // "
     static xhtml_less_than                            = ctRegex!(`[<]`);      // <
     static xhtml_greater_than                         = ctRegex!(`[>]`);      // >
     static xhtml_line_break                           = ctRegex!(` [\\]{2}`); // 
diff --git a/src/sdp/output/xmls.d b/src/sdp/output/xmls.d index 58ae237..7dd6a60 100644 --- a/src/sdp/output/xmls.d +++ b/src/sdp/output/xmls.d @@ -444,10 +444,10 @@ template outputXHTMLs() { lev4_subtoc ~= "
\n"; foreach (subtoc; obj.lev4_subtoc) { if (auto m = subtoc.match(rgx.inline_link_subtoc)) { - auto indent = to!string(m.captures[1]); - auto text = to!string(m.captures[2]); + auto indent = m.captures[1].to!string; + auto text = m.captures[2].to!string; text = font_face(text); - auto link = to!string(m.captures[3]); + auto link = m.captures[3].to!string; lev4_subtoc ~= subtoc.replaceFirst(rgx.inline_link_subtoc, format(q"¶

%s @@ -670,7 +670,7 @@ template outputXHTMLs() { string _suffix = ".html", ) { auto t = inline_markup_seg(obj, _txt, _suffix); - _txt = to!string(t[0]); + _txt = t[0].to!string; string[] _endnotes = t[1]; string o = para(obj, _txt); auto u = tuple( @@ -726,7 +726,7 @@ template outputXHTMLs() { string _suffix = ".html", ) { auto t = inline_markup_seg(obj, _txt, _suffix); - _txt = to!string(t[0]); + _txt = t[0].to!string; string[] _endnotes = t[1]; string o = quote(obj, _txt); auto u = tuple( @@ -782,7 +782,7 @@ template outputXHTMLs() { string _suffix = ".html", ) { auto t = inline_markup_seg(obj, _txt, _suffix); - _txt = to!string(t[0]); + _txt = t[0].to!string; string[] _endnotes = t[1]; string o = group(obj, _txt); auto u = tuple( @@ -834,7 +834,7 @@ template outputXHTMLs() { string _suffix = ".html", ) { auto t = inline_markup_seg(obj, _txt, _suffix); - _txt = to!string(t[0]); + _txt = t[0].to!string; string[] _endnotes = t[1]; string o = block(obj, _txt); auto u = tuple( @@ -886,7 +886,7 @@ template outputXHTMLs() { string _suffix = ".html", ) { auto t = inline_markup_seg(obj, _txt, _suffix); - _txt = to!string(t[0]); + _txt = t[0].to!string; string[] _endnotes = t[1]; string o = verse(obj, _txt); auto u = tuple( -- cgit v1.2.3