diff options
Diffstat (limited to 'lib')
-rwxr-xr-x | lib/sdp.d | 119 | ||||
-rw-r--r-- | lib/sdp/ao_abstract_doc_source.d | 367 | ||||
-rw-r--r-- | lib/sdp/ao_assertions.d | 6 | ||||
-rw-r--r-- | lib/sdp/ao_defaults.d | 76 | ||||
-rw-r--r-- | lib/sdp/ao_emitter.d | 274 | ||||
-rw-r--r-- | lib/sdp/ao_interface.d | 144 | ||||
-rw-r--r-- | lib/sdp/ao_object_setter.d | 96 | ||||
-rw-r--r-- | lib/sdp/ao_output_debugs.d | 173 | ||||
-rw-r--r-- | lib/sdp/ao_read_markup_source.d | 8 | ||||
-rw-r--r-- | lib/sdp/ao_rgx.d | 42 | ||||
-rw-r--r-- | lib/sdp/ao_scan_inserts.d | 124 | ||||
-rw-r--r-- | lib/sdp/ao_structs.d | 43 | ||||
-rw-r--r-- | lib/sdp/ao_utils.d | 4 | ||||
-rw-r--r-- | lib/sdp/compile_time_info.d | 38 | ||||
-rw-r--r-- | lib/sdp/version.txt | 8 | ||||
-rw-r--r-- | lib/version.txt | 7 |
16 files changed, 944 insertions, 585 deletions
@@ -1,8 +1,8 @@ #!/usr/bin/env rdmd -/* +/+ sdp sdp.d -*/ ++/ /+ sdp sisu document parser +/ import std.algorithm, @@ -21,21 +21,28 @@ import std.typecons, std.utf, // std.variant, + std.conv : to; +/+ sdp sisu document parser +/ +import + lib.sdp.compile_time_info, // sdp/compile_time_info.d lib.sdp.ao_abstract_doc_source, // sdp/ao_abstract_doc_source.d lib.sdp.ao_assertions, // sdp/ao_assertions.d lib.sdp.ao_defaults, // sdp/ao_defaults.d lib.sdp.ao_emitter, // sdp/ao_emitter.d - lib.sdp.ao_interface, // sdp/ao_interface.d - lib.sdp.ao_read_markup_source, // sdp/ao_read_markup_source.d + lib.sdp.ao_read_markup_source, // sdp/ao_read_markup_source.d lib.sdp.ao_object_setter, // sdp/ao_object_setter.d lib.sdp.ao_output_debugs, // sdp/ao_output_debugs.d lib.sdp.ao_rgx, // sdp/ao_rgx.d lib.sdp.ao_scan_inserts, // sdp/ao_scan_inserts.d + lib.sdp.ao_structs, // sdp/ao_structs.d lib.sdp.ao_utils; // sdp/ao_utils.d // std.conv; -import std.conv : to; -mixin RgxInit; mixin Interfaces; mixin Emitters; +// import std.stdio; +mixin(import("version.txt")); +mixin CompileTimeInfo; +mixin RgxInit; mixin Emitters; void main(string[] argv) { + mixin SiSUheader; mixin SiSUbiblio; mixin SiSUrgxInitFlags; @@ -44,10 +51,10 @@ void main(string[] argv) { mixin SiSUdocAbstraction; mixin SiSUoutputDebugs; mixin ScreenTxtColors; - auto cli = new CLI(); - auto raw = new MarkupRaw(); - auto abs = new Abstraction(); - auto dbg = new SDPoutputDebugs(); + auto cli = CLI(); + auto raw = MarkupRaw(); + auto abs = Abstraction(); + auto dbg = SDPoutputDebugs(); // struct DocumentParts { // string[string][] contents; // JSONValue[string] metadata_json; @@ -55,67 +62,89 @@ void main(string[] argv) { // string[][string][string] bookindex_unordered_hashes; // JSONValue[] biblio; // } - char[][] msc; - string[1000] fns_src; + string[] fns_src; string flag_action; string[string] actions; - int file_count; actions = [ "assert" : "yes", ]; - auto rgx = new Rgx(); + auto rgx = Rgx(); scope(success) { debug(checkdoc) { - writeln( + writefln( + "%s~ run complete, ok ~ %s (sdp-%s.%s.%s, %s v%s, %s %s)", scr_txt_color["cyan"], - "~ run complete, ok ~ ", scr_txt_color["off"], + ver.major, + ver.minor, + ver.patch, + __VENDOR__, + __VERSION__, + bits, + os, ); } - // writeln("0"); + // stderr.writeln("0"); } scope(failure) { - debug(checkdoc) { - writeln( + debug(checkdoc) { + writefln( + "%s~ run failure ~%s", scr_txt_color["fuchsia"], - "~ run failure ~", scr_txt_color["off"], + ); + } + // stderr.writeln("1"); + } + scope(exit) { + debug(checkdoc) { + writefln( + "(%s v%s)", + __VENDOR__, + __VERSION__, ); } - // writeln("1"); } foreach(cmdlnins; argv) { if (match(cmdlnins, rgx.flag_action)) { flag_action ~= " " ~ cmdlnins; actions = cli.extract_actions(cmdlnins, actions); } else if (match(cmdlnins, rgx.src_pth)) { - fns_src[file_count] = cmdlnins; - file_count++; + fns_src ~= cmdlnins; } } foreach(fn_src; fns_src) { if (!empty(fn_src)) { scope(success) { debug(checkdoc) { - writeln( + writefln( + "%s~ document complete, ok ~%s %s", scr_txt_color["green"], - "~ document complete, ok ~ ", scr_txt_color["off"], fn_src ); } - // writeln("0"); + // stderr.writeln("0"); } scope(failure) { debug(checkdoc) { - writeln( + writefln( + "%s~ document run failure ~%s (%s v%s)\n\t%s", scr_txt_color["red"], - "~ document run failure ~", scr_txt_color["off"], + __VENDOR__, + __VERSION__, + fn_src + ); + } + // stderr.writeln("1"); + } + scope(exit) { + debug(checkdoc) { + writeln( fn_src ); } - // writeln("1"); } enforce( match(fn_src, rgx.src_pth), @@ -131,28 +160,34 @@ void main(string[] argv) { auto m = match(fn_src, rgx.src_pth); // auto m = match(fn_src, rgx.src_pth); auto markup_src_file_path = m.captures[1]; - writeln("markup source file path: ", markup_src_file_path); // writeln(m.captures[1]); + writefln( + "markup source file path: %s", + markup_src_file_path + ); // writeln(m.captures[1]); writeln(m.captures[2]); } if (match(fn_src, rgx.src_fn_master)) { - /+ if master file scan document source for document imports (inserted sub-documents) +/ - auto ins = new Inserts(); - auto markup_master_sourcefile_content = + /+ if master file .ssm + scan document source for document imports + (inserted sub-documents) + +/ + auto ins = Inserts(); + markup_sourcefile_content = ins.scan_doc_source(markup_sourcefile_content, fn_src); - msc = markup_master_sourcefile_content; - } else if (match(fn_src, rgx.src_fn)) { - msc = markup_sourcefile_content; - } else { + } else if (!match(fn_src, rgx.src_fn)) { writeln("not a recognized filename"); } debug(raw) { - foreach (line; msc) { + foreach (line; markup_sourcefile_content) { writeln(line); } } - /+ process document ao_abstract_doc_source SiSUdocAbstraction::Abstraction return abstraction as tuple +/ + /+ process document ao_abstract_doc_source + SiSUdocAbstraction::Abstraction + return abstraction as tuple + +/ auto t = - abs.abstract_doc_source(msc); + abs.abstract_doc_source(markup_sourcefile_content); static assert(!isTypeTuple!(t)); auto contents = t[0]; // static assert(!isIterable!(contents)); @@ -176,7 +211,7 @@ void main(string[] argv) { // compose abstract document markup state // append book index scope(exit) { - destroy(msc); + destroy(markup_sourcefile_content); destroy(t); destroy(contents); destroy(make_json); @@ -186,7 +221,7 @@ void main(string[] argv) { destroy(biblio); } } else { - /* no recognized filename provided */ + /+ no recognized filename provided +/ writeln("no recognized filename"); break; // terminate, stop diff --git a/lib/sdp/ao_abstract_doc_source.d b/lib/sdp/ao_abstract_doc_source.d index 941c3f0..34e4072 100644 --- a/lib/sdp/ao_abstract_doc_source.d +++ b/lib/sdp/ao_abstract_doc_source.d @@ -1,29 +1,31 @@ -/* +/+ document abstraction ao_abstract_doc_source.d -*/ ++/ mixin template SiSUdocAbstraction() { - class Abstraction { - /* abstract marked up document */ + private: + struct Abstraction { + /+ ↓ abstract marked up document +/ auto abstract_doc_source(char[][] markup_sourcefile_content) { /+ initialize +/ mixin ObjectSetters; mixin AssertionsOnMarkupDocumentStructure; mixin AssertionsOnBlocks; mixin ScreenTxtColors; - auto rgx = new Rgx(); - auto set_oa = new ObjectAbstractSet(); - auto set_header = new HeaderDocMetadataMakeJson(); - auto notesection = new NotesSection(); - string[string][131072] contents_arbitrary_max_length_set; // 2000 pg * 50 lines == 100000 - string[1024] notes; + auto rgx = Rgx(); + auto set_oa = ObjectAbstractSet(); + auto set_header = HeaderDocMetadataMakeJson(); + auto notesection = NotesSection(); + string[string][] contents; + mixin Structs; string notes_str; string[string] object, processing, head; string biblio_tag_name, biblio_tag_entry, book_idx_tmp, st; - string[1024] biblio_arr_json = biblio_entry_tags_jsonstr; - JSONValue[1024] bib_arr_json; + string[] biblio_arr_json; + JSONValue[] bib_arr_json; uint[string] line_occur; - uint counter, previous_count, count_biblio_entry, ocn, ocn_, verse_line, bib_entry, heading_pointer, notepoint; + uint counter, ocn, ocn_, verse_line, bib_entry, heading_pointer, notepoint, count_biblio_entry; + ulong previous_count; string indent_first, indent_second; string[][string][string] bookindex_unordered_hashes; bool bullet = true; @@ -67,18 +69,18 @@ mixin template SiSUdocAbstraction() { auto str_h_4 = "^(none)"; string content_non_header = "8"; string node; - auto obj_im = new ObjInlineMarkup(); - auto obj_att = new ObjAttrib(); - auto object_citation_number = new OCNemitter(); + auto obj_im = ObjInlineMarkup(); + auto obj_att = ObjAttrib(); + auto object_citation_number = OCNemitter(); auto ft = flag_type.dup; int ocn_emit(int ocn_status_flag) { return object_citation_number.ocn_emitter(ocn_status_flag); } - auto bookindex_extract_hash = new BookIndexNuggetHash(); + auto bookindex_extract_hash = BookIndexNuggetHash(); string[][string][string] bkidx_hash(string bookindex, int ocn) { return bookindex_extract_hash.bookindex_nugget_hash(bookindex, ocn); } - auto node_construct = new NodeStructureMetadata(); + auto node_construct = NodeStructureMetadata(); string node_jstr( string lvn, int ocn_, @@ -116,11 +118,20 @@ mixin template SiSUdocAbstraction() { "end" : "" ]; int tell_lo(string color, int ocn, in char[] line) { - writeln(scr_txt_marker[color], to!string(ocn), " ", to!string(line)); + writefln( + "%s%s %s", + scr_txt_marker[color], + to!string(ocn), + to!string(line) + ); return 0; } int tell_l(string color, in char[] line) { - writeln(scr_txt_marker[color], line); + writefln( + "%s%s", + scr_txt_marker[color], + line + ); return 0; } scope(success) { @@ -128,23 +139,26 @@ mixin template SiSUdocAbstraction() { scope(failure) { } scope(exit) { - destroy(contents_arbitrary_max_length_set); + destroy(contents); destroy(object); destroy(processing); destroy(biblio_arr_json); } auto dochead_make = parseJSON(header_make_jsonstr).object; auto dochead_metadata = parseJSON(header_metadata_jsonstr).object; + /+ ↓ loop markup document/text line by line +/ foreach (line; markup_sourcefile_content) { - /* loop markup document/text line by line */ - /* scope */ + /+ ↓ markup document/text line by line +/ + /+ scope +/ scope(exit) { } scope(failure) { - writeln(__FILE__, ":", __LINE__, " failed here:"); - writeln(" line: ", line); - writeln(" is : ", object["is"]); - writeln(" node: ", node); + writefln( + "%s:%s failed here: \n line: %s", + __FILE__, + __LINE__, + line, + ); } line = replaceAll(line, rgx.true_dollar, "$$$$"); // dollar represented as $$ needed to stop submatching on $ @@ -155,13 +169,17 @@ mixin template SiSUdocAbstraction() { } debug(srclines) { if (!line.empty) { // source lines, not empty - writeln(scr_txt_marker["green"], line); + writefln( + "%s%s", + scr_txt_marker["green"], + line + ); } } if ((!line.empty) && (ft["ocn_status_multi_obj"] == 0)) { - /* not multi-line object, check whether ocn is on or turned off */ + /+ not multi-line object, check whether ocn is on or turned off +/ if (match(line, rgx.ocn_block_marks)) { - /* switch off ocn */ + /+ switch off ocn +/ if (match(line, rgx.ocn_off_block)) { ft["ocn_status_multi_obj"] = 1; debug(ocnoff) { @@ -198,7 +216,7 @@ mixin template SiSUdocAbstraction() { } } if (ft["code"] == 1) { - /* block object: code */ + /+ block object: code +/ if (ft["curly_code"] == 1) { if (auto m = match(line, rgx.block_curly_code_close)) { debug(code) { // code (curly) close @@ -229,26 +247,25 @@ mixin template SiSUdocAbstraction() { } } } else if (!match(line, rgx.regular_parse_skip)) { - /* object other than code block object (includes regular text paragraph) */ + /+ object other than code block object (includes regular text paragraph) +/ if (((match(line, rgx.heading_biblio) || (ft["heading_biblio"] == 1))) && (!match(line, rgx.heading)) && (!match(line, rgx.comment))) { - /* within block object: biblio */ + /+ within block object: biblio +/ if (match(line, rgx.heading_biblio)) { ft["heading_biblio"] = 1; } if (empty(line) && (bib_entry == 0)) { - count_biblio_entry++; + ++count_biblio_entry; + biblio_arr_json ~= biblio_entry_tags_jsonstr; bib_entry = 1; } debug(biblio) { - writeln( + writefln( + "%s * %s %s", scr_txt_color["yellow"], - "* ", scr_txt_color["off"], - to!string(count_biblio_entry), - " ", line ); } @@ -257,7 +274,7 @@ mixin template SiSUdocAbstraction() { bib_entry = 0; st=to!string(bt.captures[1]); biblio_tag_entry=to!string(bt.captures[2]); - JSONValue j = parseJSON(biblio_arr_json[count_biblio_entry]); + JSONValue j = parseJSON(biblio_arr_json[count_biblio_entry-1]); // core.exception.RangeError@lib/sdp/ao_abstract_doc_source.d(288): Range violation (LDC) [: same for 343], fix to subtract 1 done! if (match(st, rgx.biblio_abbreviations)) { biblio_tag_name=biblio_tag_map[st]; } else { @@ -300,29 +317,28 @@ mixin template SiSUdocAbstraction() { auto s = to!string(j); s = j.toString(); debug(biblio) { - writeln( + writefln( + "%s* %s%s: %s\n%s", scr_txt_color["red"], - "* ", scr_txt_color["off"], biblio_tag_name, - ": ", - biblio_tag_entry + biblio_tag_entry, + j[biblio_tag_name] ); - writeln(biblio_arr_json[count_biblio_entry]); writeln(j[biblio_tag_name], ":", j[biblio_tag_name]); } - biblio_arr_json[count_biblio_entry] = s; + biblio_arr_json[count_biblio_entry-1] = s; biblio_tag_entry=""; } } else if (ft["poem"] == 1) { - /* within block object: poem */ + /+ within block object: poem +/ if (ft["curly_poem"] == 1) { if (auto m = match(line, rgx.block_curly_poem_close)) { object["obj"]="verse"; // check that this is as you please debug(poem) { // poem (curly) close - writeln( + writefln( + "%s* [poem curly] %s%s", scr_txt_color["red"], - "* [poem curly] ", scr_txt_color["off"], line ); @@ -332,10 +348,10 @@ mixin template SiSUdocAbstraction() { } debug(poem) { // poem (curly) close writeln(__LINE__); - writeln( + writefln( + "%s%s %s", scr_txt_marker["fuchsia"], ocn, - " ", line ); } @@ -354,7 +370,7 @@ mixin template SiSUdocAbstraction() { obj_im.obj_inline_markup(object["is"], object["obj"]); object["attrib"] = obj_att.obj_attributes(object["is"], object["obj"], node); - contents_arbitrary_max_length_set[counter] = + contents ~= set_oa.contents_block( object["is"], object["markup"], @@ -386,10 +402,12 @@ mixin template SiSUdocAbstraction() { verse_line=1; object["obj"] = processing["verse"]; debug(poem) { // poem verse - writeln(scr_txt_marker["green"], - ocn, - " curly\n", - object["obj"]); + writefln( + "%s%s curly\n%s", + scr_txt_marker["green"], + ocn, + object["obj"] + ); } processing.remove("verse"); object["is"] = "verse"; @@ -402,7 +420,7 @@ mixin template SiSUdocAbstraction() { ); object["markup"] = obj_im.obj_inline_markup(object["is"], object["obj"]); object["attrib"] = obj_att.obj_attributes(object["is"], object["obj"], node); - contents_arbitrary_max_length_set[counter] = + contents ~= set_oa.contents_block( object["is"], object["markup"], @@ -422,9 +440,9 @@ mixin template SiSUdocAbstraction() { if (auto m = match(line, rgx.block_tic_close)) { // tic_poem_close object["obj"]="verse"; // check that this is as you please debug(poem) { // poem (curly) close - writeln( + writefln( + "%s* [poem tic] %s%s", scr_txt_color["red"], - "* [poem tic] ", scr_txt_color["off"], line ); @@ -443,7 +461,7 @@ mixin template SiSUdocAbstraction() { obj_im.obj_inline_markup(object["is"], object["obj"]); object["attrib"] = obj_att.obj_attributes(object["is"], object["obj"], node); - contents_arbitrary_max_length_set[counter] = + contents ~= set_oa.contents_block( object["is"], object["markup"], @@ -475,10 +493,12 @@ mixin template SiSUdocAbstraction() { verse_line=1; object["obj"] = processing["verse"]; debug(poem) { // poem (tic) close - writeln(scr_txt_marker["green"], - ocn, - " tic\n", - object["obj"]); + writefln( + "%s%s tic\n%s", + scr_txt_marker["green"], + ocn, + object["obj"] + ); } processing.remove("verse"); object["is"] = "verse"; @@ -494,7 +514,7 @@ mixin template SiSUdocAbstraction() { obj_im.obj_inline_markup(object["is"], object["obj"]); object["attrib"] = obj_att.obj_attributes(object["is"], object["obj"], node); - contents_arbitrary_max_length_set[counter] = + contents ~= set_oa.contents_block( object["is"], object["markup"], @@ -511,7 +531,7 @@ mixin template SiSUdocAbstraction() { } } } - /* within block object: group */ + /+ within block object: group +/ } else if (ft["group"] == 1) { if (ft["curly_group"] == 1) { if (auto m = match(line, rgx.block_curly_group_close)) { @@ -543,7 +563,7 @@ mixin template SiSUdocAbstraction() { } } } else if (ft["block"] == 1) { - /* within block object: block */ + /+ within block object: block +/ if (ft["curly_block"] == 1) { if (auto m = match(line, rgx.block_curly_block_close)) { debug(block) { // block (curly) close @@ -574,7 +594,7 @@ mixin template SiSUdocAbstraction() { } } } else if (ft["quote"] == 1) { - /* within block object: quote */ + /+ within block object: quote +/ if (ft["curly_quote"] == 1) { if (auto m = match(line, rgx.block_curly_quote_close)) { debug(quote) { // quote (curly) close @@ -605,7 +625,7 @@ mixin template SiSUdocAbstraction() { } } } else if (ft["table"] == 1) { - /* within block object: table */ + /+ within block object: table +/ if (ft["curly_table"] == 1) { if (auto m = match(line, rgx.block_curly_table_close)) { debug(table) { // table (curly) close @@ -636,7 +656,7 @@ mixin template SiSUdocAbstraction() { } } } else { - /* not within a block group */ + /+ not within a block group +/ assert( (ft["blocks"] == 0) || (ft["blocks"] == 2), @@ -644,11 +664,11 @@ mixin template SiSUdocAbstraction() { ); assertions_flag_types_block_status_none_or_closed(ft); if (auto m = match(line, rgx.block_curly_code_open)) { - /* curly code open */ + /+ curly code open +/ debug(code) { // code (curly) open - writeln( + writefln( + "%s* [code curly] %s%s", scr_txt_color["blue"], - "* [code curly] ", scr_txt_color["off"], line ); @@ -657,7 +677,7 @@ mixin template SiSUdocAbstraction() { ft["code"] = 1; ft["curly_code"] = 1; } else if (auto m = match(line, rgx.block_curly_poem_open)) { - /* curly poem open */ + /+ curly poem open +/ object.remove("obj"); object.remove("markup"); object.remove("is"); @@ -665,9 +685,9 @@ mixin template SiSUdocAbstraction() { object.remove("bookindex"); processing.remove("verse"); debug(poem) { // poem (curly) open - writeln( + writefln( + "%s* [poem curly] %s%s", scr_txt_color["red"], - "* [poem curly] ", scr_txt_color["off"], line ); @@ -678,11 +698,11 @@ mixin template SiSUdocAbstraction() { ft["poem"] = 1; ft["curly_poem"] = 1; } else if (auto m = match(line, rgx.block_curly_group_open)) { - /* curly group open */ + /+ curly group open +/ debug(group) { // group (curly) open - writeln( + writefln( + "%s* [group curly] %s%s", scr_txt_color["blue"], - "* [group curly] ", scr_txt_color["off"], line ); @@ -691,11 +711,11 @@ mixin template SiSUdocAbstraction() { ft["group"] = 1; ft["curly_group"] = 1; } else if (auto m = match(line, rgx.block_curly_block_open)) { - /* curly block open */ + /+ curly block open +/ debug(block) { // block (curly) open - writeln( + writefln( + "%s* [block curly] %s%s", scr_txt_color["blue"], - "* [block curly] ", scr_txt_color["off"], line ); @@ -704,11 +724,11 @@ mixin template SiSUdocAbstraction() { ft["block"] = 1; ft["curly_block"] = 1; } else if (auto m = match(line, rgx.block_curly_quote_open)) { - /* curly quote open */ + /+ curly quote open +/ debug(quote) { // quote (curly) open - writeln( + writefln( + "%s* [quote curly] %s%s", scr_txt_color["blue"], - "* [quote curly] ", scr_txt_color["off"], line ); @@ -717,11 +737,11 @@ mixin template SiSUdocAbstraction() { ft["quote"] = 1; ft["curly_quote"] = 1; } else if (auto m = match(line, rgx.block_curly_table_open)) { - /* curly table open */ + /+ curly table open +/ debug(table) { // table (curly) open - writeln( + writefln( + "%s* [table curly] %s%s", scr_txt_color["blue"], - "* [table curly] ", scr_txt_color["off"], line ); @@ -730,11 +750,11 @@ mixin template SiSUdocAbstraction() { ft["table"] = 1; ft["curly_table"] = 1; } else if (auto m = match(line, rgx.block_tic_code_open)) { - /* tic code open */ + /+ tic code open +/ debug(code) { // code (tic) open - writeln( + writefln( + "%s* [code tic] %s%s", scr_txt_color["blue"], - "* [code tic] ", scr_txt_color["off"], line ); @@ -743,7 +763,7 @@ mixin template SiSUdocAbstraction() { ft["code"] = 1; ft["tic_code"] = 1; } else if (auto m = match(line, rgx.block_tic_poem_open)) { - /* tic poem open */ + /+ tic poem open +/ object.remove("obj"); object.remove("markup"); object.remove("is"); @@ -751,9 +771,9 @@ mixin template SiSUdocAbstraction() { object.remove("bookindex"); processing.remove("verse"); debug(poem) { // poem (tic) open - writeln( + writefln( + "%s* [poem tic] %s%s", scr_txt_color["red"], - "* [poem tic] ", scr_txt_color["off"], line ); @@ -764,11 +784,11 @@ mixin template SiSUdocAbstraction() { ft["poem"] = 1; ft["tic_poem"] = 1; } else if (auto m = match(line, rgx.block_tic_group_open)) { - /* tic group open */ + /+ tic group open +/ debug(group) { // group (tic) open - writeln( + writefln( + "%s* [group tic] %s%s", scr_txt_color["blue"], - "* [group tic] ", scr_txt_color["off"], line ); @@ -777,11 +797,11 @@ mixin template SiSUdocAbstraction() { ft["group"] = 1; ft["tic_group"] = 1; } else if (auto m = match(line, rgx.block_tic_block_open)) { - /* tic block open */ + /+ tic block open +/ debug(block) { // block (tic) open - writeln( + writefln( + "%s* [block tic] %s%s", scr_txt_color["blue"], - "* [block tic] ", scr_txt_color["off"], line ); @@ -790,11 +810,11 @@ mixin template SiSUdocAbstraction() { ft["block"] = 1; ft["tic_block"] = 1; } else if (auto m = match(line, rgx.block_tic_quote_open)) { - /* tic quote open */ + /+ tic quote open +/ debug(quote) { // quote (tic) open - writeln( + writefln( + "%s* [quote tic] %s%s", scr_txt_color["blue"], - "* [quote tic] ", scr_txt_color["off"], line ); @@ -803,11 +823,11 @@ mixin template SiSUdocAbstraction() { ft["quote"] = 1; ft["tic_quote"] = 1; } else if (auto m = match(line, rgx.block_tic_table_open)) { - /* tic table open */ + /+ tic table open +/ debug(table) { // table (tic) open - writeln( + writefln( + "%s* [table tic] %s%s", scr_txt_color["blue"], - "* [table tic] ", scr_txt_color["off"], line ); @@ -816,8 +836,8 @@ mixin template SiSUdocAbstraction() { ft["table"] = 1; ft["tic_table"] = 1; } else if (!line.empty) { - /* line not empty */ - /* non blocks (headers, paragraphs) & closed blocks */ + /+ line not empty +/ + /+ non blocks (headers, paragraphs) & closed blocks +/ assert( !line.empty, "line tested, line not empty surely" @@ -840,11 +860,13 @@ mixin template SiSUdocAbstraction() { ); } if (auto m = match(line, rgx.book_index)) { - /* match book_index */ + /+ match book_index +/ debug(bookindexmatch) { // book index - writeln( - scr_txt_color["blue"], "* [bookindex] ", scr_txt_color["off"], - to!string(m.captures[1]), "\n" + writefln( + "%s* [bookindex] %s%s\n", + scr_txt_color["blue"], + scr_txt_color["off"], + to!string(m.captures[1]), ); // writeln(scr_txt_marker["blue"], to!string(m.captures[1]), "\n"); } @@ -854,24 +876,24 @@ mixin template SiSUdocAbstraction() { ft["book_index"] = 1; book_idx_tmp = to!string(m.captures[1]); debug(bookindexmatch) { // book index - writeln( + writefln( + "%s* [bookindex] %s%s\n", scr_txt_color["blue"], - "* [bookindex] ", scr_txt_color["off"], - book_idx_tmp, "\n" + book_idx_tmp, ); } } else if (ft["book_index"] == 1 ) { - /* book_index flag set */ + /+ book_index flag set +/ if (auto m = match(line, rgx.book_index_close)) { ft["book_index"] = 0; object["bookindex"] = book_idx_tmp ~ to!string(m.captures[1]); debug(bookindexmatch) { // book index - writeln( + writefln( + "%s* [bookindex] %s%s\n", scr_txt_color["blue"], - "* [bookindex] ", scr_txt_color["off"], - book_idx_tmp, "\n" + book_idx_tmp, ); } book_idx_tmp = ""; @@ -879,14 +901,14 @@ mixin template SiSUdocAbstraction() { book_idx_tmp ~= line; } } else { - /* not book_index */ + /+ not book_index +/ if (auto m = match(line, rgx.comment)) { - /* matched comment */ + /+ matched comment +/ debug(comment) { tell_l("blue", line); } object["obj"] ~= line ~= "\n"; - contents_arbitrary_max_length_set[counter] = + contents ~= set_oa.contents_comment(strip(object["obj"])); object.remove("obj"); object.remove("markup"); @@ -905,7 +927,7 @@ mixin template SiSUdocAbstraction() { ft["para"] = 0; counter++; } else if (auto m = match(line, rgx.header_make)) { - /* matched header_make */ + /+ matched header_make +/ debug(header1) { // header tell_l("yellow", line); } @@ -917,7 +939,7 @@ mixin template SiSUdocAbstraction() { line_occur["header_make"]++; object["obj"] ~= line ~= "\n"; } else if (auto m = match(line, rgx.header_metadata)) { - /* matched header_metadata */ + /+ matched header_metadata +/ debug(header1) { // header tell_l("yellow", line); } @@ -930,9 +952,9 @@ mixin template SiSUdocAbstraction() { object["obj"] ~= line ~= "\n"; } else if (ft["header_make"] == 1 && (line_occur["header_make"] > 0)) { - /* header_make flag set */ + /+ header_make flag set +/ if (auto m = match(line, rgx.header_sub)) { - /* sub-header */ + /+ sub-header +/ debug(header1) { tell_l("yellow", line); } @@ -941,9 +963,9 @@ mixin template SiSUdocAbstraction() { } } else if (ft["header_metadata"] == 1 && (line_occur["header_metadata"] > 0)) { - /* header_metadata flag set */ + /+ header_metadata flag set +/ if (auto m = match(line, rgx.header_sub)) { - /* sub-header */ + /+ sub-header +/ debug(header1) { tell_l("yellow", line); } @@ -954,10 +976,10 @@ mixin template SiSUdocAbstraction() { && (line_occur["heading"] == 0)) && ((ft["para"] == 0) && (ft["heading"] == 0))) { - /* heading or para but neither flag nor line exists */ + /+ heading or para but neither flag nor line exists +/ if ((to!string(dochead_make["make"]["headings"]).length > 2) && (ft["make_headings"] == 0)) { - /* headings found */ + /+ headings found +/ debug(headingsfound) { writeln(dochead_make["make"]["headings"]); } @@ -1026,7 +1048,7 @@ mixin template SiSUdocAbstraction() { && (line_occur["heading"] == 0)) && ((ft["para"] == 0) && (ft["heading"] == 0))) { - /* heading make set */ + /+ heading make set +/ if (match(line, rgx_h_B)) { line = "B~ " ~ line; debug(headingsfound) { @@ -1071,7 +1093,7 @@ mixin template SiSUdocAbstraction() { } } if (auto m = match(line, rgx.heading)) { - /* heading match */ + /+ heading match +/ ft["heading"] = 1; ft["header"] = 0; ft["header_make"] = 0; @@ -1194,7 +1216,7 @@ mixin template SiSUdocAbstraction() { tell_l("yellow", strip(line)); } } else if (line_occur["para"] == 0) { - /* para matches */ + /+ para matches +/ if (auto m = match(line, rgx.para_indent)) { debug(paraindent) { // para indent tell_l("blue", line); @@ -1241,7 +1263,7 @@ mixin template SiSUdocAbstraction() { line_occur["para"]++; } } else if (line_occur["header_make"] > 0) { - /* header_make */ + /+ header_make +/ // should be caught by sub-header debug(header) { tell_l("red", line); @@ -1249,7 +1271,7 @@ mixin template SiSUdocAbstraction() { object["obj"] ~= line ~= "\n"; line_occur["header_make"]++; } else if (line_occur["header_metadata"] > 0) { - /* header_metadata */ + /+ header_metadata +/ // should be caught by sub-header debug(header) { // para tell_l("red", line); @@ -1257,14 +1279,14 @@ mixin template SiSUdocAbstraction() { object["obj"] ~= line ~= "\n"; line_occur["header_metadata"]++; } else if (line_occur["heading"] > 0) { - /* heading */ + /+ heading +/ debug(heading) { // heading tell_l("blue", line); } object["obj"] ~= line ~= "\n"; line_occur["heading"]++; } else if (line_occur["para"] > 0) { - /* paragraph */ + /+ paragraph +/ debug(para) { tell_l("blue", line); } @@ -1273,7 +1295,7 @@ mixin template SiSUdocAbstraction() { } } } else if (ft["blocks"] == 2) { - /* line empty, with blocks flag */ + /+ line empty, with blocks flag +/ assert( line.empty, "line should be empty" @@ -1302,7 +1324,7 @@ mixin template SiSUdocAbstraction() { obj_im.obj_inline_markup(object["is"], object["obj"]); object["attrib"] = obj_att.obj_attributes(object["is"], object["obj"], node); - contents_arbitrary_max_length_set[counter] = + contents ~= set_oa.contents_block( object["is"], object["markup"], @@ -1332,7 +1354,7 @@ mixin template SiSUdocAbstraction() { heading_pointer-1, object["is"] ); - contents_arbitrary_max_length_set[counter] = + contents ~= set_oa.contents_block_ocn_string( "poem", "", @@ -1366,7 +1388,7 @@ mixin template SiSUdocAbstraction() { obj_im.obj_inline_markup(object["is"], object["obj"]); object["attrib"] = obj_att.obj_attributes(object["is"], object["obj"], node); - contents_arbitrary_max_length_set[counter] = + contents ~= set_oa.contents_block( object["is"], object["markup"], @@ -1399,7 +1421,7 @@ mixin template SiSUdocAbstraction() { obj_im.obj_inline_markup(object["is"], object["obj"]); object["attrib"] = obj_att.obj_attributes(object["is"], object["obj"], node); - contents_arbitrary_max_length_set[counter] = + contents ~= set_oa.contents_block( object["is"], object["markup"], @@ -1432,7 +1454,7 @@ mixin template SiSUdocAbstraction() { obj_im.obj_inline_markup(object["is"], object["obj"]); object["attrib"] = obj_att.obj_attributes(object["is"], object["obj"], node); - contents_arbitrary_max_length_set[counter] = + contents ~= set_oa.contents_block( object["is"], object["markup"], @@ -1466,7 +1488,7 @@ mixin template SiSUdocAbstraction() { obj_im.obj_inline_markup(object["is"], object["obj"]); object["attrib"] = obj_att.obj_attributes(object["is"], object["obj"], node); - contents_arbitrary_max_length_set[counter] = + contents ~= set_oa.contents_block( object["is"], object["markup"], @@ -1484,8 +1506,8 @@ mixin template SiSUdocAbstraction() { ft["quote"] = 0; } } else { - /* line empty */ - /* line.empty, post contents, empty variables: */ + /+ line empty +/ + /+ line.empty, post contents, empty variables: +/ assert( line.empty, "line should be empty" @@ -1496,7 +1518,7 @@ mixin template SiSUdocAbstraction() { ); if ((ft["header_make"] == 1) && (line_occur["header_make"] > 0)) { - /* header_make instructions (current line empty) */ + /+ header_make instructions (current line empty) +/ auto dochead_metadata_and_make = set_header.header_metadata_and_make_jsonstr(strip(object["obj"]), dochead_metadata, dochead_make); static assert(!isTypeTuple!(dochead_metadata_and_make)); @@ -1517,7 +1539,7 @@ mixin template SiSUdocAbstraction() { processing.remove("verse"); } else if ((ft["header_metadata"] == 1) && (line_occur["header_metadata"] > 0)) { - /* header_metadata (current line empty) */ + /+ header_metadata (current line empty) +/ auto dochead_metadata_and_make = set_header.header_metadata_and_make_jsonstr(strip(object["obj"]), dochead_metadata, dochead_make); static assert(!isTypeTuple!(dochead_metadata_and_make)); @@ -1540,7 +1562,7 @@ mixin template SiSUdocAbstraction() { processing.remove("verse"); } else if ((ft["heading"] == 1) && (line_occur["heading"] > 0)) { - /* heading object (current line empty) */ + /+ heading object (current line empty) +/ ocn = ocn_emit(ft["ocn_status"]); object["bookindex"] = ("bookindex" in object) ? object["bookindex"] : ""; @@ -1561,7 +1583,7 @@ mixin template SiSUdocAbstraction() { object["attrib"] = obj_att.obj_attributes(object["is"], object["obj"], node); heading_pointer++; - contents_arbitrary_max_length_set[counter] = + contents ~= set_oa.contents_heading( ft["ocn_status"], object["markup"], @@ -1593,7 +1615,7 @@ mixin template SiSUdocAbstraction() { processing.remove("verse"); counter++; } else if ((ft["para"] == 1) && (line_occur["para"] > 0)) { - /* paragraph object (current line empty) */ + /+ paragraph object (current line empty) +/ ocn = ocn_emit(ft["ocn_status"]); object["bookindex"] = ("bookindex" in object) ? object["bookindex"] : ""; @@ -1612,7 +1634,7 @@ mixin template SiSUdocAbstraction() { obj_im.obj_inline_markup(object["is"], object["obj"]); object["attrib"] = obj_att.obj_attributes(object["is"], object["obj"], node); - contents_arbitrary_max_length_set[counter] = + contents ~= set_oa.contents_para( object["is"], object["markup"], @@ -1651,47 +1673,52 @@ mixin template SiSUdocAbstraction() { } // close else for line empty } // close else for not the above } // close after non code, other blocks or regular text - if (((contents_arbitrary_max_length_set[counter-1]["is"] == "para") - || (contents_arbitrary_max_length_set[counter-1]["is"] == "heading")) + if (((contents[$-1]["is"] == "para") + || (contents[$-1]["is"] == "heading")) && (counter-1 > previous_count)) { - if (match(contents_arbitrary_max_length_set[counter-1]["obj"], + if (match(contents[$-1]["obj"], rgx.inline_notes_delimiter_al_regular_number_note)) { // endnotes/ footnotes for // doc objects other than paragraphs & headings // various forms of grouped text - previous_count=counter-1; - notesection.gather_notes_for_endnote_section(contents_arbitrary_max_length_set, counter-1); + previous_count=contents.length -1; + notesection.gather_notes_for_endnote_section( + contents, + contents.length -1 + ); } } - } // closed: loop markup document/text line by line - /* post loop markup document/text */ + } /+ ← closed: loop markup document/text line by line +/ + /+ ↓ post loop markup document/text +/ debug(objectrelated2) { // check tell_l("blue", line); } - /* + /+ Backmatter: * endnotes * glossary * references / bibliography * book index - */ + +/ obj_im.obj_inline_markup("doc_end_reset", ""); auto en_tuple = notesection.endnote_objects(ocn); static assert(!isTypeTuple!(en_tuple)); auto endnotes = en_tuple[0]; ocn = en_tuple[1]; debug(endnotes) { - writeln(__LINE__, " ", endnotes.length); + writefln( + "%s %s", + __LINE__, + endnotes.length + ); foreach (n; endnotes) { writeln(n); } } - auto contents = contents_arbitrary_max_length_set[0..counter].dup; - auto biblio_unsorted_incomplete = biblio_arr_json[0..count_biblio_entry].dup; - // destroy(biblio_arr_json); - auto biblio = new Bibliography(); - auto biblio_ordered = biblio.bibliography(biblio_unsorted_incomplete); - auto bi = new BookIndexReportSection(); + auto biblio_unsorted_incomplete = biblio_arr_json.dup; + auto biblio = Bibliography(); + auto biblio_ordered = biblio.bibliography(biblio_unsorted_incomplete, bib_arr_json); + auto bi = BookIndexReportSection(); auto bi_tuple = bi.bookindex_build_section(bookindex_unordered_hashes, ocn); static assert(!isTypeTuple!(bi_tuple)); @@ -1739,10 +1766,10 @@ mixin template SiSUdocAbstraction() { spc=""; break; } - writeln( - spc, "* ", " ", + writefln( + "%s* $s\n %s", + spc, strip(o["obj"]), - "\n ", o["attrib"] ); // tell_l("yellow", spc, strip(o["obj"])); diff --git a/lib/sdp/ao_assertions.d b/lib/sdp/ao_assertions.d index 8cdbc87..2aa2c1d 100644 --- a/lib/sdp/ao_assertions.d +++ b/lib/sdp/ao_assertions.d @@ -1,7 +1,7 @@ -/* +/+ assertions ao_assertions.d -*/ ++/ mixin template AssertionsOnMarkupDocumentStructure() { auto assertions_doc_structure(string[string] object, uint[string] lv) { if (lv["h3"] > 0) { @@ -107,7 +107,7 @@ mixin template AssertionsOnMarkupDocumentStructure() { assert(lv["h5"] == 0); assert(lv["h6"] == 0); assert(lv["h7"] == 0); - } else { + } else { // (lv["h0"] >0) assert(lv["h0"] == 0,"error should not enter level A a second time"); } break; diff --git a/lib/sdp/ao_defaults.d b/lib/sdp/ao_defaults.d index 50c1b09..166871b 100644 --- a/lib/sdp/ao_defaults.d +++ b/lib/sdp/ao_defaults.d @@ -1,7 +1,7 @@ -/* +/+ defaults ao_defaults.d -*/ ++/ template SiSUheader() { auto header_make_jsonstr = `{ "make": { @@ -165,7 +165,7 @@ template SiSUheader() { auto config_jsonstr = `{ }`; } -/* regex flags */ +/+ regex flags +/ template SiSUrgxInitFlags() { int[string] flag_type = [ "make_headings" : 0, @@ -247,8 +247,76 @@ template SiSUbiblio() { ]; // is: book, article, magazine, newspaper, blog, other } template InternalMarkup() { - class InternalMarkup { + struct InternalMarkup { auto en_a_o = "【"; auto en_a_c = "】"; auto en_b_o = "〖"; auto en_b_c = "〗"; + // auto segname_prefix_auto_num_extract = "c"; + // auto segname_prefix_auto_num_provide = "s"; + // auto segname_prefix_auto_num_other = "x"; + // auto ocn_id_char = ""; //'o'; now as before; remove for html5 + // auto note = "note_"; + // auto note_ref = "noteref_"; + // auto note_astx = "note_astx_"; + // auto note_ref_astx = "noteref_astx_"; + // auto note_plus = "note_plus_"; + // auto note_ref_plus = "noteref_plus_"; + // auto meta_o = "〔@"; auto meta_c = "〕"; + // auto lv_o_0 = 0; + // auto lv_o_1 = 1; + // auto lv_o_2 = 2; + // auto lv_o_3 = 3; + // auto lv_o_4 = 4; + // auto lv_o_5 = 5; + // auto lv_o_6 = 6; + // auto lv_o_7 = 7; + // auto lv_o_8 = 8; + // auto lv_o_9 = 9; + // auto lv_o = "〔"; auto lv_c = "〕"; + // auto bl_o = "〔"; auto bl_c = "〕"; // block text mark + // auto gr_o = "〔"; auto gr_c = "〕"; // group text mark #REPLACE & RETIRE + // auto id_o = "〔"; auto id_c = "〕"; // object id mark + // auto tc_o = "『"; auto tc_c = "』"; // table row mark #Mx[:tc_c]="』\n" + // auto tc_p = "┆'" + // auto pa_o = "〔"; auto pa_c = "〕"; // affects paragraph mark + // auto mk_o = "〔"; auto mk_c = "〕"; // generic mark + // auto gl_o = "〔"; auto gl_c = "〕"; // glyph + // auto fa_o = "〔"; auto fa_o_c = "¤"; auto fa_c_o = "¤"; auto fa_c = "〕"; + // auto idx_o = "▩"; auto idx_c = "▩"; + // auto nbsp = "░"; // '▭ ' + // auto br_line = "╱"; // lB ▌ 9612 ┘ ¶ + // auto br_nl = "╲"; // lB ▌ 』 ┘ + // auto br_paragraph = "█"; // FB █ 9608 # PP ∥ 8741 #▐ #'┘' #'¶' #FB █ 9608 lB ▌ 9612 RB ▐ 9616 + // auto br_obj = "break_obj"; + // auto br_page_line = "▭"; + // auto br_page = "┼"; + // auto br_page_new = "╋"; + // auto lnk_o = "⌠"; lnk_c = "⌡"; // '⌈' '⌋' '⌠' '⌡' #Mx[:lnk_o= '◁'; Mx[:lnk_c= '▷' #‹ › + // auto url_o = "◘"; auto url_c = "◙"; + // auto rel_o = "⌈"; auto rel_c = "⌋"; + // auto tag_o = "⌊"; auto tag_c = "⌉"; + // auto sm_set_o = "◢"; auto sm_set_c = "◣"; + // auto sm_subset_o = "◢"; auto sm_subset_c = "◣"; + // auto vline = "┆"; // ¦ | + // auto src_bold_o = "!{"; auto src_bold_c = "}!"; + // auto src_italics_o = "/{"; auto src_italics_c = "}/"; + // auto src_underscore_o = "_{"; auto src_underscore_c = "}_"; + // auto src_cite_o = ""{"; auto src_cite_c = "}""; + // auto src_insert_o = "+{"; auto src_insert_c = "}+"; + // auto src_strike_o = "-{"; auto src_strike_c = "}-"; + // auto src_superscript_o = "^{"; auto src_superscript_c = "}^"; + // auto src_subscript_o = ";{"; auto src_subscript_c = "}'" + // auto src_hilite_o = "*{"; auto src_hilite_c = "}*"; + // auto src_monospace_o = "#{"; auto src_monospace_c = "}#"; + // auto srcrgx_bold_o = "\\!\\{"; auto srcrgx_bold_c = "\\}\\!"; + // auto srcrgx_italics_o = "\\/\\{"; auto srcrgx_italics_c = "\\}\\/"; + // auto srcrgx_underscore_o = "_\\{"; auto srcrgx_underscore_c = "\\}_"; + // auto srcrgx_cite_o = "\"\\{"; auto srcrgx_cite_c = "\\}\""; + // auto srcrgx_insert_o = "\\+\\{"; auto srcrgx_insert_c = "\\}\\+"; + // auto srcrgx_strike_o = "\\-\\{"; auto srcrgx_strike_c = "\\}\\-"; + // auto srcrgx_superscript_o = "\\^\\{"; auto srcrgx_superscript_c = "\\}\\^"; + // auto srcrgx_subscript_o = ",\\{"; auto srcrgx_subscript_c = "\\},"; + // auto srcrgx_hilite_o = "\\*\\{"; auto srcrgx_hilite_c = "\\}\\*"; + // auto srcrgx_monospace_o = "\\#\\{"; auto srcrgx_monospace_c = "\\}\\#"; + // ⊹ } } diff --git a/lib/sdp/ao_emitter.d b/lib/sdp/ao_emitter.d index c9b1a7e..7ed9fa8 100644 --- a/lib/sdp/ao_emitter.d +++ b/lib/sdp/ao_emitter.d @@ -1,10 +1,10 @@ -/* +/+ emitters ao_emitters.d -*/ ++/ mixin template Emitters() { mixin InternalMarkup; - class CLI { + struct CLI { string[string] extract_actions(string cmdlnins, string[string] actions) in { } body { @@ -18,7 +18,8 @@ mixin template Emitters() { return actions; } } - class OCNemitter : AssertOCN { + struct OCNemitter { + // class OCNemitter : AssertOCN { int ocn, ocn_; int ocn_emitter(int ocn_status_flag) in { assert(ocn_status_flag <= 2); } @@ -28,17 +29,19 @@ mixin template Emitters() { } else { ocn=0; } + assert(ocn >= 0); return ocn; } invariant() { } } - class ObjAttributes { + struct ObjAttributes { + // class ObjAttributes : AssertObjAttributes { string[string] obj_txt; string para_and_blocks(string obj_txt_in) in { } body { - auto rgx = new Rgx(); + auto rgx = Rgx(); obj_txt["munge"]=obj_txt_in; if (match(obj_txt_in, rgx.para_bullet)) { obj_txt["attrib"] =" \"bullet\": \"true\"," @@ -81,6 +84,7 @@ mixin template Emitters() { obj_txt["attrib"] = " \"use\": \"content\"," ~ " \"of\": \"para\"," ~ " \"is\": \"heading\""; + // obj_txt["struct"]=; return obj_txt["attrib"]; } invariant() { @@ -185,7 +189,8 @@ mixin template Emitters() { invariant() { } } - class ObjInlineMarkupMunge { + struct ObjInlineMarkupMunge { + // struct ObjInlineMarkupMunge : AssertObjInlineMarkup { string[string] obj_txt; int n_foot, n_foot_reg, n_foot_sp_asterisk, n_foot_sp_plus; string obj_txt_out, tail, note; @@ -198,8 +203,8 @@ mixin template Emitters() { private auto object_notes_(string obj_txt_in) in { } body { - auto rgx = new Rgx(); - auto mkup = new InternalMarkup(); + auto rgx = Rgx(); + auto mkup = InternalMarkup(); obj_txt_out = ""; tail = ""; obj_txt_in = replaceAll( @@ -237,6 +242,11 @@ mixin template Emitters() { (mkup.en_a_o ~ to!string(n_foot)) ); tail = m.post; + // if (!empty(m.post)) { + // tail = m.post; + // } else { + // tail = ""; + // } } } else { obj_txt_out = obj_txt_in; @@ -257,7 +267,7 @@ mixin template Emitters() { string para(string obj_txt_in) in { } body { - auto rgx = new Rgx(); + auto rgx = Rgx(); obj_txt["munge"]=obj_txt_in; obj_txt["munge"]=replaceFirst(obj_txt["munge"], rgx.para_attribs, ""); obj_txt["munge"]=replaceFirst(obj_txt["munge"], rgx.ocn_off_all, ""); @@ -273,7 +283,7 @@ mixin template Emitters() { string heading(string obj_txt_in) in { } body { - auto rgx = new Rgx(); + auto rgx = Rgx(); obj_txt["munge"]=obj_txt_in; obj_txt["munge"]=replaceFirst(obj_txt["munge"], rgx.heading, ""); obj_txt["munge"]=replaceFirst(obj_txt["munge"], rgx.ocn_off_all, ""); @@ -364,8 +374,9 @@ mixin template Emitters() { invariant() { } } - class ObjInlineMarkup : AssertObjInlineMarkup { - auto munge = new ObjInlineMarkupMunge(); + struct ObjInlineMarkup { + // struct ObjInlineMarkup : AssertObjInlineMarkup { + auto munge = ObjInlineMarkupMunge(); string[string] obj_txt; string obj_inline_markup(string obj_is_, string obj_raw) in { } @@ -419,13 +430,17 @@ mixin template Emitters() { invariant() { } } - class ObjAttrib : AssertObjAttrib { - auto attrib = new ObjAttributes(); + struct ObjAttrib { + // struct ObjAttrib : AssertObjAttrib { + // auto sink = appender!(char[])(); + auto attrib = ObjAttributes(); string[string] obj_attrib; string obj_attributes(string obj_is_, string obj_raw, string node) in { } body { + // string s = "{ \"language\": \"D\", \"rating\": 3.14, \"code\": \"42\" }"; scope(exit) { + // destroy(obj_is_); destroy(obj_raw); destroy(node); } @@ -493,20 +508,24 @@ mixin template Emitters() { obj_attrib["json"] = oa_j.toString(); debug(structattrib) { if (oa_j["is"].str() == "heading") { + // writeln(__LINE__); writeln(obj_attrib["json"]); + // writeln(node); writeln( "is: ", oa_j["is"].str(), "; ocn: ", oa_j["ocn"].integer() ); } } + // obj_attrib["json"]="{}"; return obj_attrib["json"]; } invariant() { } } - class HeaderDocMetadataMakeJson { - auto rgx = new Rgx(); + struct HeaderDocMetadataMakeJson { + // class HeaderMetadataMakeHash : AssertHeaderMetadataMakeJson { + auto rgx = Rgx(); string hm, hs; auto header_metadata_and_make_jsonstr( string header, @@ -678,6 +697,15 @@ mixin template Emitters() { case "links": destroy(hm); destroy(hs); + // if (match(hs, rgx.subhead_links)) { + // if (dochead_metadata[hm][hs].type() == JSON_TYPE.STRING) { + // dochead_metadata[hm][hs].str = to!string(s.captures[2]); + // } + // } else { + // writeln("not a valid header type:", hm, ":", hs); + // destroy(hm); + // destroy(hs); + // } break; default: break; @@ -694,9 +722,12 @@ mixin template Emitters() { static assert(!isTypeTuple!(t)); return t; } + // invariant() { + // } } class HeaderMetadataMakeHash { - auto rgx = new Rgx(); + // class HeaderMetadataMakeHash : AssertHeaderMetadataMakeHash { + auto rgx = Rgx(); string header_main; string[string] head; string[string] header_topic_hash(string header) @@ -743,7 +774,8 @@ mixin template Emitters() { invariant() { } } - class BookIndexNuggetHash : AssertBookIndexNuggetHash { + struct BookIndexNuggetHash { + // class BookIndexNuggetHash : AssertBookIndexNuggetHash { string main_term, sub_term, sub_term_bits; uint ocn_offset, ocn_endpoint; string[] ocns; @@ -751,9 +783,19 @@ mixin template Emitters() { string[][string][string] hash_nugget; string[] bi_main_terms_split_arr; string[][string][string] bookindex_nugget_hash(string bookindex, int ocn) - in { } + in { + debug(bookindexraw) { + mixin ScreenTxtColors; + if (!bookindex.empty) { + writeln( + scr_txt_color["blue"], "* [bookindex] ", scr_txt_color["off"], + "[", to!string(ocn), "] ", bookindex + ); + } + } + } body { - auto rgx = new Rgx(); + auto rgx = Rgx(); if (!bookindex.empty) { auto bi_main_terms_split_arr = split(bookindex, rgx.bi_main_terms_split); @@ -796,15 +838,18 @@ mixin template Emitters() { ocns=null; } } + // ocns=null; } } hash_nugget = bi; + // bi=null; // bi.init; // use to empty for each next object; else, harvest hashes at the end of the document return hash_nugget; } invariant() { } } - class BookIndexReport { + struct BookIndexReport { + // class BookIndexReport : AssertBookIndexReport { int mkn, skn; auto bookindex_report_sorted( string[][string][string] bookindex_unordered_hashes @@ -822,13 +867,15 @@ mixin template Emitters() { to!string(bookindex_unordered_hashes[mainkey][subkey]) ); } + // bookindex_the[mkn][mainkey][skn][subkey] ~= (bookindex_unordered_hashes[mainkey][subkey]); skn++; } mkn++; } + // return bookindex_the; } } - class BookIndexReportIndent { + struct BookIndexReportIndent { int mkn, skn; auto bookindex_report_indented( string[][string][string] bookindex_unordered_hashes @@ -848,16 +895,17 @@ mixin template Emitters() { bookindex_unordered_hashes[mainkey][subkey] )); } + // bookindex_the[mkn][mainkey][skn][subkey] ~= (bookindex_unordered_hashes[mainkey][subkey]); skn++; } mkn++; } } } - class BookIndexReportSection { + struct BookIndexReportSection { mixin ObjectSetters; int mkn, skn; - auto rgx = new Rgx(); + auto rgx = Rgx(); auto bookindex_write_section( string[][string][string] bookindex_unordered_hashes ) { @@ -894,19 +942,20 @@ mixin template Emitters() { string attrib; string indent_first; string indent_second; - auto set_oa = new ObjectAbstractSet(); + auto set_oa = ObjectAbstractSet(); auto mainkeys = bookindex_unordered_hashes.byKey.array.sort().release; string bi_tmp; - string[string][1024] bookindex_arbitrary_max_length_set; + string[string][] bookindex; writeln(mainkeys.length); + // B~ Book Index type_heading=1; bi_tmp = "Book Index"; attrib=""; lev="B"; lvn="1"; lcn="1"; - bookindex_arbitrary_max_length_set[mkn] = + bookindex ~= set_oa.contents_heading( type_heading, bi_tmp, @@ -918,13 +967,14 @@ mixin template Emitters() { ); ocn++; mkn++; + // 1~ Index type_heading=1; bi_tmp = "Index"; attrib=""; lev="1"; lvn="4"; lcn="2"; - bookindex_arbitrary_max_length_set[mkn] = + bookindex ~= set_oa.contents_heading( type_heading, bi_tmp, @@ -938,6 +988,7 @@ mixin template Emitters() { mkn++; foreach (mainkey; mainkeys) { bi_tmp = "!{" ~ mainkey ~ "}! "; + // bi_tmp = "_0_1 !{" ~ mainkey ~ "}! "; foreach (ref_; bookindex_unordered_hashes[mainkey]["_a"]) { auto go = replaceAll(ref_, rgx.book_index_go, "$1"); bi_tmp ~= " {" ~ ref_ ~ "}#" ~ go ~ ", "; @@ -961,7 +1012,7 @@ mixin template Emitters() { indent_first = "0"; indent_second = "1"; attrib=""; - bookindex_arbitrary_max_length_set[mkn] = + bookindex ~= set_oa.contents_para( type, bi_tmp, @@ -974,8 +1025,6 @@ mixin template Emitters() { ocn++; mkn++; } - auto bookindex = - bookindex_arbitrary_max_length_set[0..mkn].dup; auto t = tuple(bookindex, ocn); return t; } @@ -985,7 +1034,8 @@ mixin template Emitters() { auto mainkeys = bookindex_unordered_hashes.byKey.array.sort().release; string bi_tmp; - string[1024] bookindex_arbitrary_max_length_set; + string[] bookindex; + // int bi_num; writeln(mainkeys.length); foreach (mainkey; mainkeys) { bi_tmp = "_0_1 !{" ~ mainkey ~ "}! "; @@ -999,6 +1049,7 @@ mixin template Emitters() { bookindex_unordered_hashes[mainkey].byKey.array.sort().release; foreach (subkey; subkeys) { bi_tmp ~= subkey ~ ", "; + // bi_tmp ~= " " ~ subkey ~ ", "; foreach (ref_; bookindex_unordered_hashes[mainkey][subkey]) { auto go = replaceAll(ref_, rgx.book_index_go, "$1"); bi_tmp ~= " {" ~ ref_ ~ "}#" ~ go ~ ", "; @@ -1007,23 +1058,21 @@ mixin template Emitters() { skn++; } bi_tmp = replaceFirst(bi_tmp, rgx.trailing_linebreak, ""); - bookindex_arbitrary_max_length_set[mkn] = bi_tmp; + bookindex ~= bi_tmp; mkn++; } - auto bookindex = - bookindex_arbitrary_max_length_set[0..mkn].dup; return bookindex; } } - class NotesSection { + struct NotesSection { mixin ObjectSetters; string object_notes; - int previous_count; + ulong previous_count; int mkn; - auto rgx = new Rgx(); + auto rgx = Rgx(); private auto gather_notes_for_endnote_section( - string[string][131072] contents_arbitrary_max_length_set, - int counter + string[string][] contents_arbitrary_max_length_set, + ulong counter ) in { // endnotes/ footnotes for @@ -1046,6 +1095,7 @@ mixin template Emitters() { writeln( "{^{", m.captures[1], ".}^}#noteref_", m.captures[1], " ", m.captures[2]); // sometimes need segment name (segmented html & epub) + // writeln("{^{", m.captures[1], ".}^}#", contents_arbitrary_max_length_set[counter]["ocn"], " ", m.captures[2]); } object_notes ~= "{^{" ~ m.captures[1] ~ ".}^}#noteref_" ~ @@ -1067,21 +1117,23 @@ mixin template Emitters() { in { } body { - auto set_oa = new ObjectAbstractSet(); - string[string][1024] endnotes_arbitrary_max_length_set; + auto set_oa = ObjectAbstractSet(); + string[string][] endnotes; auto endnotes_ = gathered_notes(); + // auto endnotes_ = (split(object_notes, rgx.break_string))[0..$-1]; string type; int type_heading; string lev, lvn, lcn; string attrib; string indent_first; string indent_second; + // B~ Endnotes type_heading=1; attrib=""; lev="B"; lvn="1"; lcn="1"; - endnotes_arbitrary_max_length_set[mkn] = + endnotes ~= set_oa.contents_heading( type_heading, "Endnotes", @@ -1093,12 +1145,13 @@ mixin template Emitters() { ); ocn++; mkn++; + // 1~ Endnotes type_heading=1; attrib=""; lev="1"; lvn="4"; lcn="2"; - endnotes_arbitrary_max_length_set[mkn] = + endnotes ~= set_oa.contents_heading( type_heading, "Endnotes", @@ -1116,7 +1169,7 @@ mixin template Emitters() { indent_first = "0"; indent_second = "0"; attrib=""; - endnotes_arbitrary_max_length_set[mkn] = + endnotes ~= set_oa.contents_para( type, endnote, @@ -1129,28 +1182,27 @@ mixin template Emitters() { ocn++; mkn++; } - auto endnotes = - endnotes_arbitrary_max_length_set[0..mkn].dup; auto t = tuple(endnotes, ocn); return t; } } - class Bibliography { - public JSONValue[] bibliography(string[] biblio_unsorted_incomplete) + struct Bibliography { + public JSONValue[] bibliography(ref string[] biblio_unsorted_incomplete, ref JSONValue[] bib_arr_json) in { } body { JSONValue[] biblio_unsorted = - biblio_unsorted_complete(biblio_unsorted_incomplete); + biblio_unsorted_complete(biblio_unsorted_incomplete, bib_arr_json); JSONValue[] biblio_sorted = biblio_sort(biblio_unsorted); biblio_debug(biblio_sorted); return biblio_sorted; } final private JSONValue[] biblio_unsorted_complete( - string[] biblio_unordered + string[] biblio_unordered, + ref JSONValue[] bib_arr_json ) { - JSONValue[1024] bib_arr_json; - int count_biblio_entry; - count_biblio_entry=0; + // JSONValue[] bib_arr_json; + // int count_biblio_entry; + // count_biblio_entry=0; // watch foreach (bibent; biblio_unordered) { // update bib to include deemed_author, needed for: // sort_bibliography_array_by_deemed_author_year_title @@ -1169,12 +1221,15 @@ mixin template Emitters() { "; " ~ j["fulltitle"].str ); + // bib[count_biblio_entry] = j.toString(); } - bib_arr_json[count_biblio_entry] = j; - count_biblio_entry++; + bib_arr_json ~= j; + // count_biblio_entry++; + // bib_arr_json[count_biblio_entry] = j; + // count_biblio_entry++; } JSONValue[] biblio_unsorted_array_of_json_objects = - bib_arr_json[0..(count_biblio_entry)].dup; + bib_arr_json.dup; return biblio_unsorted_array_of_json_objects; } final private JSONValue[] biblio_sort(JSONValue[] biblio_unordered) { @@ -1187,6 +1242,7 @@ mixin template Emitters() { foreach (j; biblio_sorted) { if (!empty(j["fulltitle"].str)) { writeln(j["sortby_deemed_author_year_title"]); + // writeln(j["deemed_author"], " (", j["author"], ") ", j["fulltitle"]); } } } @@ -1202,7 +1258,8 @@ mixin template Emitters() { } } } - class NodeStructureMetadata : AssertNodeJSON { + struct NodeStructureMetadata { + // class NodeStructureMetadata : AssertNodeJSON { int lv, lv0, lv1, lv2, lv3, lv4, lv5, lv6, lv7; uint ocn; uint[string] p_; // p_ parent_ @@ -1215,9 +1272,16 @@ mixin template Emitters() { string is_ ) in { - auto rgx = new Rgx(); + auto rgx = Rgx(); + assert(is_ != "heading"); + assert(to!int(ocn_) >= 0); } body { + // scope(failure) { + // writeln(__FILE__, ":", __LINE__, " failed here:"); + // writeln(" is : ", is_); + // writeln(" node: ", node); + // } assert(is_ != "heading"); // should not be necessary assert(to!int(ocn_) >= 0); // should not be necessary uint ocn=to!uint(ocn_); @@ -1239,6 +1303,18 @@ mixin template Emitters() { ", \"parent_lvn\": " ~ to!string(p_["lvn"]) ~ " }" ); + debug(node) { + mixin ScreenTxtColors; + if (match(lvn, rgx.levels_numbered_headings)) { + writeln(scr_txt_marker["yellow"], to!string(node)); + } else { + writeln(scr_txt_marker["white"], to!string(node)); + } + } + JSONValue j = parseJSON(node); + assert(j["parent_lvn"].integer >= 4); + assert(j["parent_lvn"].integer <= 7); + assert(j["parent_ocn"].integer >= 0); return node; } invariant() { @@ -1252,9 +1328,28 @@ mixin template Emitters() { string is_ ) in { - auto rgx = new Rgx(); + auto rgx = Rgx(); + assert(is_ == "heading"); + assert(to!uint(ocn_) >= 0); + assert( + match(lvn, rgx.levels_numbered), + ("not a valid heading level: " ~ lvn ~ " at " ~ to!string(ocn_)) + ); + // assert(to!uint(ocn_) >= 0); + if (match(lvn, rgx.levels_numbered)) { + if (to!uint(lvn) == 0) { + assert(to!uint(ocn_) == 1); + // writeln(lvn); + } + } } body { + // scope(failure) { + // writeln(__FILE__, ":", __LINE__, " failed here:"); + // writeln(" is : ", is_); + // writeln(" node: ", node); + // } + auto rgx = Rgx(); uint ocn=to!uint(ocn_); switch (lvn) { // switch (to!string(lv)) { case "0": @@ -1306,6 +1401,15 @@ mixin template Emitters() { p_["lvn"] = 6; p_["ocn"] = lv6; break; default: + // if (lv7 > 0) { + // p_["lvn"] = 7; p_["ocn"] = lv7; + // } else if (lv6 > 0) { + // p_["lvn"] = 6; p_["ocn"] = lv6; + // } else if (lv5 > 0) { + // p_["lvn"] = 5; p_["ocn"] = lv5; + // } else { + // p_["lvn"] = 4; p_["ocn"] = lv4; + // } break; } node=("{ " ~ @@ -1319,6 +1423,54 @@ mixin template Emitters() { ", \"parent_lvn\": " ~ to!string(p_["lvn"]) ~ " }" ); + debug(heading) { + mixin ScreenTxtColors; + if (match(lvn, rgx.levels_numbered_headings)) { + writeln(scr_txt_marker["yellow"], to!string(node)); + } + } + debug(node) { + mixin ScreenTxtColors; + if (match(lvn, rgx.levels_numbered_headings)) { + writeln(scr_txt_marker["yellow"], to!string(node)); + } else { + writeln(scr_txt_marker["white"], to!string(node)); + } + } + JSONValue j = parseJSON(node); + assert(j["parent_lvn"].integer <= 7); + assert(j["parent_ocn"].integer >= 0); + if (match(lvn, rgx.levels_numbered_headings)) { + assert(j["lvn"].integer <= 7); + assert(j["ocn"].integer >= 0); + if (j["parent_lvn"].integer > 0) { + assert(j["parent_lvn"].integer < j["lvn"].integer); + if (j["ocn"].integer != 0) { + assert(j["parent_ocn"].integer < j["ocn"].integer); + } + } + if (j["lvn"].integer == 0) { + assert(j["parent_lvn"].integer == 0); + } else if (j["lvn"].integer == 1) { + assert(j["parent_lvn"].integer == 0); + } else if (j["lvn"].integer == 2) { + assert(j["parent_lvn"].integer == 1); + } else if (j["lvn"].integer == 3) { + assert(j["parent_lvn"].integer == 2); + } else if (j["lvn"].integer == 4) { + assert(j["parent_lvn"].integer <= 3); + } else if (j["lvn"].integer == 5) { + assert(j["parent_lvn"].integer == 4); + } else if (j["lvn"].integer == 6) { + assert(j["parent_lvn"].integer == 5); + } else if (j["lvn"].integer == 7) { + assert(j["parent_lvn"].integer == 6); + } else if (j["lvn"].integer == 8) { + // writeln(j["parent_lvn"].integer); + // assert(j["parent_lvn"].integer >= 4); + // assert(j["parent_lvn"].integer <= 7); + } + } return node; } invariant() { diff --git a/lib/sdp/ao_interface.d b/lib/sdp/ao_interface.d deleted file mode 100644 index b50bee7..0000000 --- a/lib/sdp/ao_interface.d +++ /dev/null @@ -1,144 +0,0 @@ -/* - interface - ao_interface.d -*/ -mixin template Interfaces() { - interface AssertOCN { - int ocn_emitter(int ocn_status_flag) - in { assert(ocn_status_flag <= 2); } - out(ocn) { assert(ocn >= 0); } - } - interface AssertObjInlineMarkup { - string obj_inline_markup(string obj_raw, string obj_type_) - in { - } - out(inline_markup) { - } - } - interface AssertObjAttrib { - string obj_attributes(string obj_raw, string node, string obj_type_) - in { - } - out(obj_attrib_json) { - } - } - interface AssertBookIndexNuggetHash { - string[][string][string] bookindex_nugget_hash(string bookindex, int ocn) - in { - debug(bookindexraw) { - mixin ScreenTxtColors; - if (!bookindex.empty) { - writeln( - scr_txt_color["blue"], "* [bookindex] ", scr_txt_color["off"], - "[", to!string(ocn), "] ", bookindex - ); - } - } - } - out(hash_nugget) { - } - } - interface AssertBookIndexReport { - string[][string][][string][] bookindex_nugget_hash(string[][string][string] bookindex_unordered_hashes) - in { - } - } - interface AssertNodeJSON { - string node_emitter( - string lvn, - int ocn_, - int counter_, - int pointer_, - string is_ - ) - in { - auto rgx = new Rgx(); - assert(is_ != "heading"); - assert(to!int(ocn_) >= 0); - } - out(node) { - debug(node) { - mixin ScreenTxtColors; - if (match(lvn, rgx.levels_numbered_headings)) { - writeln(scr_txt_marker["yellow"], to!string(node)); - } else { - writeln(scr_txt_marker["white"], to!string(node)); - } - } - JSONValue j = parseJSON(node); - assert(j["parent_lvn"].integer >= 4); - assert(j["parent_lvn"].integer <= 7); - assert(j["parent_ocn"].integer >= 0); - } - string node_emitter_heading( - string lvn, - string lcn, - int ocn_, - int counter_, - int pointer_, - string is_ - ) - in { - auto rgx = new Rgx(); - assert(is_ == "heading"); - assert(to!uint(ocn_) >= 0); - assert( - match(lvn, rgx.levels_numbered), - ("not a valid heading level: " ~ lvn ~ " at " ~ to!string(ocn_)) - ); - if (match(lvn, rgx.levels_numbered)) { - if (to!uint(lvn) == 0) { - assert(to!uint(ocn_) == 1); - } - } - } - out(node) { - auto rgx = new Rgx(); - debug(heading) { - mixin ScreenTxtColors; - if (match(lvn, rgx.levels_numbered_headings)) { - writeln(scr_txt_marker["yellow"], to!string(node)); - } - } - debug(node) { - mixin ScreenTxtColors; - if (match(lvn, rgx.levels_numbered_headings)) { - writeln(scr_txt_marker["yellow"], to!string(node)); - } else { - writeln(scr_txt_marker["white"], to!string(node)); - } - } - JSONValue j = parseJSON(node); - assert(j["parent_lvn"].integer <= 7); - assert(j["parent_ocn"].integer >= 0); - if (match(lvn, rgx.levels_numbered_headings)) { - assert(j["lvn"].integer <= 7); - assert(j["ocn"].integer >= 0); - if (j["parent_lvn"].integer > 0) { - assert(j["parent_lvn"].integer < j["lvn"].integer); - if (j["ocn"].integer != 0) { - assert(j["parent_ocn"].integer < j["ocn"].integer); - } - } - if (j["lvn"].integer == 0) { - assert(j["parent_lvn"].integer == 0); - } else if (j["lvn"].integer == 1) { - assert(j["parent_lvn"].integer == 0); - } else if (j["lvn"].integer == 2) { - assert(j["parent_lvn"].integer == 1); - } else if (j["lvn"].integer == 3) { - assert(j["parent_lvn"].integer == 2); - } else if (j["lvn"].integer == 4) { - assert(j["parent_lvn"].integer <= 3); - } else if (j["lvn"].integer == 5) { - assert(j["parent_lvn"].integer == 4); - } else if (j["lvn"].integer == 6) { - assert(j["parent_lvn"].integer == 5); - } else if (j["lvn"].integer == 7) { - assert(j["parent_lvn"].integer == 6); - } else if (j["lvn"].integer == 8) { - } - } - } - } -} diff --git a/lib/sdp/ao_object_setter.d b/lib/sdp/ao_object_setter.d index ff76143..ce4611d 100644 --- a/lib/sdp/ao_object_setter.d +++ b/lib/sdp/ao_object_setter.d @@ -1,10 +1,21 @@ -/* +/+ object setter ao_object_setter.d -*/ ++/ mixin template ObjectSetters() { - class ObjectAbstractSet { + struct ObjectAbstractSet { import std.conv : to; + mixin Structs; + ObjComposite contents_comment_new(in string object) { + ObjComposite object_set; + object_set.use = "comment"; + object_set.of = "comment"; + object_set.is_a = "comment"; + object_set.object = object; + // does not have .attrib; + // does not have .ocn + return object_set; + } string[string] contents_comment(in string object) { string[string] object_set; object_set["use"] = "comment"; @@ -13,6 +24,28 @@ mixin template ObjectSetters() { object_set["obj"] = object; return object_set; } + ObjComposite contents_heading_new( + in int type, + in string object, + in string attrib, + in int ocn, + in string lev, + in string lvn, + in string lcn, + ) { + ObjComposite object_set; + object_set.use = "content"; + object_set.of = "para"; + object_set.is_a = "heading"; + object_set.object = object; + object_set.ocn = (ocn==0) ? "" : to!string(ocn); + object_set.attrib = attrib; + object_set.heading.type = to!string(type); + object_set.heading.lev = to!string(lev); + object_set.heading.lvn = to!string(lvn); + object_set.heading.lcn = to!string(lcn); + return object_set; + } string[string] contents_heading( in int type, in string object, @@ -35,8 +68,29 @@ mixin template ObjectSetters() { object_set["attrib"] = attrib; return object_set; } + ObjComposite contents_para_new( + in string is_a, + in string object, + in string attrib, + in int ocn, + in string indent_first, + in string indent_second, + in bool bullet + ) { + ObjComposite object_set; + object_set.use = "content"; + object_set.of = "para"; + object_set.is_a = "heading"; + object_set.object = object; + object_set.ocn = (ocn==0) ? "" : to!string(ocn); + object_set.attrib = attrib; + object_set.para.indent_first = indent_first; + object_set.para.indent_second = indent_second; + object_set.para.bullet = to!string(bullet); + return object_set; + } string[string] contents_para( - in string type, + in string is_a, in string object, in string attrib, in int ocn, @@ -47,7 +101,7 @@ mixin template ObjectSetters() { string[string] object_set; object_set["use"] = "content"; object_set["of"] = "para"; - object_set["is"] = type; + object_set["is"] = is_a; object_set["obj"] = object; object_set["ocn"] = (ocn==0) ? "" : to!string(ocn); object_set["indent_first"] = indent_first; @@ -56,6 +110,22 @@ mixin template ObjectSetters() { object_set["attrib"] = attrib; return object_set; } + ObjComposite contents_block_new( + in string type, + in string object, + in string attrib, + in int ocn + ) { + ObjComposite object_set; + // does not have .attrib; + object_set.use = "content"; + object_set.of = "block"; + object_set.is_a = type; + object_set.object = object; + object_set.ocn = (ocn==0) ? "" : to!string(ocn); + object_set.attrib = attrib; + return object_set; + } string[string] contents_block( in string type, in string object, @@ -71,6 +141,22 @@ mixin template ObjectSetters() { object_set["attrib"] = attrib; return object_set; } + ObjComposite contents_block_ocn_string_new( + in string type, + in string object, + in string ocn, + in string node + ) { + ObjComposite object_set; + object_set.use = "content"; + object_set.of = "block"; + object_set.is_a = type; + object_set.object = object; + object_set.ocn = ocn; + object_set.block_ocn_string.node = node; + // object_set.attrib = attrib; + return object_set; + } string[string] contents_block_ocn_string( in string type, in string object, diff --git a/lib/sdp/ao_output_debugs.d b/lib/sdp/ao_output_debugs.d index c6bdfe1..d2c2c73 100644 --- a/lib/sdp/ao_output_debugs.d +++ b/lib/sdp/ao_output_debugs.d @@ -1,9 +1,9 @@ -/* +/+ output debugs ao_output_debugs.d -*/ ++/ template SiSUoutputDebugs() { - class SDPoutputDebugs { + struct SDPoutputDebugs { auto abstract_doc_source_debugs( string[string][] contents, JSONValue[string] docmake, @@ -15,13 +15,19 @@ template SiSUoutputDebugs() { ) { mixin RgxInit; mixin ScreenTxtColors; - auto rgx = new Rgx(); + auto rgx = Rgx(); debug(parent) { - writeln(__FILE__, ":", __LINE__); + writefln( + "%s:%s", + __FILE__, + __LINE__, + ); foreach (obj; contents) { if (obj["use"] == "content") { if (obj["is"] == "heading") { - writeln(scr_txt_marker["cyan"], + writefln( + "%s%s node: %s heading: %s %s", + scr_txt_marker["cyan"], obj["ocn"], " node: ", obj["node"], " heading: ", obj["lvn"], @@ -32,15 +38,38 @@ template SiSUoutputDebugs() { } } } + debug(dumpdoc) { + writefln( + "%s\n%s:%s", + "-------------------------------", + __FILE__, + __LINE__, + ); + foreach (obj; contents) { + if (obj["use"] == "content") { + writefln( + "[%s][%s]\n%s", + obj["ocn"], + obj["is"], + obj["obj"] + ); + } + } + } debug(objects) { - writeln("-------------------------------"); - writeln(__FILE__, ":", __LINE__); + writefln( + "%s\n%s:%s", + "-------------------------------", + __FILE__, + __LINE__, + ); foreach (obj; contents) { if (obj["use"] == "content") { - writeln( + writefln( + "%s* [%s][%s] %s%s", scr_txt_color["green"], - "* [", obj["ocn"], "]", - "[", obj["is"], "] ", + obj["ocn"], + obj["is"], scr_txt_color["off"], obj["obj"] ); @@ -48,17 +77,21 @@ template SiSUoutputDebugs() { } } debug(headermakejson) { - writeln("document header, metadata & make instructions:"); - writeln(dochead); - writeln(pointer_head_main); + writefln( + "%s\n%s\n%s", + "document header, metadata & make instructions:", + dochead, + pointer_head_main, + ); foreach (main_header; pointer_head_main) { switch (main_header) { case "make": foreach (sub_header; pointer_head_sub_make) { if (to!string(dochead[main_header][sub_header]).length > 2) { - writeln( - main_header, ":", - sub_header, ": ", + writefln( + "%s:%s: %s", + main_header, + sub_header, dochead[main_header][sub_header] ); } @@ -70,16 +103,21 @@ template SiSUoutputDebugs() { } } debug(headermetadatajson) { - writeln("document header, metadata & make instructions:"); - writeln(dochead); - writeln(pointer_head_main); + writefln( + "%s\n%s\n%s", + "document header, metadata & make instructions:", + dochead, + pointer_head_main, + ); foreach (main_header; pointer_head_main) { switch (main_header) { case "creator": foreach (sub_header; pointer_head_sub_creator) { if (to!string(dochead[main_header][sub_header]).length > 2) { - writeln(main_header, ":", - sub_header, ": ", + writefln( + "%s:%s: %s", + main_header, + sub_header, dochead[main_header][sub_header] ); } @@ -88,8 +126,10 @@ template SiSUoutputDebugs() { case "title": foreach (sub_header; pointer_head_sub_title) { if (to!string(dochead[main_header][sub_header]).length > 2) { - writeln(main_header, ":", - sub_header, ": ", + writefln( + "%s:%s: %s", + main_header, + sub_header, dochead[main_header][sub_header] ); } @@ -98,8 +138,10 @@ template SiSUoutputDebugs() { case "rights": foreach (sub_header; pointer_head_sub_rights) { if (to!string(dochead[main_header][sub_header]).length > 2) { - writeln(main_header, ":", - sub_header, ": ", + writefln( + "%s:%s: %s", + main_header, + sub_header, dochead[main_header][sub_header] ); } @@ -108,8 +150,10 @@ template SiSUoutputDebugs() { case "date": foreach (sub_header; pointer_head_sub_date) { if (to!string(dochead[main_header][sub_header]).length > 2) { - writeln(main_header, ":", - sub_header, ": ", + writefln( + "%s:%s: %s", + main_header, + sub_header, dochead[main_header][sub_header] ); } @@ -118,8 +162,10 @@ template SiSUoutputDebugs() { case "original": foreach (sub_header; pointer_head_sub_original) { if (to!string(dochead[main_header][sub_header]).length > 2) { - writeln(main_header, ":", - sub_header, ": ", + writefln( + "%s:%s: %s", + main_header, + sub_header, dochead[main_header][sub_header] ); } @@ -128,8 +174,10 @@ template SiSUoutputDebugs() { case "classify": foreach (sub_header; pointer_head_sub_classify) { if (to!string(dochead[main_header][sub_header]).length > 2) { - writeln(main_header, ":", - sub_header, ": ", + writefln( + "%s:%s: %s", + main_header, + sub_header, dochead[main_header][sub_header] ); } @@ -138,8 +186,10 @@ template SiSUoutputDebugs() { case "identifier": foreach (sub_header; pointer_head_sub_identifier) { if (to!string(dochead[main_header][sub_header]).length > 2) { - writeln(main_header, ":", - sub_header, ": ", + writefln( + "%s:%s: %s", + main_header, + sub_header, dochead[main_header][sub_header] ); } @@ -148,8 +198,10 @@ template SiSUoutputDebugs() { case "notes": foreach (sub_header; pointer_head_sub_notes) { if (to!string(dochead[main_header][sub_header]).length > 2) { - writeln(main_header, ":", - sub_header, ": ", + writefln( + "%s:%s: %s", + main_header, + sub_header, dochead[main_header][sub_header] ); } @@ -158,8 +210,10 @@ template SiSUoutputDebugs() { case "publisher": foreach (sub_header; pointer_head_sub_publisher) { if (to!string(dochead[main_header][sub_header]).length > 2) { - writeln(main_header, ":", - sub_header, ": ", + writefln( + "%s:%s: %s", + main_header, + sub_header, dochead[main_header][sub_header] ); } @@ -171,9 +225,13 @@ template SiSUoutputDebugs() { } } debug(bookindex) { - writeln("-------------------------------"); - writeln(__FILE__, ":", __LINE__); - auto bookindex = new BookIndexReport(); + writefln( + "%s\n%s:%s", + "-------------------------------", + __FILE__, + __LINE__, + ); + auto bookindex = BookIndexReport(); bookindex.bookindex_report_sorted(bookindex_unordered_hashes); } debug(summary) { @@ -190,28 +248,39 @@ template SiSUoutputDebugs() { } } debug(headings) { - writeln("-------------------------------"); - writeln(__FILE__, ":", __LINE__); + writefln( + "%s\n%s:%s", + "-------------------------------", + __FILE__, + __LINE__, + ); foreach (obj; contents) { if (obj["is"] == "heading") { - writeln( + writefln( + "%s%s~ [%s] %s", scr_txt_marker["yellow"], - obj["lev"], "~ ", - "[", obj["ocn"], "] ", + obj["lev"], + obj["ocn"], + // "[", obj["is"], "] ", obj["obj"] ); } } } - writeln( + writefln( + "%s%s%s\n%s\n%s%s\n%s%s\n%s%s\n%s:%s", scr_txt_color["green"], "-------------------------------", scr_txt_color["off"], - "\n", fn_src, - "\nlength contents array: ", contents.length, - "\nlast ocn: ", check["last_ocn"], - "\nlength bookindex: ", bookindex_unordered_hashes.length, - "\n", __FILE__, ":", __LINE__, + fn_src, + "length contents array: ", + contents.length, + "last ocn: ", + check["last_ocn"], + "length bookindex: ", + bookindex_unordered_hashes.length, + __FILE__, + __LINE__, ); debug(checkdoc) { if (auto mfn=match(fn_src, rgx.src_fn)) { diff --git a/lib/sdp/ao_read_markup_source.d b/lib/sdp/ao_read_markup_source.d index 1c574ea..6eaecbe 100644 --- a/lib/sdp/ao_read_markup_source.d +++ b/lib/sdp/ao_read_markup_source.d @@ -1,10 +1,10 @@ -/* +/+ read markup source ao_read_markup_source.d -*/ ++/ mixin template SiSUmarkupRaw() { - class MarkupRaw { - auto rgx = new Rgx(); + struct MarkupRaw { + auto rgx = Rgx(); final private string markupSourceString(in char[] fn_src) { enforce( exists(fn_src)!=0, diff --git a/lib/sdp/ao_rgx.d b/lib/sdp/ao_rgx.d index 7050d25..4c36ff9 100644 --- a/lib/sdp/ao_rgx.d +++ b/lib/sdp/ao_rgx.d @@ -1,10 +1,10 @@ -/* +/+ regex ao_rgx.d -*/ ++/ mixin template RgxInit() { - class Rgx { - /* misc */ + struct Rgx { + /+ misc +/ static flag_action = ctRegex!(`^(--[a-z][a-z0-9-]+)$`); static flag_action_str = ctRegex!(` (--[a-z][a-z0-9-]+)`); static src_pth = ctRegex!(`^([a-zA-Z0-9._-]+/)*([a-zA-Z0-9._-]+[.]ss[tm])$`); @@ -25,19 +25,19 @@ mixin template RgxInit() { static levels_markup = ctRegex!(`^[A-D1-4]$`); static levels_numbered = ctRegex!(`^[0-9]$`); static levels_numbered_headings = ctRegex!(`^[0-7]$`); - /* insert markup file */ + /+ insert markup file +/ static insert_src_fn_ssi_or_sst = ctRegex!(`^<<\s*(?P<path>[a-zA-Z0-9._-]+/)*(?P<filename>[a-zA-Z0-9._-]+[.]ss[ti])$`); // static insert_ssi_or_sst_fn = ctRegex!(`^<<\s*[a-zA-Z0-9._-]+[.]ss[ti]`); - /* comments */ + /+ comments +/ static comment = ctRegex!(`^%+ `); - /* header */ + /+ header +/ static header = ctRegex!(`^@([a-z_]+):(?:\s|$)`); static header_make = ctRegex!(`^@(make):(?:\s|$)`); static header_metadata = ctRegex!(`^@([a-z_]+):(?:\s|$)`); static header_sub = ctRegex!(`^[ ]+:([a-z_]+):\s`); static head_main = ctRegex!(`^@([a-z_]+):\s*(.*)`, "m"); static head_sub = ctRegex!(`^[ ]*:([a-z_]+):\s+(.+)`, "m"); - /* heading & paragraph operators */ + /+ heading & paragraph operators +/ static heading = ctRegex!(`^:?([A-D1-4])[~]([a-z0-9_.-]*[?]?) `); static heading_marker = ctRegex!(`^:?([A-D1-4])[~]`); static heading_title = ctRegex!(`^:?[A-D1-4][~][a-z0-9_.-]*[?]?\s+(.+?)$`); @@ -49,7 +49,7 @@ mixin template RgxInit() { static para_indent = ctRegex!(`^_([1-9]) `); static para_indent_hang = ctRegex!(`^_([0-9])_([0-9]) `); static para_attribs = ctRegex!(`^_(([0-9])(_([0-9]))?|_([1-9])?[*]) `); - /* blocked markup tics */ + /+ blocked markup tics +/ static block_tic_code_open = ctRegex!("^`{3} (code)"); static block_tic_poem_open = ctRegex!("^`{3} (poem)"); static block_tic_group_open = ctRegex!("^`{3} (group)"); @@ -57,7 +57,7 @@ mixin template RgxInit() { static block_tic_quote_open = ctRegex!("^`{3} (quote)"); static block_tic_table_open = ctRegex!("^`{3} (table)"); static block_tic_close = ctRegex!("^(`{3})$","m"); - /* blocked markup curly */ + /+ blocked markup curly +/ static block_curly_code_open = ctRegex!(`^(code[{].*?$)`); static block_curly_code_close = ctRegex!(`^([}]code)`); static block_curly_poem_open = ctRegex!(`^(poem[{].*?$)`); @@ -70,7 +70,7 @@ mixin template RgxInit() { static block_curly_quote_close = ctRegex!(`^([}]quote)`); static block_curly_table_open = ctRegex!(`^(table[{].*?$)`); static block_curly_table_close = ctRegex!(`^([}]table)`); - /* inline markup font face mod */ + /+ inline markup font face mod +/ static inline_emphasis = ctRegex!(`\*\{(?P<text>.+?)\}\*`); static inline_bold = ctRegex!(`!\{(?P<text>.+?)\}!`); static inline_italics = ctRegex!(`/\{(?P<text>.+?)\}/`); @@ -79,7 +79,7 @@ mixin template RgxInit() { static inline_strike = ctRegex!(`-\{(?P<text>.+?)\}-`); static inline_insert = ctRegex!(`\+\{(?P<text>.+?)\}\+`); static inline_mono = ctRegex!(`#\{(?P<text>.+?)\}#`); - /* inline markup footnotes */ + /+ inline markup footnotes +/ static true_dollar = ctRegex!(`\$`, "gm"); static inline_notes_al = ctRegex!(`【(?:[*+]\s+|\s*)(.+?)】`, "mg"); static inline_notes_al_gen = ctRegex!(`【.+?】`, "m"); @@ -106,23 +106,23 @@ mixin template RgxInit() { static inline_text_and_note_square_sp = ctRegex!(`(.+?)~\[[*+]+\s+(.+?)\]~`, "mg"); static inline_text_and_note_square = ctRegex!(`(.+?)~\[\s*(.+?)\]~`, "mg"); static inline_note_square_delimiters = ctRegex!(`(~\[\s*)(.+?)(\]~)`, "mg"); - /* inline markup book index */ + /+ inline markup book index +/ static book_index = ctRegex!(`^=\{\s*(.+?)\}$`, "m"); static book_index_open = ctRegex!(`^=\{\s*([^}]+?)$`); static book_index_close = ctRegex!(`^(.*?)\}$`, "m"); // strip - /* no ocn object */ + /+ no ocn object +/ static ocn_off = ctRegex!(`~#$`, "m"); static ocn_off_dh = ctRegex!(`-#$`, "m"); static ocn_off_all = ctRegex!(`[~-]#$`, "m"); - /* no ocn block */ + /+ no ocn block +/ static ocn_off_block = ctRegex!(`^--~#$`); static ocn_off_block_dh = ctRegex!(`^---#$`); static ocn_off_block_close = ctRegex!(`^--\+#$`); // static auto_ocn_ignore = ctRegex!(`^[+~*$-]{3,}$`); // reminder static ocn_block_marks = ctRegex!(`^--[+~-]#$`); - /* ignore outside code blocks */ + /+ ignore outside code blocks +/ static regular_parse_skip = ctRegex!(`^(--[+~-]#|-[\\]{2}-|=[.\\]{2}=)$`); // not structural info - /* line & page breaks */ + /+ line & page breaks +/ static break_line_within_object = ctRegex!(`[\\]{2}( |$)`); // static break_line_break_within_object = ctRegex!(`( |^)[\\]{2}( |$)`); static break_page = ctRegex!(`^-[\\]{2}-$`); @@ -131,9 +131,9 @@ mixin template RgxInit() { static break_string = ctRegex!(`』`); // ancestry, parent static parent = ctRegex!(`([0-7]):([0-9]+)`); - /* json */ + /+ json +/ static tailing_comma = ctRegex!(`,$`, "m"); - /* head */ + /+ head +/ static main_headers = ctRegex!(`^(?:creator|title|rights|date|original|classify|identifier|notes|publisher|make|links)$`, "m"); static subhead_creator = ctRegex!(`^(?:author|translator|illustrator)$`, "m"); static subhead_title = ctRegex!(`^(?:main|sub(?:title)?|full|language|edition|note)$`, "m"); @@ -145,10 +145,10 @@ mixin template RgxInit() { static subhead_notes = ctRegex!(`^(?:abstract|description)$`, "m"); static subhead_publisher = ctRegex!(`^(?:name)$`, "m"); static subhead_make = ctRegex!(`^(?:cover_image|home_button_image|home_button_text|footer|headings|num_top|breaks|substitute|bold|italics|emphasis|texpdf_font|css)$`, "m"); - /* biblio tags */ + /+ biblio tags +/ static biblio_tags = ctRegex!(`^(is|au|author_raw|author|author_arr|editor_raw|ed|editor_arr|ti|title|subtitle|fulltitle|lng|language|trans|src|jo|journal|in|vol|volume|edn|edition|yr|year|pl|place|pb|pub|publisher|url|pg|pages|note|short_name|id):\s+(.+)`); static biblio_abbreviations = ctRegex!(`^(au|ed|ti|lng|jo|vol|edn|yr|pl|pb|pub|pg|pgs|sn)$`); - /* bookindex split */ + /+ bookindex split +/ static bi_main_terms_split = ctRegex!(`\s*;\s*`); static bi_main_term_plus_rest_split = ctRegex!(`\s*:\s*`); static bi_sub_terms_plus_ocn_offset_split = ctRegex!(`\s*\|\s*`); diff --git a/lib/sdp/ao_scan_inserts.d b/lib/sdp/ao_scan_inserts.d index 54abb8f..f70b2e7 100644 --- a/lib/sdp/ao_scan_inserts.d +++ b/lib/sdp/ao_scan_inserts.d @@ -3,20 +3,16 @@ ao_inserts.d +/ mixin template SiSUdocInserts() { - class Inserts { + private: + struct Inserts { auto scan_subdoc_source( - char[][] markup_sourcefile_insert_content, string fn_src, int add + char[][] markup_sourcefile_insert_content, + string fn_src ) { - char[][100000] cont_arbitrary_max_length_set_; - auto ft0 = flag_type.dup; + char[][] contents_insert; auto ft1 = flag_type.dup; - string[string] processing; - uint[string] line_occur; - auto obj_im = new ObjInlineMarkup(); - auto obj_att = new ObjAttrib(); - int[string] counter; counter["add"]=0; mixin ScreenTxtColors; - auto rgx = new Rgx(); + auto rgx = Rgx(); int tell_l(string color, in char[] line) { writeln(scr_txt_marker[color], line); return 0; @@ -30,44 +26,36 @@ mixin template SiSUdocInserts() { if (auto m = match(line, rgx.block_curly_code_close)) { ft1["curly_code"] = 0; } - cont_arbitrary_max_length_set_[counter["add"]] = line; - ++counter["add"]; ++add; + contents_insert ~= line; } else if (auto m = match(line, rgx.block_curly_code_open)) { ft1["curly_code"] = 1; ft1["header_make"] = 0; ft1["header_metadata"] = 0; - cont_arbitrary_max_length_set_[counter["add"]] = line; - ++counter["add"]; ++add; + contents_insert ~= line; } else if (ft1["tic_code"] == 1) { ft1["header_make"] = 0; ft1["header_metadata"] = 0; if (auto m = match(line, rgx.block_tic_close)) { ft1["tic_code"] = 0; } - cont_arbitrary_max_length_set_[counter["add"]] = line; - ++counter["add"]; ++add; + contents_insert ~= line; } else if (auto m = match(line, rgx.block_tic_code_open)) { ft1["tic_code"] = 1; ft1["header_make"] = 0; ft1["header_metadata"] = 0; - cont_arbitrary_max_length_set_[counter["add"]] = line; - ++counter["add"]; ++add; + contents_insert ~= line; } else if ( - (ft1["header_make"] == 1) && (line_occur["header_make"] > 0) + (ft1["header_make"] == 1) && match(line, rgx.header_sub) ) { ft1["header_make"] = 1; ft1["header_metadata"] = 0; - ++line_occur["header_make"]; - ++counter["add"]; } else if ( - (ft1["header_metadata"] == 1) && (line_occur["header_metadata"] > 0) + (ft1["header_metadata"] == 1) && match(line, rgx.header_sub) ) { ft1["header_metadata"] = 1; ft1["header_make"] = 0; - ++line_occur["header_metadata"]; - ++counter["add"]; } else if (auto m = match(line, rgx.insert_src_fn_ssi_or_sst)) { ft1["header_make"] = 0; ft1["header_metadata"] = 0; @@ -75,7 +63,7 @@ mixin template SiSUdocInserts() { auto insert_sub_pth = m.captures[1]; auto fn_src_insert = (markup_src_file_path ~ insert_sub_pth ~ insert_fn); - auto raw = new MarkupRaw(); + auto raw = MarkupRaw(); auto markup_sourcesubfile_insert_content = raw.markupInsertSourceContentRawLineArray(fn_src_insert); debug(insert) { // insert file @@ -87,7 +75,7 @@ mixin template SiSUdocInserts() { markup_sourcesubfile_insert_content.length ); } - auto ins = new Inserts(); + auto ins = Inserts(); /+ 1. load file, 2. read lines; @@ -100,24 +88,19 @@ mixin template SiSUdocInserts() { } else { ft1["header_make"] = 0; ft1["header_metadata"] = 0; - cont_arbitrary_max_length_set_[counter["add"]] = line; - ++counter["add"]; ++add; + contents_insert ~= line; } } // end src subdoc (inserts) loop - auto contents_ = cont_arbitrary_max_length_set_[0 .. counter["add"]].dup; - auto t = tuple(contents_, add); - return t; + return contents_insert; } - auto scan_doc_source(char[][] markup_sourcefile_content, string fn_src) { - char[][100000] cont_arbitrary_max_length_set; // 2000 pg * 50 lines - string[string] processing; - uint[string] line_occur; - auto obj_im = new ObjInlineMarkup(); - auto obj_att = new ObjAttrib(); + auto scan_doc_source( + char[][] markup_sourcefile_content, + string fn_src + ) { + char[][] contents; auto ft = flag_type.dup; - int add; mixin ScreenTxtColors; - auto rgx = new Rgx(); + auto rgx = Rgx(); int tell_l(string color, in char[] line) { writeln(scr_txt_marker[color], line); return 0; @@ -131,49 +114,42 @@ mixin template SiSUdocInserts() { if (auto m = match(line, rgx.block_curly_code_close)) { ft["curly_code"] = 0; } - cont_arbitrary_max_length_set[add] = line; - ++add; + contents ~= line; } else if (auto m = match(line, rgx.block_curly_code_open)) { ft["curly_code"] = 1; ft["header_make"] = 0; ft["header_metadata"] = 0; - cont_arbitrary_max_length_set[add] = line; - ++add; + contents ~= line; } else if (ft["tic_code"] == 1) { ft["header_make"] = 0; ft["header_metadata"] = 0; if (auto m = match(line, rgx.block_tic_close)) { ft["tic_code"] = 0; } - cont_arbitrary_max_length_set[add] = line; - ++add; + contents ~= line; } else if (auto m = match(line, rgx.block_tic_code_open)) { ft["tic_code"] = 1; ft["header_make"] = 0; ft["header_metadata"] = 0; - cont_arbitrary_max_length_set[add] = line; - } else if ((ft["header_make"] == 1) - && (line_occur["header_make"] > 0) - && match(line, rgx.header_sub)) { - ++line_occur["header_make"]; - cont_arbitrary_max_length_set[add] = line; - ++add; - } else if ((ft["header_metadata"] == 1) - && (line_occur["header_metadata"] > 0) - && match(line, rgx.header_sub)) { - ++line_occur["header_metadata"]; - cont_arbitrary_max_length_set[add] = line; - ++add; + contents ~= line; + } else if ( + (ft["header_make"] == 1) + && match(line, rgx.header_sub) + ) { + contents ~= line; + } else if ( + (ft["header_metadata"] == 1) + && match(line, rgx.header_sub) + ) { + contents ~= line; } else if (auto m = match(line, rgx.header_make)) { ft["header_make"] = 1; - ++line_occur["header_make"]; - cont_arbitrary_max_length_set[add] = line; - ++add; + ft["header_metadata"] = 0; + contents ~= line; } else if (auto m = match(line, rgx.header_metadata)) { + ft["header_make"] = 0; ft["header_metadata"] = 1; - ++line_occur["header_metadata"]; - cont_arbitrary_max_length_set[add] = line; - ++add; + contents ~= line; } else if (auto m = match(line, rgx.insert_src_fn_ssi_or_sst)) { ft["header_make"] = 0; ft["header_metadata"] = 0; @@ -181,7 +157,7 @@ mixin template SiSUdocInserts() { auto insert_sub_pth = m.captures[1]; auto fn_src_insert = (markup_src_file_path ~ insert_sub_pth ~ insert_fn); - auto raw = new MarkupRaw(); + auto raw = MarkupRaw(); auto markup_sourcefile_insert_content = raw.markupInsertSourceContentRawLineArray(fn_src_insert); debug(insert) { // insert file @@ -192,15 +168,12 @@ mixin template SiSUdocInserts() { markup_sourcefile_insert_content.length ); } - auto ins = new Inserts(); - auto t = ins.scan_subdoc_source( - markup_sourcefile_insert_content, to!string(fn_src_insert), add + auto ins = Inserts(); + auto contents_insert = ins.scan_subdoc_source( + markup_sourcefile_insert_content, + to!string(fn_src_insert) ); - static assert(!isTypeTuple!(t)); - auto tmparr = t[0]; - auto addsub = t[1]; - cont_arbitrary_max_length_set[add .. addsub-1] = tmparr[0 .. $-1]; - add=addsub; + contents ~= contents_insert; /+ 1. load file, 2. read lines; @@ -213,15 +186,12 @@ mixin template SiSUdocInserts() { } else { ft["header_make"] = 0; ft["header_metadata"] = 0; - cont_arbitrary_max_length_set[add] = line; - ++add; + contents ~= line; } } // end src doc loop - auto contents = cont_arbitrary_max_length_set[0..add].dup; debug(insert) { // insert file writeln(__LINE__); writeln(contents.length); - writeln(add); } return contents; } diff --git a/lib/sdp/ao_structs.d b/lib/sdp/ao_structs.d new file mode 100644 index 0000000..0aeb235 --- /dev/null +++ b/lib/sdp/ao_structs.d @@ -0,0 +1,43 @@ +/+ + structs + ao_structs.d ++/ +/+ structs +/ + +mixin template Structs() { + struct ObjHeading { + string type; + string lev; + string lvn; + string lcn; + } + struct ObjPara { + string indent_first; + string indent_second; + string bullet; + } + struct ObjComment { + // does not have .attrib; + // does not have .ocn + } + struct ObjBlock { + } + struct ObjBlockOcnString { + // does not have .attrib; + string node; + } + struct ObjComposite { + // size_t id; + string use; + string of; + string is_a; + string object; + string ocn; + string attrib; + // int ocn; + ObjHeading heading; + ObjPara para; + ObjBlock block; + ObjBlockOcnString block_ocn_string; + } +} diff --git a/lib/sdp/ao_utils.d b/lib/sdp/ao_utils.d index 20e8988..e5245dd 100644 --- a/lib/sdp/ao_utils.d +++ b/lib/sdp/ao_utils.d @@ -1,7 +1,7 @@ -/* +/+ utils ao_util.d -*/ ++/ mixin template ScreenTxtColors() { string[string] scr_txt_color = [ "off" : "\033[0m", diff --git a/lib/sdp/compile_time_info.d b/lib/sdp/compile_time_info.d new file mode 100644 index 0000000..e541113 --- /dev/null +++ b/lib/sdp/compile_time_info.d @@ -0,0 +1,38 @@ +/+ + compile_time_info + compile_time_info.d ++/ +mixin template CompileTimeInfo() { + version(Windows) { + pragma(msg, "[ Windows compilation ]"); + enum os = "Windows"; + } else version(OSX) { + pragma(msg, "[ Mac OS X POSIX System compilation ]"); + enum os = "OSX"; + } else version(linux) { + pragma(msg, "[ Linux POSIX System compilation ]"); + enum os = "Linux"; + } else version(FreeBSD) { + pragma(msg, "[ FreeBSD POSIX System compilation ]"); + enum os = "FreeBSD"; + } else version(OpenBSD) { + pragma(msg, "[ OpenBSD POSIX System compilation ]"); + enum os = "OpenBSD"; + } else version(NetBSD) { + pragma(msg, "[ NetBSD POSIX System compilation ]"); + enum os = "NetBSD"; + } else version(DragonFlyBSD) { + pragma(msg, "[ DragonFlyBSD POSIX System compilation ]"); + enum os = "DragonFlyBSD"; + } else version(POSIX) { + pragma(msg, "[ POSIX System compilation ]"); + enum os = "POSIX"; + } else { + static assert(0, "OS not listed"); + } + version(D_LP64) { + enum bits = "64 bit"; + } else { + enum bits = "32 bit"; + } +} diff --git a/lib/sdp/version.txt b/lib/sdp/version.txt new file mode 100644 index 0000000..f4dde1a --- /dev/null +++ b/lib/sdp/version.txt @@ -0,0 +1,8 @@ +/+ obt - org generated file +/ +// [used by rdmd] +struct Version { + int major; + int minor; + int patch; +} +enum ver = Version(1, 0, 0); diff --git a/lib/version.txt b/lib/version.txt new file mode 100644 index 0000000..33ae56d --- /dev/null +++ b/lib/version.txt @@ -0,0 +1,7 @@ +/+ obt - org generated file +/ +struct Version { + int major; + int minor; + int patch; +} +enum ver = Version(1, 0, 0); |