diff options
author | Ralph Amissah <ralph@amissah.com> | 2018-03-01 12:51:58 -0500 |
---|---|---|
committer | Ralph Amissah <ralph@amissah.com> | 2019-04-10 15:14:14 -0400 |
commit | b243ba3e00bf6cd5e9298903bc69d8efc7a03414 (patch) | |
tree | db70f147c4aa744166bbb559ab238ccf316f8727 /org/meta_abstraction.org | |
parent | header make unmarked headings (diff) |
conf, make, meta, init and tidy substitution
Diffstat (limited to 'org/meta_abstraction.org')
-rw-r--r-- | org/meta_abstraction.org | 63 |
1 files changed, 31 insertions, 32 deletions
diff --git a/org/meta_abstraction.org b/org/meta_abstraction.org index 03da5cf..959de0c 100644 --- a/org/meta_abstraction.org +++ b/org/meta_abstraction.org @@ -538,6 +538,7 @@ int cnt1 = 1; int cnt2 = 1; int cnt3 = 1; #+name: make_tests #+BEGIN_SRC d +enum Substitute { match, markup, } debug (substitutions) { writeln(__LINE__, ":", __FILE__, ": DEBUG substitutions:"); if (!(conf_make_meta.make.headings.empty)) { @@ -545,21 +546,21 @@ debug (substitutions) { } if (conf_make_meta.make.substitute) { foreach(substitution_pair; conf_make_meta.make.substitute) { - writeln("regex to match: ", substitution_pair[0]); - writeln("substitution to make: ", substitution_pair[1]); + writeln("regex to match: ", substitution_pair[Substitute.match]); + writeln("substitution to make: ", substitution_pair[Substitute.markup]); } } - if (!(conf_make_meta.make.bold_rgxmatch == "=NULL" || conf_make_meta.make.bold_rgxmatch.empty)) { - writeln("regex to match: ", conf_make_meta.make.bold_rgxmatch); - writeln("substitution to make: ", conf_make_meta.make.bold_substitute_html); + if (conf_make_meta.make.bold) { + writeln("regex to match: ", conf_make_meta.make.bold[Substitute.match]); + writeln("substitution to make: ", conf_make_meta.make.bold[Substitute.markup]); } - if (!(conf_make_meta.make.emphasis_rgxmatch == "=NULL" || conf_make_meta.make.emphasis_rgxmatch.empty)) { - writeln("regex to match: ", conf_make_meta.make.emphasis_rgxmatch); - writeln("substitution to make: ", conf_make_meta.make.emphasis_substitute_html); + if (conf_make_meta.make.emphasis) { + writeln("regex to match: ", conf_make_meta.make.emphasis[Substitute.match]); + writeln("substitution to make: ", conf_make_meta.make.emphasis[Substitute.markup]); } - if (!(conf_make_meta.make.italics_rgxmatch == "=NULL" || conf_make_meta.make.italics_rgxmatch.empty)) { - writeln("regex to match: ", conf_make_meta.make.italics_rgxmatch); - writeln("substitution to make: ", conf_make_meta.make.italics_substitute_html); + if (conf_make_meta.make.italics) { + writeln("regex to match: ", conf_make_meta.make.italics[Substitute.match]); + writeln("substitution to make: ", conf_make_meta.make.italics[Substitute.markup]); } } #+END_SRC @@ -857,6 +858,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); line = _doc_header_and_make_substitutions_fontface_(line, conf_make_meta); _quote_block_(line, an_object, obj_type_status); continue; @@ -869,6 +871,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 = _doc_header_and_make_substitutions_fontface_(line, conf_make_meta); line = (line) .replaceAll(rgx.para_delimiter, mkup.br_paragraph ~ "$1"); @@ -882,6 +885,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); line = _doc_header_and_make_substitutions_fontface_(line, conf_make_meta); if (auto m = line.match(rgx.spaces_line_start)) { line = (line) @@ -938,7 +942,6 @@ 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_fontface_(line, conf_make_meta); _start_block_(line, obj_type_status, obj_cite_number_poem); continue; #+END_SRC @@ -1044,10 +1047,12 @@ if (line.matchFirst(rgx.book_index) +/ if (line.matchFirst(rgx.heading)) { /+ heading match +/ + line = _doc_header_and_make_substitutions_(line, conf_make_meta); _heading_matched_(line, line_occur, an_object, an_object_key, lv, collapsed_lev, obj_type_status, conf_make_meta); } else if (line_occur["para"] == State.off) { /+ para match +/ an_object_key="body_nugget"; + line = _doc_header_and_make_substitutions_(line, conf_make_meta); line = _doc_header_and_make_substitutions_fontface_(line, conf_make_meta); _para_match_(line, an_object, an_object_key, indent, bullet, obj_type_status, line_occur); } @@ -1075,6 +1080,7 @@ if (line.matchFirst(rgx.book_index) debug(para) { writeln(an_object_key, "-> ", line); } + line = _doc_header_and_make_substitutions_(line, conf_make_meta); line = _doc_header_and_make_substitutions_fontface_(line, conf_make_meta); an_object[an_object_key] ~= " " ~ line; ++line_occur["para"]; @@ -2574,11 +2580,12 @@ auto _doc_header_and_make_substitutions_(L,CMM)( debug(asserts) { static assert(is(typeof(line) == char[])); } + enum Substitute { match, markup, } if (conf_make_meta.make.substitute) { foreach(substitution_pair; conf_make_meta.make.substitute) { line = line.replaceAll( - regex(substitution_pair[0]), - substitution_pair[1] + regex(substitution_pair[Substitute.match]), + substitution_pair[Substitute.markup] ); } } @@ -2597,31 +2604,23 @@ auto _doc_header_and_make_substitutions_fontface_(L,CMM)( debug(asserts) { static assert(is(typeof(line) == char[])); } - if (!( - conf_make_meta.make.bold_rgxmatch == "=NULL" - || conf_make_meta.make.bold_rgxmatch.empty - )) { + enum Substitute { match, markup, } + if ( conf_make_meta.make.bold) { line = line.replaceAll( - regex(conf_make_meta.make.bold_rgxmatch), - conf_make_meta.make.bold_substitute_sisu_markup + regex(conf_make_meta.make.bold[Substitute.match]), + conf_make_meta.make.bold[Substitute.markup] ); } - if (!( - conf_make_meta.make.emphasis_rgxmatch == "=NULL" - || conf_make_meta.make.emphasis_rgxmatch.empty - )) { + if (conf_make_meta.make.emphasis) { line = line.replaceAll( - regex(conf_make_meta.make.emphasis_rgxmatch), - conf_make_meta.make.emphasis_substitute_sisu_markup + regex(conf_make_meta.make.emphasis[Substitute.match]), + conf_make_meta.make.emphasis[Substitute.markup] ); } - if (!( - conf_make_meta.make.italics_rgxmatch == "=NULL" - || conf_make_meta.make.italics_rgxmatch.empty - )) { + if (conf_make_meta.make.italics) { line = line.replaceAll( - regex(conf_make_meta.make.italics_rgxmatch), - conf_make_meta.make.italics_substitute_sisu_markup + regex(conf_make_meta.make.italics[Substitute.match]), + conf_make_meta.make.italics[Substitute.markup] ); } return line; |