From 194c896c4a3780e9fece376507dcac3657237cd4 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Mon, 26 Feb 2018 15:42:10 -0500 Subject: playing with header/make substitutions --- org/meta_abstraction.org | 47 +++++++++++++++++++++++++++++++++++ org/meta_conf_make_meta.org | 35 ++++++++++++++++++-------- org/sdp.org | 2 +- src/sdp/meta/conf_make_meta_json.d | 2 +- src/sdp/meta/conf_make_meta_structs.d | 33 ++++++++++++++++-------- src/sdp/meta/metadoc_from_src.d | 42 +++++++++++++++++++++++++++++++ src/sdp/sdp.d | 2 +- 7 files changed, 139 insertions(+), 24 deletions(-) diff --git a/org/meta_abstraction.org b/org/meta_abstraction.org index aa79d9a..a1e5a95 100644 --- a/org/meta_abstraction.org +++ b/org/meta_abstraction.org @@ -88,6 +88,7 @@ template SiSUdocAbstraction() { <> <> <> + <> <> <> <> @@ -825,6 +826,7 @@ if there is a blurb section you need to: #+BEGIN_SRC d } else if (obj_type_status["quote"] == TriState.on) { /+ within block object: quote +/ + line = _doc_header_and_make_substitutions_(line, conf_make_meta); _quote_block_(line, an_object, obj_type_status); continue; #+END_SRC @@ -836,6 +838,7 @@ if there is a blurb section you need to: /+ within block object: group +/ } else if (obj_type_status["group"] == TriState.on) { /+ within block object: group +/ + line = _doc_header_and_make_substitutions_(line, conf_make_meta); line = (line) .replaceAll(rgx.para_delimiter, mkup.br_paragraph ~ "$1"); _group_block_(line, an_object, obj_type_status); @@ -848,6 +851,7 @@ if there is a blurb section you need to: #+BEGIN_SRC d } else if (obj_type_status["block"] == TriState.on) { /+ within block object: block +/ + line = _doc_header_and_make_substitutions_(line, conf_make_meta); if (auto m = line.match(rgx.spaces_line_start)) { line = (line) .replaceAll(rgx.spaces_line_start, (m.captures[1]).translate([ ' ' : mkup.nbsp ])); @@ -903,6 +907,7 @@ if (line.matchFirst(rgx.block_poem_open)) { processing.remove("verse"); obj_cite_number_poem["start"] = obj_cite_digits.on.to!string; } +line = _doc_header_and_make_substitutions_(line, conf_make_meta); _start_block_(line, obj_type_status, obj_cite_number_poem); continue; #+END_SRC @@ -1012,6 +1017,7 @@ if (line.matchFirst(rgx.book_index) } else if (line_occur["para"] == State.off) { /+ para match +/ an_object_key="body_nugget"; + line = _doc_header_and_make_substitutions_(line, conf_make_meta); _para_match_(line, an_object, an_object_key, indent, bullet, obj_type_status, line_occur); } #+END_SRC @@ -1038,6 +1044,7 @@ if (line.matchFirst(rgx.book_index) debug(para) { writeln(an_object_key, "-> ", line); } + line = _doc_header_and_make_substitutions_(line, conf_make_meta); an_object[an_object_key] ~= " " ~ line; ++line_occur["para"]; } @@ -2524,6 +2531,46 @@ static auto _check_ocn_status_(L,T)( } #+END_SRC +#+name: abs_functions_substitutions +#+BEGIN_SRC d +auto _doc_header_and_make_substitutions_(L,CMM)( + L line, + CMM conf_make_meta, +) { + debug(asserts) { + static assert(is(typeof(line) == char[])); + } + if (!( + conf_make_meta.make.bold_rgxmatch == "=NULL" + || conf_make_meta.make.bold_rgxmatch.empty + )) { + line = line.replaceAll( + regex(conf_make_meta.make.bold_rgxmatch), + conf_make_meta.make.bold_substitute_sisu_markup + ); + } + if (!( + conf_make_meta.make.emphasis_rgxmatch == "=NULL" + || conf_make_meta.make.emphasis_rgxmatch.empty + )) { + line = line.replaceAll( + regex(conf_make_meta.make.emphasis_rgxmatch), + conf_make_meta.make.emphasis_substitute_sisu_markup + ); + } + if (!( + conf_make_meta.make.italics_rgxmatch == "=NULL" + || conf_make_meta.make.italics_rgxmatch.empty + )) { + line = line.replaceAll( + regex(conf_make_meta.make.italics_rgxmatch), + conf_make_meta.make.italics_substitute_sisu_markup + ); + } + return line; +} +#+END_SRC + *** block :block: **** block start (open) block :start: ***** { block starts function diff --git a/org/meta_conf_make_meta.org b/org/meta_conf_make_meta.org index 91c9d11..aa67709 100644 --- a/org/meta_conf_make_meta.org +++ b/org/meta_conf_make_meta.org @@ -48,6 +48,7 @@ import sdp.meta.conf_make_meta_structs; module sdp.meta.conf_make_meta_structs; import std.exception, + std.json, std.regex, std.stdio, std.string, @@ -75,7 +76,7 @@ struct ConfCompositeMakeStr { string italics = ""; string num_top = ""; string num_depth = ""; - string substitute = ""; + JSONValue substitute = JSONValue( ["", ""] ); string texpdf_font = ""; } struct confCompositeMakeBuild { @@ -86,7 +87,10 @@ struct confCompositeMakeBuild { return (cast(char[]) (_rgxtxt)); } auto bold_substitute_abstract() { - return "$1"; + return "*{$1}*"; + } + auto bold_substitute_sisu_markup() { + return "*{$1}*"; } auto bold_substitute_html() { return "$1"; @@ -107,7 +111,10 @@ struct confCompositeMakeBuild { return (cast(char[]) (_rgxtxt)); } auto emphasis_substitute_abstract() { - return "$1"; + return "!{$1}!"; + } + auto emphasis_substitute_sisu_markup() { + return "!{$1}!"; } auto emphasis_substitute_html() { return "$1"; @@ -131,7 +138,10 @@ struct confCompositeMakeBuild { return (cast(char[]) (_rgxtxt)); } auto italics_substitute_abstract() { - return "$1"; + return "/{$1}/"; + } + auto italics_substitute_sisu_markup() { + return "/{$1}/"; } auto italics_substitute_html() { return "$1"; @@ -142,8 +152,8 @@ struct confCompositeMakeBuild { auto num_depth(string _mk) { return _mk; } - auto substitute(string _mk) { // TODO this is different from others - return regex(_mk); + auto substitute(JSONValue _mk) { + return _mk; } auto texpdf_font(string _mk) { return _mk; @@ -158,24 +168,27 @@ struct confCompositeMakeBuild { #+BEGIN_SRC d struct ConfCompositeMakeInit { char[] bold_rgxmatch = `=NULL`.dup; - auto bold_substitute_abstract = "$1"; + auto bold_substitute_abstract = "*{$1}*"; + auto bold_substitute_sisu_markup = "*{$1}*"; auto bold_substitute_html = "$1"; string breaks = ""; string cover_image = ""; string css = ""; char[] emphasis_rgxmatch = `=NULL`.dup; - auto emphasis_substitute_abstract = "$1"; + auto emphasis_substitute_abstract = "!{$1}!"; + auto emphasis_substitute_sisu_markup = "!{$1}!"; auto emphasis_substitute_html = "$1"; string footer = ""; string headings = ""; string home_button_image = ""; string home_button_text = ""; char[] italics_rgxmatch = `=NULL`.dup; - auto italics_substitute_abstract = "$1"; + auto italics_substitute_abstract = "/{$1}/"; + auto italics_substitute_sisu_markup = "/{$1}/"; auto italics_substitute_html = "$1"; string num_top = ""; string num_depth = ""; - auto substitute = regex(""); // TODO + auto substitute = JSONValue(["", ""]); string texpdf_font = ""; } #+END_SRC @@ -482,7 +495,7 @@ if ("make" in _json.object) { _struct_composite.make_str.num_depth = _json.object["num_depth"][""].str; } if ("substitute" in _json.object["make"]) { - _struct_composite.make_str.substitute = _json.object["make"]["substitute"].str; + _struct_composite.make_str.substitute = _json.object["make"]["substitute"].arrayNoRef; } if ("texpdf_font" in _json.object["make"]) { _struct_composite.make_str.texpdf_font = _json.object["make"]["texpdf_font"].str; diff --git a/org/sdp.org b/org/sdp.org index 6ed2639..4d6971e 100644 --- a/org/sdp.org +++ b/org/sdp.org @@ -604,7 +604,7 @@ enforce( #+NAME: sdp_each_file_do_abstraction #+BEGIN_SRC d debug(steps) { - writeln("stepX commence → (document abstraction)"); + writeln("--->\nstepX commence → (document abstraction)"); } auto t = SiSUabstraction!()(_env, _opt_action, manifest); static assert(!isTypeTuple!(t)); diff --git a/src/sdp/meta/conf_make_meta_json.d b/src/sdp/meta/conf_make_meta_json.d index 88e24da..0471dbf 100644 --- a/src/sdp/meta/conf_make_meta_json.d +++ b/src/sdp/meta/conf_make_meta_json.d @@ -75,7 +75,7 @@ static template contentJSONtoSiSUstruct() { _struct_composite.make_str.num_depth = _json.object["num_depth"][""].str; } if ("substitute" in _json.object["make"]) { - _struct_composite.make_str.substitute = _json.object["make"]["substitute"].str; + _struct_composite.make_str.substitute = _json.object["make"]["substitute"].arrayNoRef; } if ("texpdf_font" in _json.object["make"]) { _struct_composite.make_str.texpdf_font = _json.object["make"]["texpdf_font"].str; diff --git a/src/sdp/meta/conf_make_meta_structs.d b/src/sdp/meta/conf_make_meta_structs.d index 211d2c0..3253b45 100644 --- a/src/sdp/meta/conf_make_meta_structs.d +++ b/src/sdp/meta/conf_make_meta_structs.d @@ -1,6 +1,7 @@ module sdp.meta.conf_make_meta_structs; import std.exception, + std.json, std.regex, std.stdio, std.string, @@ -21,7 +22,7 @@ struct ConfCompositeMakeStr { string italics = ""; string num_top = ""; string num_depth = ""; - string substitute = ""; + JSONValue substitute = JSONValue( ["", ""] ); string texpdf_font = ""; } struct confCompositeMakeBuild { @@ -32,7 +33,10 @@ struct confCompositeMakeBuild { return (cast(char[]) (_rgxtxt)); } auto bold_substitute_abstract() { - return "$1"; + return "*{$1}*"; + } + auto bold_substitute_sisu_markup() { + return "*{$1}*"; } auto bold_substitute_html() { return "$1"; @@ -53,7 +57,10 @@ struct confCompositeMakeBuild { return (cast(char[]) (_rgxtxt)); } auto emphasis_substitute_abstract() { - return "$1"; + return "!{$1}!"; + } + auto emphasis_substitute_sisu_markup() { + return "!{$1}!"; } auto emphasis_substitute_html() { return "$1"; @@ -77,7 +84,10 @@ struct confCompositeMakeBuild { return (cast(char[]) (_rgxtxt)); } auto italics_substitute_abstract() { - return "$1"; + return "/{$1}/"; + } + auto italics_substitute_sisu_markup() { + return "/{$1}/"; } auto italics_substitute_html() { return "$1"; @@ -88,8 +98,8 @@ struct confCompositeMakeBuild { auto num_depth(string _mk) { return _mk; } - auto substitute(string _mk) { // TODO this is different from others - return regex(_mk); + auto substitute(JSONValue _mk) { + return _mk; } auto texpdf_font(string _mk) { return _mk; @@ -97,24 +107,27 @@ struct confCompositeMakeBuild { } struct ConfCompositeMakeInit { char[] bold_rgxmatch = `=NULL`.dup; - auto bold_substitute_abstract = "$1"; + auto bold_substitute_abstract = "*{$1}*"; + auto bold_substitute_sisu_markup = "*{$1}*"; auto bold_substitute_html = "$1"; string breaks = ""; string cover_image = ""; string css = ""; char[] emphasis_rgxmatch = `=NULL`.dup; - auto emphasis_substitute_abstract = "$1"; + auto emphasis_substitute_abstract = "!{$1}!"; + auto emphasis_substitute_sisu_markup = "!{$1}!"; auto emphasis_substitute_html = "$1"; string footer = ""; string headings = ""; string home_button_image = ""; string home_button_text = ""; char[] italics_rgxmatch = `=NULL`.dup; - auto italics_substitute_abstract = "$1"; + auto italics_substitute_abstract = "/{$1}/"; + auto italics_substitute_sisu_markup = "/{$1}/"; auto italics_substitute_html = "$1"; string num_top = ""; string num_depth = ""; - auto substitute = regex(""); // TODO + auto substitute = JSONValue(["", ""]); string texpdf_font = ""; } struct ConfCompositeSiteLocal { diff --git a/src/sdp/meta/metadoc_from_src.d b/src/sdp/meta/metadoc_from_src.d index d0ee599..97e5f78 100644 --- a/src/sdp/meta/metadoc_from_src.d +++ b/src/sdp/meta/metadoc_from_src.d @@ -602,17 +602,20 @@ template SiSUdocAbstraction() { continue; } else if (obj_type_status["quote"] == TriState.on) { /+ within block object: quote +/ + line = _doc_header_and_make_substitutions_(line, conf_make_meta); _quote_block_(line, an_object, obj_type_status); continue; /+ within block object: group +/ } else if (obj_type_status["group"] == TriState.on) { /+ within block object: group +/ + line = _doc_header_and_make_substitutions_(line, conf_make_meta); line = (line) .replaceAll(rgx.para_delimiter, mkup.br_paragraph ~ "$1"); _group_block_(line, an_object, obj_type_status); continue; } else if (obj_type_status["block"] == TriState.on) { /+ within block object: block +/ + line = _doc_header_and_make_substitutions_(line, conf_make_meta); if (auto m = line.match(rgx.spaces_line_start)) { line = (line) .replaceAll(rgx.spaces_line_start, (m.captures[1]).translate([ ' ' : mkup.nbsp ])); @@ -646,6 +649,7 @@ template SiSUdocAbstraction() { processing.remove("verse"); obj_cite_number_poem["start"] = obj_cite_digits.on.to!string; } + line = _doc_header_and_make_substitutions_(line, conf_make_meta); _start_block_(line, obj_type_status, obj_cite_number_poem); continue; } else if (!line.empty) { @@ -727,6 +731,7 @@ template SiSUdocAbstraction() { } else if (line_occur["para"] == State.off) { /+ para match +/ an_object_key="body_nugget"; + line = _doc_header_and_make_substitutions_(line, conf_make_meta); _para_match_(line, an_object, an_object_key, indent, bullet, obj_type_status, line_occur); } } else if (line_occur["heading"] > State.off) { @@ -741,6 +746,7 @@ template SiSUdocAbstraction() { debug(para) { writeln(an_object_key, "-> ", line); } + line = _doc_header_and_make_substitutions_(line, conf_make_meta); an_object[an_object_key] ~= " " ~ line; ++line_occur["para"]; } @@ -1918,6 +1924,42 @@ template SiSUdocAbstraction() { } return obj_type_status; } + auto _doc_header_and_make_substitutions_(L,CMM)( + L line, + CMM conf_make_meta, + ) { + debug(asserts) { + static assert(is(typeof(line) == char[])); + } + if (!( + conf_make_meta.make.bold_rgxmatch == "=NULL" + || conf_make_meta.make.bold_rgxmatch.empty + )) { + line = line.replaceAll( + regex(conf_make_meta.make.bold_rgxmatch), + conf_make_meta.make.bold_substitute_sisu_markup + ); + } + if (!( + conf_make_meta.make.emphasis_rgxmatch == "=NULL" + || conf_make_meta.make.emphasis_rgxmatch.empty + )) { + line = line.replaceAll( + regex(conf_make_meta.make.emphasis_rgxmatch), + conf_make_meta.make.emphasis_substitute_sisu_markup + ); + } + if (!( + conf_make_meta.make.italics_rgxmatch == "=NULL" + || conf_make_meta.make.italics_rgxmatch.empty + )) { + line = line.replaceAll( + regex(conf_make_meta.make.italics_rgxmatch), + conf_make_meta.make.italics_substitute_sisu_markup + ); + } + return line; + } void _start_block_(L,T,N)( L line, return ref T obj_type_status, diff --git a/src/sdp/sdp.d b/src/sdp/sdp.d index b54ea3c..2d0397d 100755 --- a/src/sdp/sdp.d +++ b/src/sdp/sdp.d @@ -376,7 +376,7 @@ void main(string[] args) { manifest.src.filename ~ "»" ); debug(steps) { - writeln("stepX commence → (document abstraction)"); + writeln("--->\nstepX commence → (document abstraction)"); } auto t = SiSUabstraction!()(_env, _opt_action, manifest); static assert(!isTypeTuple!(t)); -- cgit v1.2.3