diff options
author | Ralph Amissah <ralph@amissah.com> | 2017-02-28 15:26:52 -0500 |
---|---|---|
committer | Ralph Amissah <ralph@amissah.com> | 2019-04-10 15:14:14 -0400 |
commit | d28ce48b155a11bf4f313982139f4697120e2df1 (patch) | |
tree | 5baad6cabd4787c06b539848d952f4883c174bff /src/sdp/ao_abstract_doc_source.d | |
parent | 0.13.5 defaults regex reorganised; some work on (x)html output (diff) |
work on outputs
Diffstat (limited to 'src/sdp/ao_abstract_doc_source.d')
-rw-r--r-- | src/sdp/ao_abstract_doc_source.d | 245 |
1 files changed, 138 insertions, 107 deletions
diff --git a/src/sdp/ao_abstract_doc_source.d b/src/sdp/ao_abstract_doc_source.d index 6690a9f..066ef3a 100644 --- a/src/sdp/ao_abstract_doc_source.d +++ b/src/sdp/ao_abstract_doc_source.d @@ -3015,6 +3015,7 @@ template SiSUdocAbstraction() { } auto rgx = Rgx(); if (line_occur["para"] == State.off) { + line = font_faces_line(line); /+ para matches +/ type["para"] = State.on; an_object[an_object_key] ~= line; // body_nugget @@ -3055,6 +3056,19 @@ template SiSUdocAbstraction() { ++line_occur["para"]; } } + auto font_faces_line(T)( + return ref T textline, + ) { + auto rgx = Rgx(); + if (match(textline, rgx.inline_faces_line)) { + textline = (textline) + .replaceFirst(rgx.inline_emphasis_line, ("*{$1}*$2")) + .replaceFirst(rgx.inline_bold_line, ("!{$1}!$2")) + .replaceFirst(rgx.inline_underscore_line, ("_{$1}_$2")) + .replaceFirst(rgx.inline_italics_line, ("/{$1}/$2")); + } + return textline; + } /+ abstraction functions ↑ +/ /+ ↓ abstraction function emitters +/ struct OCNemitter { @@ -3304,7 +3318,8 @@ template SiSUdocAbstraction() { } } body { - obj_txt["munge"]=obj_txt_in; + obj_txt_in = (obj_txt_in).replaceAll(rgx.two_spaces, mkup.nbsp ~ mkup.nbsp); + obj_txt["munge"] = obj_txt_in; return obj_txt["munge"]; } invariant() { @@ -3503,7 +3518,7 @@ template SiSUdocAbstraction() { ObjGenericComposite comp_obj_toc; mixin InternalMarkup; auto mkup = InlineMarkup(); - char[] heading_toc_ = to!(char[])(obj_["body_nugget"].dup.strip); + char[] heading_toc_ = (obj_["substantive"].dup.strip.to!(char[])).replaceAll(rgx.inline_notes_al, ""); heading_toc_ = _clean_heading_toc_(heading_toc_); auto attrib=""; string toc_txt_, subtoc_txt_; @@ -3621,7 +3636,8 @@ template SiSUdocAbstraction() { heading_toc_, _anchor_tag, ); - lev4_subtoc[segment_anchor_tag_that_object_belongs_to] ~= obj_["lev_markup_number"] ~ "~ " ~ to!string(subtoc_txt_).strip; + lev4_subtoc[segment_anchor_tag_that_object_belongs_to] + ~= obj_["lev_markup_number"] ~ "~ " ~ to!string(subtoc_txt_).strip; toc_txt_= munge.url_links(toc_txt_); indent=[ "hang_position" : to!int(obj_["lev_markup_number"]), @@ -3652,113 +3668,128 @@ template SiSUdocAbstraction() { static assert(is(typeof(dochead_make_aa) == string[string][string])); } if (dochead_make_aa["make"]["num_top"].length > 0) { - if (!(match(munge_, rgx.heading_anchor_tag))) { - static __gshared int heading_num_top_level=9; - static __gshared int heading_num_depth=2; - static __gshared int heading_num_0 = 0; - static __gshared int heading_num_1 = 0; - static __gshared int heading_num_2 = 0; - static __gshared int heading_num_3 = 0; - static __gshared string heading_number_auto_composite = ""; - if (heading_num_top_level==9) { - if (dochead_make_aa["make"]["num_depth"].length > 0) { - heading_num_depth = to!uint(dochead_make_aa["make"]["num_depth"]); - } - switch (dochead_make_aa["make"]["num_top"]) { - case "A": - break; - case "B": - heading_num_top_level=1; - break; - case "C": - heading_num_top_level=2; - break; - case "D": - heading_num_top_level=3; - break; - case "1": - heading_num_top_level=4; - break; - case "2": - heading_num_top_level=5; - break; - case "3": - heading_num_top_level=6; - break; - case "4": - heading_num_top_level=7; - break; - default: - break; - } - } - /+ num_depth minimum 0 (1.) default 2 (1.1.1) max 3 (1.1.1.1) implement +/ - if (heading_num_top_level > to!uint(obj_["lev_markup_number"])) { - heading_num_0 = 0; - heading_num_1 = 0; - heading_num_2 = 0; - heading_num_3 = 0; - } else if (heading_num_top_level == to!uint(obj_["lev_markup_number"])) { - heading_num_0 ++; - heading_num_1 = 0; - heading_num_2 = 0; - heading_num_3 = 0; - } else if (heading_num_top_level == (to!uint(obj_["lev_markup_number"]) - 1)) { - heading_num_1 ++; - heading_num_2 = 0; - heading_num_3 = 0; - } else if (heading_num_top_level == (to!uint(obj_["lev_markup_number"]) - 2)) { - heading_num_2 ++; - heading_num_3 = 0; - } else if (heading_num_top_level == (to!uint(obj_["lev_markup_number"]) - 3)) { - heading_num_3 ++; - } - if (heading_num_3 > 0) { - heading_number_auto_composite = - (heading_num_depth == 3) - ? ( to!string(heading_num_0) ~ "." ~ - to!string(heading_num_1) ~ "." ~ - to!string(heading_num_2) ~ "." ~ - to!string(heading_num_3) - ) - : ""; - } else if (heading_num_2 > 0) { - heading_number_auto_composite = - ((heading_num_depth >= 2) - && (heading_num_depth <= 3)) - ? ( to!string(heading_num_0) ~ "." ~ - to!string(heading_num_1) ~ "." ~ - to!string(heading_num_2) - ) - : ""; - } else if (heading_num_1 > 0) { - heading_number_auto_composite = - ((heading_num_depth >= 1) - && (heading_num_depth <= 3)) - ? ( to!string(heading_num_0) ~ "." ~ - to!string(heading_num_1) - ) - : ""; - } else if (heading_num_0 > 0) { - heading_number_auto_composite = - ((heading_num_depth >= 0) - && (heading_num_depth <= 3)) - ? (to!string(heading_num_0)) - : ""; - } else { - heading_number_auto_composite = ""; - } - debug(heading_number_auto) { - writeln(heading_number_auto_composite); + // if (!(match(munge_, rgx.heading_anchor_tag))) { + static __gshared int heading_num_top_level=9; + static __gshared int heading_num_depth=2; + static __gshared int heading_num_0 = 0; + static __gshared int heading_num_1 = 0; + static __gshared int heading_num_2 = 0; + static __gshared int heading_num_3 = 0; + static __gshared string heading_number_auto_composite = ""; + if (heading_num_top_level==9) { + if (dochead_make_aa["make"]["num_depth"].length > 0) { + heading_num_depth = to!uint(dochead_make_aa["make"]["num_depth"]); } - if (!empty(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 ~ " "); + switch (dochead_make_aa["make"]["num_top"]) { + case "A": + break; + case "B": + heading_num_top_level=1; + break; + case "C": + heading_num_top_level=2; + break; + case "D": + heading_num_top_level=3; + break; + case "1": + heading_num_top_level=4; + break; + case "2": + heading_num_top_level=5; + break; + case "3": + heading_num_top_level=6; + break; + case "4": + heading_num_top_level=7; + break; + default: + break; } } + /+ num_depth minimum 0 (1.) default 2 (1.1.1) max 3 (1.1.1.1) implement +/ + if ( + heading_num_top_level + > to!uint(obj_["lev_markup_number"]) + ) { + heading_num_0 = 0; + heading_num_1 = 0; + heading_num_2 = 0; + heading_num_3 = 0; + } else if ( + heading_num_top_level + == to!uint(obj_["lev_markup_number"]) + ) { + heading_num_0 ++; + heading_num_1 = 0; + heading_num_2 = 0; + heading_num_3 = 0; + } else if ( + heading_num_top_level + == (to!uint(obj_["lev_markup_number"]) - 1) + ) { + heading_num_1 ++; + heading_num_2 = 0; + heading_num_3 = 0; + } else if ( + heading_num_top_level + == (to!uint(obj_["lev_markup_number"]) - 2) + ) { + heading_num_2 ++; + heading_num_3 = 0; + } else if ( + heading_num_top_level + == (to!uint(obj_["lev_markup_number"]) - 3) + ) { + heading_num_3 ++; + } + if (heading_num_3 > 0) { + heading_number_auto_composite = + (heading_num_depth == 3) + ? ( to!string(heading_num_0) ~ "." + ~ to!string(heading_num_1) ~ "." + ~ to!string(heading_num_2) ~ "." + ~ to!string(heading_num_3) + ) + : ""; + } else if (heading_num_2 > 0) { + heading_number_auto_composite = + ((heading_num_depth >= 2) + && (heading_num_depth <= 3)) + ? ( to!string(heading_num_0) ~ "." + ~ to!string(heading_num_1) ~ "." + ~ to!string(heading_num_2) + ) + : ""; + } else if (heading_num_1 > 0) { + heading_number_auto_composite = + ((heading_num_depth >= 1) + && (heading_num_depth <= 3)) + ? ( to!string(heading_num_0) ~ "." + ~ to!string(heading_num_1) + ) + : ""; + } else if (heading_num_0 > 0) { + heading_number_auto_composite = + ((heading_num_depth >= 0) + && (heading_num_depth <= 3)) + ? (to!string(heading_num_0)) + : ""; + } else { + heading_number_auto_composite = ""; + } + debug(heading_number_auto) { + writeln(heading_number_auto_composite); + } + if (!(match(munge_, rgx.heading_anchor_tag)) + && !empty(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 ~ " "); + } } return munge_; } |