diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/doc_reform/meta/metadoc_from_src.d | 180 |
1 files changed, 83 insertions, 97 deletions
diff --git a/src/doc_reform/meta/metadoc_from_src.d b/src/doc_reform/meta/metadoc_from_src.d index d976b60..9817fac 100644 --- a/src/doc_reform/meta/metadoc_from_src.d +++ b/src/doc_reform/meta/metadoc_from_src.d @@ -21,17 +21,13 @@ template docAbstraction() { mixin ObjectSetter; mixin InternalMarkup; mixin spineRgxIn; + /+ ↓ abstraction struct init +/ @safe static auto eN() { struct _e { enum bi { off, on, } - enum tri { - off, - on, - closing, - } enum ocn { off, on, @@ -78,7 +74,6 @@ template docAbstraction() { } return _e(); } - /+ ↓ abstraction struct init +/ /+ initialize +/ ObjGenericComposite[] the_table_of_contents_section; ObjGenericComposite[] the_document_head_section, the_document_body_section, the_bibliography_section, the_glossary_section, the_blurb_section; @@ -431,18 +426,18 @@ template docAbstraction() { "quote" : 0, "images" : 0, ]; - auto obj_type_status = flags_type_init; - int[string] pith = [ - "ocn" : 1, - "section" : 0, - "txt_is" : 0, - "block_is" : 0, - "block_state" : 0, - "block_delim" : 0, - "obj" : 0, - "dummy_heading_status" : 0, - "no_ocn_multiple_objects" : 0, - "heading_multiple_objects" : 0, + uint[string] pith = [ + "ocn" : 1, + "section" : 0, + "txt_is" : 0, + "block_is" : 0, + "block_state" : 0, + "block_delim" : 0, + "make_headings" : 0, + "dummy_heading_status" : 0, + "dummy_heading_multiple_objects" : 0, + "no_ocn_multiple_objects" : 0, + "verse_new" : 0, ]; string[string] object_number_poem = [ "start" : "", @@ -877,10 +872,10 @@ template docAbstraction() { an_object = line.flow_txt_block_block(an_object, pith); continue; } else if (pith["block_is"] == eN.blk_is.poem) { - an_object = line.flow_txt_block_poem(an_object, obj_type_status, pith, cntr, object_number_poem, conf_make_meta, tag_in_seg); + an_object = line.flow_txt_block_poem(an_object, pith, cntr, object_number_poem, conf_make_meta, tag_in_seg); continue; } else if (pith["block_is"] == eN.blk_is.table) { - an_object = line.flow_txt_block_table(an_object, obj_type_status, pith, conf_make_meta); + an_object = line.flow_txt_block_table(an_object, pith, conf_make_meta); continue; } } else { /+ not within a block group +/ @@ -895,7 +890,7 @@ template docAbstraction() { processing.remove("verse"); object_number_poem["start"] = obj_cite_digits.object_number.to!string; } - line.flow_txt_block_start(obj_type_status, pith, dochas, object_number_poem); + line.flow_txt_block_start(pith, dochas, object_number_poem); continue; } else if (!line.empty) { /+ line not empty +/ /+ non blocks (headings, paragraphs) & closed blocks +/ @@ -905,7 +900,7 @@ template docAbstraction() { ); assert( (pith["block_state"] == eN.blk_state.off) - || (pith["block_state"] == eN.tri.closing), + || (pith["block_state"] == eN.blk_state.closing), "code block status: none or closed" ); if (pith["block_state"] == eN.blk_state.closing) { @@ -947,15 +942,15 @@ template docAbstraction() { && pith["txt_is"] == eN.txt_is.off ) { /+ heading or para but neither flag nor line exists +/ if ((conf_make_meta.make.headings.length > 2) - && (obj_type_status["make_headings"] == eN.bi.off)) { /+ heading found +/ - heading_match_str = line.flow_heading_found_(heading_match_str, conf_make_meta.make.headings, heading_match_rgx, obj_type_status, pith); + && (pith["make_headings"] == eN.bi.off)) { /+ heading found +/ + heading_match_str = line.flow_heading_found_(heading_match_str, conf_make_meta.make.headings, heading_match_rgx, pith); } - if (obj_type_status["make_headings"] == eN.bi.on + if (pith["make_headings"] == eN.bi.on && (line_occur["para"] == eN.bi.off && line_occur["heading"] == eN.bi.off) && pith["txt_is"] == eN.txt_is.off ) { /+ heading make set +/ - line = line.flow_heading_make_set_(line_occur, heading_match_rgx, obj_type_status, pith); + line = line.flow_heading_make_set_(line_occur, heading_match_rgx, pith); } /+ TODO node info: all headings identified at this point, - extract node info here?? @@ -971,7 +966,6 @@ template docAbstraction() { an_object_key, lv, collapsed_lev, - obj_type_status, pith, conf_make_meta, ); @@ -999,7 +993,7 @@ template docAbstraction() { ++line_occur["para"]; } } - } else if (pith["block_state"] == eN.tri.closing) { /+ line empty, with blocks flag +/ + } else if (pith["block_state"] == eN.blk_state.closing) { /+ line empty, with blocks flag +/ an_object = line.flow_block_flag_line_empty_( an_object, bookindex_extract_hash, @@ -2499,40 +2493,40 @@ template docAbstraction() { @system void flow_common_reset_()( return ref int[string] line_occur, return ref string[string] an_object, - return ref int[string] pith, + return ref uint[string] pith, ) { line_occur["heading"] = eN.bi.off; line_occur["para"] = eN.bi.off; pith["txt_is"] = eN.txt_is.off; an_object = an_object.object_reset; } - @safe static int[string] _check_ocn_status_()( + @safe static uint[string] _check_ocn_status_()( char[] line, - int[string] pith, + uint[string] pith, ) { static auto rgx = RgxI(); if (!(line.empty)) { - if (pith["no_ocn_multiple_objects"] == eN.ocn.off) { + if (pith["no_ocn_multiple_objects"] == eN.bi.off) { /+ not multi-line object, check whether object_number is on or turned off +/ if (line.matchFirst(rgx.object_number_block_marks)) { /+ switch off object_number +/ if (line.matchFirst(rgx.object_number_off_block)) { - pith["no_ocn_multiple_objects"] = eN.ocn.on; - pith["ocn"] = eN.ocn.off; + pith["no_ocn_multiple_objects"] = eN.bi.on; + pith["ocn"] = eN.ocn.off; debug(ocnoff) { writeln(line); } } if (line.matchFirst(rgx.object_number_off_block_dummy_heading)) { - pith["no_ocn_multiple_objects"] = eN.ocn.on; - pith["heading_multiple_objects"] = eN.bi.on; - pith["ocn"] = eN.ocn.off; + pith["no_ocn_multiple_objects"] = eN.bi.on; + pith["dummy_heading_multiple_objects"] = eN.bi.on; + pith["ocn"] = eN.ocn.off; debug(ocnoff) { writeln(line); } } - } else if (pith["no_ocn_multiple_objects"] == eN.ocn.off) { + } else if (pith["no_ocn_multiple_objects"] == eN.bi.off) { pith["dummy_heading_status"] = eN.bi.off; - if (pith["heading_multiple_objects"]) { + if (pith["dummy_heading_multiple_objects"]) { pith["dummy_heading_status"] = eN.bi.on; } if (line.matchFirst(rgx.object_number_off)) { @@ -2547,9 +2541,9 @@ template docAbstraction() { } else { pith["ocn"] = pith["no_ocn_multiple_objects"]; } - } else if (pith["no_ocn_multiple_objects"] == eN.ocn.on) { + } else if (pith["no_ocn_multiple_objects"] == eN.bi.on) { if (line.matchFirst(rgx.object_number_off_block_close)) { - pith["no_ocn_multiple_objects"] = eN.ocn.off; + pith["no_ocn_multiple_objects"] = eN.bi.off; pith["ocn"] = eN.ocn.on; pith["dummy_heading_status"] = eN.bi.off; debug(ocnoff) { @@ -2602,8 +2596,7 @@ template docAbstraction() { } @safe void flow_txt_block_start()( char[] line, - return ref int[string] obj_type_status, - return ref int[string] pith, + return ref uint[string] pith, return ref uint[string] dochas, return ref string[string] object_number_poem ) { @@ -2637,7 +2630,7 @@ template docAbstraction() { pith["block_is"] = eN.blk_is.poem; pith["block_state"] = eN.blk_state.on; pith["block_delim"] = eN.blk_delim.curly; - obj_type_status["verse_new"] = eN.bi.on; + pith["verse_new"] = eN.bi.on; } else if (auto m = line.matchFirst(rgx.block_curly_group_open)) { dochas["group"]++; an_object["syntax"] = ""; @@ -2657,7 +2650,7 @@ template docAbstraction() { an_object["syntax"] = ""; an_object["attrib"] = (m["attrib"]) ? m["attrib"].to!string : ""; an_object["lang"] = (m["lang"]) ? m["lang"].to!string : ""; - debug(block) { // block (curly) open + debug(block) { writefln( "* [block curly] %s", line @@ -2671,7 +2664,7 @@ template docAbstraction() { an_object["syntax"] = ""; an_object["attrib"] = m["attrib"].to!string; an_object["lang"] = m["lang"].to!string; - debug(quote) { // quote (curly) open + debug(quote) { writefln( "* [quote curly] %s", line @@ -2705,7 +2698,7 @@ template docAbstraction() { an_object["lang"] = ""; an_object["attrib"] = (m["attrib"]) ? m["attrib"].to!string : ""; an_object["syntax"] = (m["syntax"]) ? m["syntax"].to!string : ""; - debug(codetic) { // code (tic) open + debug(codetic) { writefln( "* [code tic] %s", line @@ -2719,7 +2712,7 @@ template docAbstraction() { an_object["syntax"] = ""; an_object["attrib"] = (m["attrib"]) ? m["attrib"].to!string : ""; an_object["lang"] = (m["lang"]) ? m["lang"].to!string : ""; - debug(poem) { // poem (tic) open + debug(poem) { writefln( "* [poem tic] %s", line @@ -2729,13 +2722,13 @@ template docAbstraction() { pith["block_is"] = eN.blk_is.poem; pith["block_state"] = eN.blk_state.on; pith["block_delim"] = eN.blk_delim.tic; - obj_type_status["verse_new"] = eN.bi.on; + pith["verse_new"] = eN.bi.on; } else if (auto m = line.matchFirst(rgx.block_tic_group_open)) { dochas["group"]++; an_object["syntax"] = ""; an_object["attrib"] = (m["attrib"]) ? m["attrib"].to!string : ""; an_object["lang"] = (m["lang"]) ? m["lang"].to!string : ""; - debug(group) { // group (tic) open + debug(group) { writefln( "* [group tic] %s", line @@ -2749,7 +2742,7 @@ template docAbstraction() { an_object["syntax"] = ""; an_object["attrib"] = (m["attrib"]) ? m["attrib"].to!string : ""; an_object["lang"] = (m["lang"]) ? m["lang"].to!string : ""; - debug(block) { // block (tic) open + debug(block) { writefln( "* [block tic] %s", line @@ -2763,7 +2756,7 @@ template docAbstraction() { an_object["syntax"] = ""; an_object["attrib"] = m["attrib"].to!string; an_object["lang"] = m["lang"].to!string; - debug(quote) { // quote (tic) open + debug(quote) { writefln( "* [quote tic] %s", line @@ -2790,7 +2783,7 @@ template docAbstraction() { @safe string[string] flow_txt_block_quote()( char[] line, string[string] an_object, - return ref int[string] pith, + return ref uint[string] pith, ) { static auto rgx = RgxI(); if (pith["block_is"] == eN.blk_is.quote){ @@ -2831,7 +2824,7 @@ template docAbstraction() { @safe string[string] flow_txt_block_group()( char[] line, string[string] an_object, - return ref int[string] pith, + return ref uint[string] pith, ) { static auto rgx = RgxI(); if (pith["block_is"] == eN.blk_is.group) { @@ -2872,7 +2865,7 @@ template docAbstraction() { @safe string[string] flow_txt_block_block()( char[] line, string[string] an_object, - return ref int[string] pith, + return ref uint[string] pith, ) { static auto rgx = RgxI(); if (pith["block_is"] == eN.blk_is.block) { @@ -2913,8 +2906,7 @@ template docAbstraction() { @safe string[string] flow_txt_block_poem(CMM)( char[] line, string[string] an_object, - return ref int[string] obj_type_status, - return ref int[string] pith, + return ref uint[string] pith, return ref int cntr, string[string] object_number_poem, CMM conf_make_meta, @@ -2985,15 +2977,15 @@ template docAbstraction() { pith["block_delim"] = eN.blk_delim.off; } else { processing["verse"] ~= line ~= "\n"; - if (obj_type_status["verse_new"] == eN.bi.on) { + if (pith["verse_new"] == eN.bi.on) { obj_cite_digits = ocn_emit(pith["ocn"]); - obj_type_status["verse_new"] = eN.bi.off; + pith["verse_new"] = eN.bi.off; } else if (line.matchFirst(rgx.newline_eol_delimiter_only)) { processing["verse"] = processing["verse"].stripRight; - verse_line = eN.tri.off; - obj_type_status["verse_new"] = eN.bi.on; + verse_line = eN.bi.off; + pith["verse_new"] = eN.bi.on; } - if (obj_type_status["verse_new"] == eN.bi.on) { + if (pith["verse_new"] == eN.bi.on) { verse_line=1; an_object[an_object_key] = processing["verse"]; debug(poem) { @@ -3093,15 +3085,15 @@ template docAbstraction() { pith["block_delim"] = eN.blk_delim.off; } else { processing["verse"] ~= line ~= "\n"; - if (obj_type_status["verse_new"] == eN.bi.on) { + if (pith["verse_new"] == eN.bi.on) { obj_cite_digits = ocn_emit(pith["ocn"]); - obj_type_status["verse_new"] = eN.bi.off; + pith["verse_new"] = eN.bi.off; } else if (line.matchFirst(rgx.newline_eol_delimiter_only)) { processing["verse"] = processing["verse"].stripRight; - obj_type_status["verse_new"] = eN.bi.on; - verse_line = eN.tri.off; + pith["verse_new"] = eN.bi.on; + verse_line = eN.bi.off; } - if (obj_type_status["verse_new"] == eN.bi.on) { + if (pith["verse_new"] == eN.bi.on) { verse_line=1; an_object[an_object_key] = processing["verse"]; debug(poem) { @@ -3158,7 +3150,7 @@ template docAbstraction() { @safe void flow_txt_block_code()( char[] line, return ref string[string] an_object, - return ref int[string] pith, + return ref uint[string] pith, ) { static auto rgx = RgxI(); if ( pith["block_is"] == eN.blk_is.code) { @@ -3202,8 +3194,7 @@ template docAbstraction() { @system string[string] flow_txt_block_table(CMM)( char[] line, string[string] an_object, - return ref int[string] obj_type_status, - return ref int[string] pith, + return ref uint[string] pith, return ref CMM conf_make_meta, ) { static auto rgx = RgxI(); @@ -3280,11 +3271,11 @@ template docAbstraction() { return btm[abr]; } @system void flow_txt_block_biblio( - char[] line, - return ref int[string] pith, - return ref int bib_entry, - return ref string biblio_entry_str_json, - return ref string[] biblio_arr_json, + char[] line, + return ref uint[string] pith, + return ref int bib_entry, + return ref string biblio_entry_str_json, + return ref string[] biblio_arr_json, ) { mixin spineBiblio; auto jsn = BibJsnStr(); @@ -3318,7 +3309,7 @@ template docAbstraction() { } biblio_entry_str_json = jsn.biblio_entry_tags_jsonstr; } - } else { // CHECK ERROR + } else { writeln("?? 2. ERROR ", biblio_entry_str_json, "??"); biblio_entry_str_json = ""; } @@ -3406,7 +3397,7 @@ template docAbstraction() { return ref N obj_cite_digits, return ref ObjGenericComposite _comp_obj_heading, return ref int cntr, - return ref int[string] pith, + return ref uint[string] pith, CMM conf_make_meta ) { comp_obj_block = comp_obj_block.init; @@ -3449,7 +3440,7 @@ template docAbstraction() { return ref N obj_cite_digits, return ref ObjGenericComposite _comp_obj_heading, return ref int cntr, - return ref int[string] pith, + return ref uint[string] pith, string[string] object_number_poem, CMM conf_make_meta, Ts tag_in_seg, @@ -3761,7 +3752,7 @@ template docAbstraction() { char[] line, string[string] an_object, return ref string book_idx_tmp, - return ref int[string] pith, + return ref uint[string] pith, B opt_action, ) { static auto rgx = RgxI(); @@ -3812,12 +3803,11 @@ template docAbstraction() { string[string] heading_match_str, string[] _make_unmarked_headings, return ref Regex!(char)[string] heading_match_rgx, - return ref int[string] obj_type_status, - return ref int[string] pith, + return ref uint[string] pith, ) { static auto rgx = RgxI(); if ((_make_unmarked_headings.length > 2) - && (obj_type_status["make_headings"] == eN.bi.off)) { /+ headings found +/ + && (pith["make_headings"] == eN.bi.off)) { /+ headings found +/ debug(headingsfound) { writeln(_make_unmarked_headings); } @@ -3885,7 +3875,7 @@ template docAbstraction() { default: break; } - obj_type_status["make_headings"] = eN.bi.on; + pith["make_headings"] = eN.bi.on; } return heading_match_str; } @@ -3893,10 +3883,9 @@ template docAbstraction() { char[] line, int[string] line_occur, return ref Regex!(char)[string] heading_match_rgx, - return ref int[string] obj_type_status, - return ref int[string] pith, + return ref uint[string] pith, ) { - if (obj_type_status["make_headings"] == eN.bi.on + if (pith["make_headings"] == eN.bi.on && (line_occur["para"] == eN.bi.off && line_occur["heading"] == eN.bi.off) && pith["txt_is"] == eN.txt_is.off @@ -3953,8 +3942,7 @@ template docAbstraction() { return ref string an_object_key, return ref int[string] lv, return ref int[string] collapsed_lev, - return ref int[string] obj_type_status, - return ref int[string] pith, + return ref uint[string] pith, return ref CMM conf_make_meta, ) { static auto rgx = RgxI(); @@ -4103,7 +4091,7 @@ template docAbstraction() { return ref string an_object_key, return ref int[string] indent, return ref bool bullet, - return ref int[string] pith, + return ref uint[string] pith, return ref int[string] line_occur, ) { static auto rgx = RgxI(); @@ -4696,8 +4684,8 @@ template docAbstraction() { if (_new_doc) { anchor_tag = ""; } - obj_txt["munge"]=_configured_auto_heading_numbering_and_segment_anchor_tags(obj_txt["munge"], obj_, conf_make_meta, _new_doc); - obj_txt["munge"]=_make_segment_anchor_tags_if_none_provided(obj_txt["munge"], obj_["lev"], _new_doc); + obj_txt["munge"] = _configured_auto_heading_numbering_and_segment_anchor_tags(obj_txt["munge"], obj_, conf_make_meta, _new_doc); + obj_txt["munge"] = _make_segment_anchor_tags_if_none_provided(obj_txt["munge"], obj_["lev"], _new_doc); if (auto m = obj_txt["munge"].match(rgx.heading_anchor_tag)) { anchor_tag = m.captures[1]; } else if (obj_["lev"] == "1") { @@ -5208,10 +5196,8 @@ template docAbstraction() { oa_j.object["object_number"] = _comp_obj_heading.metainfo.ocn; oa_j.object["lev_markup_number"] = _comp_obj_heading.metainfo.heading_lev_markup; oa_j.object["lev_collapsed_number"] = _comp_obj_heading.metainfo.heading_lev_collapsed; - oa_j.object["heading_ptr"] - = _comp_obj_heading.ptr.heading; - oa_j.object["doc_object_ptr"] - = _comp_obj_heading.ptr.doc_object; + oa_j.object["heading_ptr"] = _comp_obj_heading.ptr.heading; + oa_j.object["doc_object_ptr"] = _comp_obj_heading.ptr.doc_object; } oa_j.object["parent_object_number"] = _comp_obj_heading.metainfo.parent_ocn; oa_j.object["parent_lev_markup_number"] = _comp_obj_heading.metainfo.parent_lev_markup; @@ -5256,7 +5242,7 @@ template docAbstraction() { ) { main_term = m.captures[1].strip; object_number_offset = m.captures[2].to!int; - object_number_endpoint=(obj_cite_digits.object_number + object_number_offset); + object_number_endpoint = (obj_cite_digits.object_number + object_number_offset); object_numbers ~= (obj_cite_digits.object_number.to!string ~ "-" ~ object_number_endpoint.to!string); } else { @@ -5274,7 +5260,7 @@ template docAbstraction() { if (auto m = sub_terms_bits.match(rgx.bi_term_and_object_numbers_match)) { sub_term = m.captures[1].strip; object_number_offset = m.captures[2].to!int; - object_number_endpoint=(obj_cite_digits.object_number + object_number_offset); + object_number_endpoint = (obj_cite_digits.object_number + object_number_offset); object_numbers ~= (obj_cite_digits.object_number.to!string ~ " - " ~ object_number_endpoint.to!string); } else { |