diff options
author | Ralph Amissah <ralph@amissah.com> | 2017-02-26 18:27:08 -0500 |
---|---|---|
committer | Ralph Amissah <ralph@amissah.com> | 2019-04-10 15:14:14 -0400 |
commit | 6f27312b0e61932d820b991a15c44845ff2cee75 (patch) | |
tree | 785c5a82b1db1b48480bd3974eba1be33707a846 /org/ao_doc_abstraction.org | |
parent | endnote anchor tags, address issues (diff) |
0.13.5 defaults regex reorganised; some work on (x)html output
Diffstat (limited to 'org/ao_doc_abstraction.org')
-rw-r--r-- | org/ao_doc_abstraction.org | 274 |
1 files changed, 188 insertions, 86 deletions
diff --git a/org/ao_doc_abstraction.org b/org/ao_doc_abstraction.org index 338fae8..fce5c90 100644 --- a/org/ao_doc_abstraction.org +++ b/org/ao_doc_abstraction.org @@ -532,7 +532,7 @@ scope(failure) { 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 @@ -2577,7 +2577,7 @@ void _biblio_block_( 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) @@ -2592,7 +2592,7 @@ void _biblio_block_( 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 @@ -3550,10 +3550,11 @@ auto _heading_matched_(L,C,O,K,Lv,Lc,T,Me)( 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"]); @@ -3674,7 +3675,7 @@ auto _heading_matched_(L,C,O,K,Lv,Lc,T,Me)( #+name: abs_functions_para #+BEGIN_SRC d -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, @@ -3764,6 +3765,8 @@ struct OCNemitter { ***** object inline markup munge :markup:inline: +****** 0. struct, inline markup munge + #+name: ao_emitters_obj_inline_markup_munge #+BEGIN_SRC d struct ObjInlineMarkupMunge { @@ -3780,17 +3783,21 @@ struct ObjInlineMarkupMunge { n_foot_sp_asterisk = 0; n_foot_sp_plus = 0; } - string url_links(Ot)(Ot obj_txt_in, string suffix = ".html") { +#+END_SRC + +****** url links + +#+name: ao_emitters_obj_inline_markup_munge +#+BEGIN_SRC d + 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 @@ -3804,44 +3811,44 @@ struct ObjInlineMarkupMunge { { 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; } +#+END_SRC + +****** footnotes endnotes markup + +#+name: ao_emitters_obj_inline_markup_munge +#+BEGIN_SRC d auto footnotes_endnotes_markup_and_number_or_stars(Ot)(Ot obj_txt_in, bool reset_note_numbers) { debug(asserts){ static assert(is(typeof(obj_txt_in) == string)); @@ -3849,12 +3856,10 @@ struct ObjInlineMarkupMunge { /+ 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; } @@ -3873,22 +3878,18 @@ struct ObjInlineMarkupMunge { ++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"; } @@ -3904,6 +3905,12 @@ struct ObjInlineMarkupMunge { ); return t; } +#+END_SRC + +****** object notes and links + +#+name: ao_emitters_obj_inline_markup_munge +#+BEGIN_SRC d private auto object_notes_and_links_(Ot)(Ot obj_txt_in, bool reset_note_numbers=false) in { debug(asserts){ @@ -3960,6 +3967,18 @@ struct ObjInlineMarkupMunge { } invariant() { } +#+END_SRC + +****** para +- paragraph text without other identification until two new lines +- general markup + - paragraph attributes + - font faces (bold, italics, underscore etc.) + - footnotes/endnotes + - links + +#+name: ao_emitters_obj_inline_markup_munge +#+BEGIN_SRC d auto para(Ot)(Ot obj_txt_in) in { debug(asserts){ @@ -3967,9 +3986,9 @@ struct ObjInlineMarkupMunge { } } 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__); @@ -3979,6 +3998,14 @@ struct ObjInlineMarkupMunge { } return t; } +#+END_SRC + +****** heading +- identified text by heading level marker followed by text until two new lines +- general markup + +#+name: ao_emitters_obj_inline_markup_munge +#+BEGIN_SRC d auto heading(Ot)(Ot obj_txt_in, bool reset_note_numbers=false) in { debug(asserts){ @@ -3986,10 +4013,10 @@ struct ObjInlineMarkupMunge { } } 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__); @@ -4001,7 +4028,16 @@ struct ObjInlineMarkupMunge { } invariant() { } - /+ revisit +/ +#+END_SRC + +****** code +- newlines +- indentation +- possibly identify syntax for coloring +- no general markup + +#+name: ao_emitters_obj_inline_markup_munge +#+BEGIN_SRC d string code(Ot)(Ot obj_txt_in) in { debug(asserts){ @@ -4014,6 +4050,19 @@ struct ObjInlineMarkupMunge { } invariant() { } +#+END_SRC + +****** group +- group block identified by open an close tags +- general markup + - paragraph attributes + - font faces (bold, italics, underscore etc.) + - footnotes/endnotes + - links +- newlines detected and kept? + +#+name: ao_emitters_obj_inline_markup_munge +#+BEGIN_SRC d auto group(string obj_txt_in) in { } body { @@ -4023,6 +4072,19 @@ struct ObjInlineMarkupMunge { } invariant() { } +#+END_SRC + +****** block +- group block identified by open an close tags +- general markup + - paragraph attributes + - font faces (bold, italics, underscore etc.) + - footnotes/endnotes + - links +- newlines detected and kept? + +#+name: ao_emitters_obj_inline_markup_munge +#+BEGIN_SRC d auto block(Ot)(Ot obj_txt_in) in { debug(asserts){ @@ -4036,6 +4098,19 @@ struct ObjInlineMarkupMunge { } invariant() { } +#+END_SRC + +****** verse (poem) +- sub part of poem block which is identified by open an close tags, separated from other verse by double newline +- newlines +- indentation +- what part of general markup? + - font faces (bold, italics, underscore etc.) + - footnotes/endnotes + - links? + +#+name: ao_emitters_obj_inline_markup_munge +#+BEGIN_SRC d auto verse(Ot)(Ot obj_txt_in) in { debug(asserts){ @@ -4049,6 +4124,12 @@ struct ObjInlineMarkupMunge { } invariant() { } +#+END_SRC + +****** quote + +#+name: ao_emitters_obj_inline_markup_munge +#+BEGIN_SRC d string quote(Ot)(Ot obj_txt_in) in { debug(asserts){ @@ -4061,6 +4142,14 @@ struct ObjInlineMarkupMunge { } invariant() { } +#+END_SRC + +****** table +- table block identified by open an close tags +- table markup + +#+name: ao_emitters_obj_inline_markup_munge +#+BEGIN_SRC d string table(Ot)(Ot obj_txt_in) in { debug(asserts){ @@ -4073,6 +4162,12 @@ struct ObjInlineMarkupMunge { } invariant() { } +#+END_SRC + +****** comment + +#+name: ao_emitters_obj_inline_markup_munge +#+BEGIN_SRC d string comment(Ot)(Ot obj_txt_in) in { debug(asserts){ @@ -4085,6 +4180,12 @@ struct ObjInlineMarkupMunge { } invariant() { } +#+END_SRC + +****** 0. close + +#+name: ao_emitters_obj_inline_markup_munge +#+BEGIN_SRC d } #+END_SRC @@ -4200,12 +4301,9 @@ struct ObjInlineMarkup { 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)( @@ -4491,10 +4589,11 @@ private: 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 ~ " "); } } } @@ -4521,16 +4620,19 @@ private: 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) ~ " "); } } @@ -5094,7 +5196,7 @@ struct BookIndexReportSection { 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(" \\\\"); @@ -5104,7 +5206,7 @@ struct BookIndexReportSection { 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(" \\\\"); @@ -5239,8 +5341,8 @@ struct BookIndexReportSection { 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"; @@ -6106,7 +6208,7 @@ auto assertions_flag_types_block_status_none_or_closed(T)(T type) { } #+END_SRC -* 2. Object Setter :abstract:object: +* 2. Object Setter (Set Abstract Object) :abstract:object: set abstracted objects for downstream processing |