diff options
author | Ralph Amissah <ralph@amissah.com> | 2018-02-28 17:18:16 -0500 |
---|---|---|
committer | Ralph Amissah <ralph@amissah.com> | 2019-04-10 15:14:14 -0400 |
commit | c3a2508f2acfdffbde46e237071c9775ce2ff519 (patch) | |
tree | b79a5f8aa92b2d642a017ff4091e7ba343773bb2 /src/sdp/meta/metadoc_from_src.d | |
parent | (header, doc make, config) add checks to toml (diff) |
header make unmarked headings
Diffstat (limited to 'src/sdp/meta/metadoc_from_src.d')
-rw-r--r-- | src/sdp/meta/metadoc_from_src.d | 69 |
1 files changed, 39 insertions, 30 deletions
diff --git a/src/sdp/meta/metadoc_from_src.d b/src/sdp/meta/metadoc_from_src.d index 816f479..54bedfe 100644 --- a/src/sdp/meta/metadoc_from_src.d +++ b/src/sdp/meta/metadoc_from_src.d @@ -360,6 +360,9 @@ template SiSUdocAbstraction() { /+ abstraction init ↑ +/ debug (substitutions) { writeln(__LINE__, ":", __FILE__, ": DEBUG substitutions:"); + if (!(conf_make_meta.make.headings.empty)) { + writeln(conf_make_meta.make.headings); + } if (conf_make_meta.make.substitute) { foreach(substitution_pair; conf_make_meta.make.substitute) { writeln("regex to match: ", substitution_pair[0]); @@ -623,20 +626,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); + line = _doc_header_and_make_substitutions_fontface_(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 = _doc_header_and_make_substitutions_fontface_(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); + line = _doc_header_and_make_substitutions_fontface_(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 ])); @@ -670,7 +673,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); + line = _doc_header_and_make_substitutions_fontface_(line, conf_make_meta); _start_block_(line, obj_type_status, obj_cite_number_poem); continue; } else if (!line.empty) { @@ -752,7 +755,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); + 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); } } else if (line_occur["heading"] > State.off) { @@ -767,7 +770,7 @@ template SiSUdocAbstraction() { 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"]; } @@ -1960,6 +1963,15 @@ template SiSUdocAbstraction() { ); } } + return line; + } + auto _doc_header_and_make_substitutions_fontface_(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 @@ -3139,85 +3151,82 @@ template SiSUdocAbstraction() { } auto _heading_found_(L,X,H,R,T)( L line, - X dochead_make_identify_unmarked_headings, + X _make_unmarked_headings, return ref H heading_match_str, return ref R heading_match_rgx, return ref T obj_type_status ) { debug(asserts) { static assert(is(typeof(line) == char[])); - static assert(is(typeof(dochead_make_identify_unmarked_headings) == string)); + static assert(is(typeof(_make_unmarked_headings) == string[])); static assert(is(typeof(heading_match_str) == string[string])); static assert(is(typeof(heading_match_rgx) == Regex!(char)[string])); static assert(is(typeof(obj_type_status) == int[string])); } static auto rgx = Rgx(); - if ((dochead_make_identify_unmarked_headings.length > 2) + if ((_make_unmarked_headings.length > 2) && (obj_type_status["make_headings"] == State.off)) { /+ headings found +/ debug(headingsfound) { - writeln(dochead_make_identify_unmarked_headings); + writeln(_make_unmarked_headings); } - char[][] make_headings_spl - = (cast(char[]) dochead_make_identify_unmarked_headings) - .split(rgx.make_heading_delimiter); debug(headingsfound) { - writeln(make_headings_spl.length); - writeln(make_headings_spl); + writeln(_make_unmarked_headings.length); + writeln(_make_unmarked_headings); } - switch (make_headings_spl.length) { + switch (_make_unmarked_headings.length) { case 7 : - if (!empty(make_headings_spl[6])) { + if (!empty(_make_unmarked_headings[6])) { heading_match_str["h_4"] - = "^(" ~ make_headings_spl[6].to!string ~ ")"; + = "^(" ~ _make_unmarked_headings[6].to!string ~ ")"; heading_match_rgx["h_4"] = regex(heading_match_str["h_4"]); } goto case; case 6 : - if (!empty(make_headings_spl[5])) { + if (!empty(_make_unmarked_headings[5])) { heading_match_str["h_3"] - = "^(" ~ make_headings_spl[5].to!string ~ ")"; + = "^(" ~ _make_unmarked_headings[5].to!string ~ ")"; heading_match_rgx["h_3"] = regex(heading_match_str["h_3"]); } goto case; case 5 : - if (!empty(make_headings_spl[4])) { + if (!empty(_make_unmarked_headings[4])) { heading_match_str["h_2"] - = "^(" ~ make_headings_spl[4].to!string ~ ")"; + = "^(" ~ _make_unmarked_headings[4].to!string ~ ")"; heading_match_rgx["h_2"] = regex(heading_match_str["h_2"]); } goto case; case 4 : - if (!empty(make_headings_spl[3])) { + if (!empty(_make_unmarked_headings[3])) { heading_match_str["h_1"] - = "^(" ~ make_headings_spl[3].to!string ~ ")"; + = "^(" ~ _make_unmarked_headings[3].to!string ~ ")"; heading_match_rgx["h_1"] = regex(heading_match_str["h_1"]); } goto case; case 3 : - if (!empty(make_headings_spl[2])) { + if (!empty(_make_unmarked_headings[2])) { heading_match_str["h_D"] - = "^(" ~ make_headings_spl[2].to!string ~ ")"; + = "^(" ~ _make_unmarked_headings[2].to!string ~ ")"; heading_match_rgx["h_D"] = regex(heading_match_str["h_D"]); } goto case; case 2 : - if (!empty(make_headings_spl[1])) { + if (!empty(_make_unmarked_headings[1])) { heading_match_str["h_C"] - = "^(" ~ make_headings_spl[1].to!string ~ ")"; + = "^(" ~ _make_unmarked_headings[1].to!string ~ ")"; heading_match_rgx["h_C"] = regex(heading_match_str["h_C"]); } goto case; case 1 : - if (!empty(make_headings_spl[0])) { + if (!empty(_make_unmarked_headings[0])) { heading_match_str["h_B"] - = "^(" ~ make_headings_spl[0].to!string ~ ")"; + = "^(" ~ _make_unmarked_headings[0].to!string ~ ")"; heading_match_rgx["h_B"] = regex(heading_match_str["h_B"]); } |