diff options
Diffstat (limited to 'src/sdp/ao_abstract_doc_source.d')
-rw-r--r-- | src/sdp/ao_abstract_doc_source.d | 157 |
1 files changed, 72 insertions, 85 deletions
diff --git a/src/sdp/ao_abstract_doc_source.d b/src/sdp/ao_abstract_doc_source.d index ef64f0b..6690a9f 100644 --- a/src/sdp/ao_abstract_doc_source.d +++ b/src/sdp/ao_abstract_doc_source.d @@ -362,7 +362,7 @@ template SiSUdocAbstraction() { line, ); } - line = replaceAll(line, rgx.true_dollar, "$$$$"); + line = (line).replaceAll(rgx.true_dollar, "$$$$"); // dollar represented as $$ needed to stop submatching on $ // (substitutions using ${identifiers} must take into account (i.e. happen earlier)) debug(source) { // source lines @@ -1965,7 +1965,7 @@ template SiSUdocAbstraction() { tmp ~= au.str; } } - tmp = replace(tmp, rgx.trailing_comma, ""); + tmp = (tmp).replace(rgx.trailing_comma, ""); j["author"].str = tmp; goto default; case "editor_raw": // editor_arr editor (fn sn) @@ -1980,7 +1980,7 @@ template SiSUdocAbstraction() { tmp ~= ed.str; } } - tmp = replace(tmp, rgx.trailing_comma, ""); + tmp = (tmp).replace(rgx.trailing_comma, ""); j["editor"].str = tmp; goto default; case "fulltitle": // title & subtitle @@ -2876,10 +2876,11 @@ template SiSUdocAbstraction() { assertions_doc_structure(an_object, lv); // includes most of the logic for collapsed levels switch (an_object["lev"]) { case "A": - an_object[an_object_key]=replaceFirst(an_object[an_object_key], - rgx.variable_doc_title, (dochead_meta_aa["title"]["full"] ~ ",")); - an_object[an_object_key]=replaceFirst(an_object[an_object_key], - rgx.variable_doc_author, dochead_meta_aa["creator"]["author"]); + an_object[an_object_key]=(an_object[an_object_key]) + .replaceFirst(rgx.variable_doc_title, + (dochead_meta_aa["title"]["full"] ~ ",")) + .replaceFirst(rgx.variable_doc_author, + dochead_meta_aa["creator"]["author"]); collapsed_lev["h0"] = 0; an_object["lev_collapsed_number"] = to!string(collapsed_lev["h0"]); @@ -2994,7 +2995,7 @@ template SiSUdocAbstraction() { } } } - auto _para_match_(L,O,K,I,B,T,C)( + void _para_match_(L,O,K,I,B,T,C)( return ref L line, return ref O an_object, return ref K an_object_key, @@ -3089,17 +3090,15 @@ template SiSUdocAbstraction() { n_foot_sp_asterisk = 0; n_foot_sp_plus = 0; } - string url_links(Ot)(Ot obj_txt_in, string suffix = ".html") { + string url_links(Ot)(Ot obj_txt_in) { debug(asserts){ static assert(is(typeof(obj_txt_in) == string)); } /+ url matched +/ - if (match(obj_txt_in, rgx.inline_url)) { + if (match(obj_txt_in, rgx.inline_url_generic)) { /+ link: naked url: http://url +/ if (match(obj_txt_in, rgx.inline_link_naked_url)) { - obj_txt_in = - replaceAll( - obj_txt_in, + obj_txt_in = (obj_txt_in).replaceAll( rgx.inline_link_naked_url, ("$1" ~ mkup.lnk_o ~ "$2" ~ mkup.lnk_c @@ -3113,40 +3112,34 @@ template SiSUdocAbstraction() { { link which includes url as footnote }http://url~{ { http://url }http://url }~ +/ if (match(obj_txt_in, rgx.inline_link_endnote_url_helper)) { - obj_txt_in = - replaceAll( - obj_txt_in, - rgx.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 - ~ mkup.url_o ~ "$2" ~ mkup.url_c - ~ " }~$3") // ("{ $1 }$2~{ { $2 }$2 }~$3") - ); - obj_txt_in = - replaceAll( - obj_txt_in, - rgx.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 - ~ mkup.url_o ~ "$2" ~ mkup.url_c - ~ " }~") // ("{ $1 }$2~{ { $2 }$2 }~") - ); + obj_txt_in = (obj_txt_in).replaceAll( + rgx.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 + ~ mkup.url_o ~ "$2" ~ mkup.url_c + ~ " }~$3") // ("{ $1 }$2~{ { $2 }$2 }~$3") + ); + obj_txt_in = (obj_txt_in).replaceAll( + rgx.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 + ~ mkup.url_o ~ "$2" ~ mkup.url_c + ~ " }~") // ("{ $1 }$2~{ { $2 }$2 }~") + ); } /+ link with regular markup: { linked text or image }http://url +/ if (match(obj_txt_in, rgx.inline_link_markup_regular)) { - obj_txt_in = - replaceAll( - obj_txt_in, - rgx.inline_link_markup_regular, - ("$1" - ~ mkup.lnk_o ~ "$2" ~ mkup.lnk_c - ~ mkup.url_o ~ "$3" ~ mkup.url_c - ~ "$4") // ("$1{ $2 }$3$4") - ); + obj_txt_in = (obj_txt_in).replaceAll( + rgx.inline_link_markup_regular, + ("$1" + ~ mkup.lnk_o ~ "$2" ~ mkup.lnk_c + ~ mkup.url_o ~ "$3" ~ mkup.url_c + ~ "$4") // ("$1{ $2 }$3$4") + ); } } return obj_txt_in; @@ -3158,12 +3151,10 @@ template SiSUdocAbstraction() { /+ endnotes (regular) +/ bool flg_notes_reg = false; bool flg_notes_star = false; - obj_txt_in = - replaceAll( - obj_txt_in, - rgx.inline_notes_curly, - (mkup.en_a_o ~ " $1" ~ mkup.en_a_c) - ); + obj_txt_in = (obj_txt_in).replaceAll( + rgx.inline_notes_curly, + (mkup.en_a_o ~ " $1" ~ mkup.en_a_c) + ); if (!(stage_reset_note_numbers) && reset_note_numbers) { stage_reset_note_numbers = true; } @@ -3182,22 +3173,18 @@ template SiSUdocAbstraction() { ++n_foot_sp_asterisk; asterisks_ = "*"; n_foot=n_foot_sp_asterisk; - obj_txt_out ~= - (replaceFirst( - to!string(n.hit), - rgx.inline_al_delimiter_open_symbol_star, - (mkup.en_a_o ~ replicate(asterisks_, n_foot_sp_asterisk) ~ " ") - ) ~ "\n"); + obj_txt_out ~= (to!string(n.hit)).replaceFirst( + rgx.inline_al_delimiter_open_symbol_star, + (mkup.en_a_o ~ replicate(asterisks_, n_foot_sp_asterisk) ~ " ") + ) ~ "\n"; } else if (match(to!string(n.hit), rgx.inline_al_delimiter_open_regular)) { flg_notes_reg = true; ++n_foot_reg; n_foot=n_foot_reg; - obj_txt_out ~= - (replaceFirst( - to!string(n.hit), - rgx.inline_al_delimiter_open_regular, - (mkup.en_a_o ~ to!string(n_foot) ~ " ") - ) ~ "\n"); + obj_txt_out ~= (to!string(n.hit)).replaceFirst( + rgx.inline_al_delimiter_open_regular, + (mkup.en_a_o ~ to!string(n_foot) ~ " ") + ) ~ "\n"; } else { obj_txt_out ~= to!string(n.hit) ~ "\n"; } @@ -3276,9 +3263,9 @@ template SiSUdocAbstraction() { } } body { - obj_txt["munge"]=obj_txt_in; - obj_txt["munge"]=replaceFirst(obj_txt["munge"], rgx.para_attribs, ""); - obj_txt["munge"]=replaceFirst(obj_txt["munge"], rgx.obj_cite_number_off_all, ""); + obj_txt["munge"]=(obj_txt_in) + .replaceFirst(rgx.para_attribs, "") + .replaceFirst(rgx.obj_cite_number_off_all, ""); auto t = object_notes_and_links_(obj_txt["munge"]); debug(munge) { writeln(__LINE__); @@ -3295,10 +3282,10 @@ template SiSUdocAbstraction() { } } body { - obj_txt["munge"]=obj_txt_in; - obj_txt["munge"]=replaceFirst(obj_txt["munge"], rgx.heading, ""); - obj_txt["munge"]=replaceFirst(obj_txt["munge"], rgx.obj_cite_number_off_all, ""); - obj_txt["munge"]=strip(obj_txt["munge"]); + obj_txt["munge"]=(obj_txt_in) + .replaceFirst(rgx.heading, "") + .replaceFirst(rgx.obj_cite_number_off_all, "") + .strip; auto t = object_notes_and_links_(obj_txt["munge"], reset_note_numbers); debug(munge) { writeln(__LINE__); @@ -3310,7 +3297,6 @@ template SiSUdocAbstraction() { } invariant() { } - /+ revisit +/ string code(Ot)(Ot obj_txt_in) in { debug(asserts){ @@ -3490,12 +3476,9 @@ template SiSUdocAbstraction() { static assert(is(typeof(heading_toc_) == char[])); } auto m = matchFirst(cast(char[]) heading_toc_, rgx.heading); - heading_toc_ = - replaceAll( - m.post, - rgx.inline_notes_curly_gen, - ("") - ); + heading_toc_ = (m.post).replaceAll( + rgx.inline_notes_curly_gen, + ""); return heading_toc_; }; auto table_of_contents_gather_headings(O,Ma,Ts,Ta,X,Toc)( @@ -3769,10 +3752,11 @@ template SiSUdocAbstraction() { writeln(heading_number_auto_composite); } if (!empty(heading_number_auto_composite)) { - munge_=replaceFirst(munge_, rgx.heading, - "$1~$2 " ~ heading_number_auto_composite ~ ". "); - munge_=replaceFirst(munge_, rgx.heading_marker_missing_tag, - "$1~" ~ heading_number_auto_composite ~ " "); + munge_=(munge_) + .replaceFirst(rgx.heading, + "$1~$2 " ~ heading_number_auto_composite ~ ". ") + .replaceFirst(rgx.heading_marker_missing_tag, + "$1~" ~ heading_number_auto_composite ~ " "); } } } @@ -3788,16 +3772,19 @@ template SiSUdocAbstraction() { if (!(match(munge_, rgx.heading_anchor_tag))) { // if (anchor_tags_.length == 0) { if (match(munge_, rgx.heading_identify_anchor_tag)) { if (auto m = match(munge_, rgx.heading_extract_named_anchor_tag)) { - munge_=replaceFirst(munge_, rgx.heading_marker_missing_tag, + munge_=(munge_).replaceFirst( + rgx.heading_marker_missing_tag, "$1~" ~ toLower(m.captures[1]) ~ "_" ~ m.captures[2] ~ " "); } else if (auto m = match(munge_, rgx.heading_extract_unnamed_anchor_tag)) { - munge_=replaceFirst(munge_, rgx.heading_marker_missing_tag, + munge_=(munge_).replaceFirst( + rgx.heading_marker_missing_tag, "$1~" ~ "s" ~ m.captures[1] ~ " "); } } else if (lev_ == "1") { // (if not successful) manufacture a unique anchor tag for lev=="1" static __gshared int heading_num_lev1 = 0; heading_num_lev1 ++; - munge_=replaceFirst(munge_, rgx.heading_marker_missing_tag, + munge_=(munge_).replaceFirst( + rgx.heading_marker_missing_tag, "$1~" ~ "x" ~ to!string(heading_num_lev1) ~ " "); } } @@ -4233,7 +4220,7 @@ template SiSUdocAbstraction() { foreach (mainkey; mainkeys) { write("_0_1 !{", mainkey, "}! "); foreach (ref_; bookindex_unordered_hashes[mainkey]["_a"]) { - auto go = replaceAll(ref_, rgx.book_index_go, "$1"); + auto go = (ref_).replaceAll(rgx.book_index_go, "$1"); write(" {", ref_, "}#", go, ", "); } writeln(" \\\\"); @@ -4243,7 +4230,7 @@ template SiSUdocAbstraction() { foreach (subkey; subkeys) { write(" ", subkey, ", "); foreach (ref_; bookindex_unordered_hashes[mainkey][subkey]) { - auto go = replaceAll(ref_, rgx.book_index_go, "$1"); + auto go = (ref_).replaceAll(rgx.book_index_go, "$1"); write(" {", ref_, "}#", go, ", "); } writeln(" \\\\"); @@ -4372,8 +4359,8 @@ template SiSUdocAbstraction() { bi_tmp_seg ~= " \\\\\n "; ++skn; } - bi_tmp_scroll = replaceFirst(bi_tmp_scroll, rgx.trailing_linebreak, ""); - bi_tmp_seg = replaceFirst(bi_tmp_seg, rgx.trailing_linebreak, ""); + bi_tmp_scroll = (bi_tmp_scroll).replaceFirst(rgx.trailing_linebreak, ""); + bi_tmp_seg = (bi_tmp_seg).replaceFirst(rgx.trailing_linebreak, ""); comp_obj_para = comp_obj_para.init; comp_obj_para.use = "backmatter"; comp_obj_para.is_of = "para"; |