diff options
Diffstat (limited to 'src/sdp/ao_abstract_doc_source.d')
-rw-r--r-- | src/sdp/ao_abstract_doc_source.d | 121 |
1 files changed, 106 insertions, 15 deletions
diff --git a/src/sdp/ao_abstract_doc_source.d b/src/sdp/ao_abstract_doc_source.d index aca4944..8c19bf3 100644 --- a/src/sdp/ao_abstract_doc_source.d +++ b/src/sdp/ao_abstract_doc_source.d @@ -120,8 +120,11 @@ template SiSUdocAbstraction() { // mixin SiSUdocAbstractionFunctions; /+ ↓ abstract marked up document +/ - auto abstract_doc_source(char[][] markup_sourcefile_content) { - + auto abstract_doc_source( + char[][] markup_sourcefile_content, + JSONValue[string] dochead_make_json, + JSONValue[string] dochead_meta_json + ) { /+ ↓ abstraction init +/ scope(success) { } @@ -338,24 +341,24 @@ template SiSUdocAbstraction() { && ((type["para"] == State.off) && (type["heading"] == State.off))) { /+ heading or para but neither flag nor line exists +/ - // if ((to!string(dochead_make_json["make"]["headings"]).length > 2) - // && (type["make_headings"] == State.off)) { - // /+ heading found +/ - // auto dochead_make_headings = - // to!string(dochead_make_json["make"]["headings"]); - // heading_found(line, dochead_make_headings, heading_match_str, heading_match_rgx, type); - // } + if ((to!string(dochead_make_json["make"]["headings"]).length > 2) + && (type["make_headings"] == State.off)) { + /+ heading found +/ + auto dochead_make_headings = + to!string(dochead_make_json["make"]["headings"]); + heading_found(line, dochead_make_headings, heading_match_str, heading_match_rgx, type); + } if ((type["make_headings"] == State.on) && ((line_occur["para"] == State.off) && (line_occur["heading"] == State.off)) && ((type["para"] == State.off) && (type["heading"] == State.off))) { /+ heading make set +/ - // heading_make_set(line, line_occur, heading_match_rgx, type); + heading_make_set(line, line_occur, heading_match_rgx, type); } if (matchFirst(line, rgx.heading)) { /+ heading match +/ - heading_matched(line, line_occur, an_object, lv, collapsed_lev, type); + heading_matched(line, line_occur, an_object, lv, collapsed_lev, type, dochead_meta_json); } else if (line_occur["para"] == State.off) { /+ para match +/ para_match(line, an_object, indent, bullet, type, line_occur); @@ -1614,6 +1617,94 @@ template SiSUdocAbstraction() { } } } + auto heading_found( + char[] line, + string dochead_make_headings, + ref string[string] heading_match_str, + ref Regex!(char)[string] heading_match_rgx, + ref int[string] type + ) { + if ((to!string(dochead_make_headings).length > 2) + && (type["make_headings"] == State.off)) { + /+ headings found +/ + debug(headingsfound) { + writeln(dochead_make_headings); + } + auto make_headings_txt = + match( + to!string(dochead_make_headings), + rgx.within_quotes); + char[][] make_headings_spl = + split( + cast(char[]) make_headings_txt.captures[1], + rgx.make_heading_delimiter); + debug(headingsfound) { + writeln(make_headings_spl.length); + writeln(make_headings_spl); + } + switch (make_headings_spl.length) { + case 7 : + if (!empty(make_headings_spl[6])) { + heading_match_str["h_4"] = + "^(" ~ to!string(make_headings_spl[6]) ~ ")"; + heading_match_rgx["h_4"] = + regex(heading_match_str["h_4"]); + } + goto case; + case 6 : + if (!empty(make_headings_spl[5])) { + heading_match_str["h_3"] = + "^(" ~ to!string(make_headings_spl[5]) ~ ")"; + heading_match_rgx["h_3"] = + regex(heading_match_str["h_3"]); + } + goto case; + case 5 : + if (!empty(make_headings_spl[4])) { + heading_match_str["h_2"] = + "^(" ~ to!string(make_headings_spl[4]) ~ ")"; + heading_match_rgx["h_2"] = + regex(heading_match_str["h_2"]); + } + goto case; + case 4 : + if (!empty(make_headings_spl[3])) { + heading_match_str["h_1"] = + "^(" ~ to!string(make_headings_spl[3]) ~ ")"; + heading_match_rgx["h_1"] = + regex(heading_match_str["h_1"]); + } + goto case; + case 3 : + if (!empty(make_headings_spl[2])) { + heading_match_str["h_D"] = + "^(" ~ to!string(make_headings_spl[2]) ~ ")"; + heading_match_rgx["h_D"] = + regex(heading_match_str["h_D"]); + } + goto case; + case 2 : + if (!empty(make_headings_spl[1])) { + heading_match_str["h_C"] = + "^(" ~ to!string(make_headings_spl[1]) ~ ")"; + heading_match_rgx["h_C"] = + regex(heading_match_str["h_C"]); + } + goto case; + case 1 : + if (!empty(make_headings_spl[0])) { + heading_match_str["h_B"] = + "^(" ~ to!string(make_headings_spl[0]) ~ ")"; + heading_match_rgx["h_B"] = + regex(heading_match_str["h_B"]); + } + break; + default: + break; + } + type["make_headings"] = State.on; + } + } auto heading_make_set( ref char[] line, ref int[string] line_occur, @@ -1676,8 +1767,8 @@ template SiSUdocAbstraction() { ref string[string] an_object, ref int[string] lv, ref int[string] collapsed_lev, - ref int[string] type - // ref JSONValue[string] dochead_meta_json + ref int[string] type, + ref JSONValue[string] dochead_meta_json ) { if (auto m = match(line, rgx.heading)) { /+ heading match +/ @@ -1691,8 +1782,8 @@ template SiSUdocAbstraction() { assertions_doc_structure(an_object, lv); // includes most of the logic for collapsed levels switch (an_object["lev"]) { case "A": - // an_object["obj"]=replaceFirst(an_object["obj"], rgx.variable_doc_title, to!string(dochead_meta_json["title"]["main"])); - // an_object["obj"]=replaceFirst(an_object["obj"], rgx.variable_doc_author, to!string(dochead_meta_json["creator"]["author"])); + an_object["obj"]=replaceFirst(an_object["obj"], rgx.variable_doc_title, to!string(dochead_meta_json["title"]["main"])); + an_object["obj"]=replaceFirst(an_object["obj"], rgx.variable_doc_author, to!string(dochead_meta_json["creator"]["author"])); collapsed_lev["h0"] = 1; an_object["lev_collapsed_number"] = to!string(collapsed_lev["h0"]); |