From d28ce48b155a11bf4f313982139f4697120e2df1 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Tue, 28 Feb 2017 15:26:52 -0500 Subject: work on outputs --- org/ao_doc_abstraction.org | 251 ++++++++++++++++++++++++++------------------- 1 file changed, 144 insertions(+), 107 deletions(-) (limited to 'org/ao_doc_abstraction.org') diff --git a/org/ao_doc_abstraction.org b/org/ao_doc_abstraction.org index fce5c90..0074e1c 100644 --- a/org/ao_doc_abstraction.org +++ b/org/ao_doc_abstraction.org @@ -3695,6 +3695,7 @@ void _para_match_(L,O,K,I,B,T,C)( } 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 @@ -3737,6 +3738,25 @@ void _para_match_(L,O,K,I,B,T,C)( } #+END_SRC +**** TODO text font face + +#+name: abs_functions_para +#+BEGIN_SRC d +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; +} +#+END_SRC + *** function emitters :emitters: **** object :object: ***** ocn :ocn: @@ -4045,7 +4065,8 @@ struct ObjInlineMarkupMunge { } } 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() { @@ -4328,7 +4349,7 @@ struct ObjInlineMarkup { 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_; @@ -4446,7 +4467,8 @@ struct ObjInlineMarkup { 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"]), @@ -4489,113 +4511,128 @@ private: 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 (!(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 (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 (!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_; } -- cgit v1.2.3