diff options
| author | Ralph Amissah <ralph@amissah.com> | 2016-04-24 22:08:24 -0400 | 
|---|---|---|
| committer | Ralph Amissah <ralph@amissah.com> | 2016-04-24 22:08:24 -0400 | 
| commit | ed302d1be74d2b4e69ee4b6e3834637ed531eaea (patch) | |
| tree | 0f605c3756788d2fda6fe0782a7a472172a285b9 | |
| parent | base ... tag (diff) | |
step1doc-reform_v0.0.1
30 files changed, 2057 insertions, 1208 deletions
| @@ -5,6 +5,7 @@  !tangle  !*.org  !*.d +!*.txt  !org  !lib  !**/ @@ -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); diff --git a/org/ao_abstract_doc_source.org b/org/ao_abstract_doc_source.org index 5356a15..a89b14c 100644 --- a/org/ao_abstract_doc_source.org +++ b/org/ao_abstract_doc_source.org @@ -15,7 +15,7 @@  * document abstraction                                             :abstract:  [[./sdp.org][sdp]]  [[./][org/]]  Process markup document, create document abstraction. -** initialize +** initialize                                                    :initialize:  #+name: abs_init  #+BEGIN_SRC d  /+ initialize +/ @@ -23,19 +23,20 @@ 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; @@ -79,18 +80,18 @@ auto str_h_3 = "^(none)";  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_, @@ -128,11 +129,20 @@ string[string] ocn_poem = [    "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) { @@ -140,7 +150,7 @@ scope(success) {  scope(failure) {  }  scope(exit) { -  destroy(contents_arbitrary_max_length_set); +  destroy(contents);    destroy(object);    destroy(processing);    destroy(biblio_arr_json); @@ -153,14 +163,16 @@ auto dochead_metadata = parseJSON(header_metadata_jsonstr).object;  *** scope                                                             :scope:  #+name: abs_loop_body_00  #+BEGIN_SRC d -/* scope */ +/+ 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 $ @@ -171,7 +183,11 @@ debug(source) {                                  // source lines  }  debug(srclines) {    if (!line.empty) {                             // source lines, not empty -    writeln(scr_txt_marker["green"], line); +    writefln( +      "%s%s", +      scr_txt_marker["green"], +      line +    );    }  }  #+END_SRC @@ -179,9 +195,9 @@ debug(srclines) {  #+name: abs_loop_body_00  #+BEGIN_SRC d  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) { @@ -223,7 +239,7 @@ if ((!line.empty) && (ft["ocn_status_multi_obj"] == 0)) {  #+name: abs_loop_body_00  #+BEGIN_SRC d  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 @@ -258,7 +274,7 @@ if (ft["code"] == 1) {  #+name: abs_loop_body_00  #+BEGIN_SRC d  } 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) +/  #+END_SRC  ***** within block group [+1]                                  :block:active:  ****** within block group: biblio                                    :biblio: @@ -268,21 +284,20 @@ 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      );    } @@ -291,7 +306,7 @@ if (((match(line, rgx.heading_biblio)      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 { @@ -334,18 +349,17 @@ if (((match(line, rgx.heading_biblio)      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="";    }  #+END_SRC @@ -353,14 +367,14 @@ if (((match(line, rgx.heading_biblio)  #+name: abs_loop_body_non_code_obj  #+BEGIN_SRC d  } 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          ); @@ -370,10 +384,10 @@ if (((match(line, rgx.heading_biblio)        }        debug(poem) {                            // poem (curly) close          writeln(__LINE__); -        writeln( +        writefln( +          "%s%s %s",            scr_txt_marker["fuchsia"],            ocn, -          " ",            line          );        } @@ -392,7 +406,7 @@ if (((match(line, rgx.heading_biblio)            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"], @@ -424,10 +438,12 @@ if (((match(line, rgx.heading_biblio)          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"; @@ -440,7 +456,7 @@ if (((match(line, rgx.heading_biblio)          );          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"], @@ -460,9 +476,9 @@ if (((match(line, rgx.heading_biblio)      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          ); @@ -481,7 +497,7 @@ if (((match(line, rgx.heading_biblio)            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"], @@ -513,10 +529,12 @@ if (((match(line, rgx.heading_biblio)          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"; @@ -532,7 +550,7 @@ if (((match(line, rgx.heading_biblio)            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"], @@ -553,7 +571,7 @@ if (((match(line, rgx.heading_biblio)  ****** within block group: group                                      :group:  #+name: abs_loop_body_non_code_obj  #+BEGIN_SRC d -/* 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)) { @@ -589,7 +607,7 @@ if (((match(line, rgx.heading_biblio)  #+name: abs_loop_body_non_code_obj  #+BEGIN_SRC d  } 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 @@ -624,7 +642,7 @@ if (((match(line, rgx.heading_biblio)  #+name: abs_loop_body_non_code_obj  #+BEGIN_SRC d  } 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 @@ -659,7 +677,7 @@ if (((match(line, rgx.heading_biblio)  #+name: abs_loop_body_non_code_obj  #+BEGIN_SRC d  } 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 @@ -694,7 +712,7 @@ if (((match(line, rgx.heading_biblio)  #+name: abs_loop_body_non_code_obj  #+BEGIN_SRC d  } else { -/* not within a block group */ +/+ not within a block group +/  #+END_SRC  ****** assert  #+name: abs_loop_body_open_block_obj @@ -711,11 +729,11 @@ assertions_flag_types_block_status_none_or_closed(ft);  #+name: abs_loop_body_open_block_obj  #+BEGIN_SRC d  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      ); @@ -728,7 +746,7 @@ if (auto m = match(line, rgx.block_curly_code_open)) {  #+name: abs_loop_body_open_block_obj  #+BEGIN_SRC d  } 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"); @@ -736,9 +754,9 @@ if (auto m = match(line, rgx.block_curly_code_open)) {    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      ); @@ -753,11 +771,11 @@ if (auto m = match(line, rgx.block_curly_code_open)) {  #+name: abs_loop_body_open_block_obj  #+BEGIN_SRC d  } 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      ); @@ -770,11 +788,11 @@ if (auto m = match(line, rgx.block_curly_code_open)) {  #+name: abs_loop_body_open_block_obj  #+BEGIN_SRC d  } 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      ); @@ -787,11 +805,11 @@ if (auto m = match(line, rgx.block_curly_code_open)) {  #+name: abs_loop_body_open_block_obj  #+BEGIN_SRC d  } 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      ); @@ -804,11 +822,11 @@ if (auto m = match(line, rgx.block_curly_code_open)) {  #+name: abs_loop_body_open_block_obj  #+BEGIN_SRC d  } 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      ); @@ -822,11 +840,11 @@ if (auto m = match(line, rgx.block_curly_code_open)) {  #+name: abs_loop_body_open_block_obj  #+BEGIN_SRC d  } 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      ); @@ -839,7 +857,7 @@ if (auto m = match(line, rgx.block_curly_code_open)) {  #+name: abs_loop_body_open_block_obj  #+BEGIN_SRC d  } 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"); @@ -847,9 +865,9 @@ if (auto m = match(line, rgx.block_curly_code_open)) {    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      ); @@ -864,11 +882,11 @@ if (auto m = match(line, rgx.block_curly_code_open)) {  #+name: abs_loop_body_open_block_obj  #+BEGIN_SRC d  } 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      ); @@ -881,11 +899,11 @@ if (auto m = match(line, rgx.block_curly_code_open)) {  #+name: abs_loop_body_open_block_obj  #+BEGIN_SRC d  } 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      ); @@ -898,11 +916,11 @@ if (auto m = match(line, rgx.block_curly_code_open)) {  #+name: abs_loop_body_open_block_obj  #+BEGIN_SRC d  } 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      ); @@ -915,11 +933,11 @@ if (auto m = match(line, rgx.block_curly_code_open)) {  #+name: abs_loop_body_open_block_obj  #+BEGIN_SRC d  } 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      ); @@ -932,8 +950,8 @@ if (auto m = match(line, rgx.block_curly_code_open)) {  #+name: abs_loop_body_not_block_obj  #+BEGIN_SRC d  } else if (!line.empty) { -/* line not empty */ -/* non blocks (headers, paragraphs) & closed blocks */ +/+ line not empty +/ +/+ non blocks (headers, paragraphs) & closed blocks +/  #+END_SRC  ******* asserts                                                      :assert:  #+name: abs_loop_body_not_block_obj @@ -964,11 +982,13 @@ if (auto m = match(line, rgx.block_curly_code_open)) {  #+name: abs_loop_body_not_block_obj  #+BEGIN_SRC d    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");      } @@ -978,24 +998,24 @@ if (auto m = match(line, rgx.block_curly_code_open)) {      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 = ""; @@ -1007,18 +1027,18 @@ if (auto m = match(line, rgx.block_curly_code_open)) {  #+name: abs_loop_body_not_block_obj  #+BEGIN_SRC d    } else { -  /* not book_index */ +  /+ not book_index +/  #+END_SRC  ******** matched: comment                                     :comment:match:  #+name: abs_loop_body_not_block_obj  #+BEGIN_SRC d      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"); @@ -1041,7 +1061,7 @@ if (auto m = match(line, rgx.block_curly_code_open)) {  #+name: abs_loop_body_not_block_obj  #+BEGIN_SRC d      } else if (auto m = match(line, rgx.header_make)) { -    /* matched header_make */ +    /+ matched header_make +/        debug(header1) {                          // header          tell_l("yellow", line);        } @@ -1057,7 +1077,7 @@ if (auto m = match(line, rgx.block_curly_code_open)) {  #+name: abs_loop_body_not_block_obj  #+BEGIN_SRC d      } else if (auto m = match(line, rgx.header_metadata)) { -    /* matched header_metadata */ +    /+ matched header_metadata +/        debug(header1) {                          // header          tell_l("yellow", line);        } @@ -1074,9 +1094,9 @@ if (auto m = match(line, rgx.block_curly_code_open)) {  #+BEGIN_SRC d      } 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);          } @@ -1089,9 +1109,9 @@ if (auto m = match(line, rgx.block_curly_code_open)) {  #+BEGIN_SRC d      } 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);          } @@ -1106,14 +1126,14 @@ if (auto m = match(line, rgx.block_curly_code_open)) {      && (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 +/  #+END_SRC  ********* headings found                                            :heading:  #+name: abs_loop_body_not_block_obj  #+BEGIN_SRC d        if ((to!string(dochead_make["make"]["headings"]).length > 2)        && (ft["make_headings"] == 0)) { -      /* headings found */ +      /+ headings found +/          debug(headingsfound) {            writeln(dochead_make["make"]["headings"]);          } @@ -1186,7 +1206,7 @@ if (auto m = match(line, rgx.block_curly_code_open)) {        && (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) { @@ -1235,7 +1255,7 @@ if (auto m = match(line, rgx.block_curly_code_open)) {  #+name: abs_loop_body_not_block_obj  #+BEGIN_SRC d        if (auto m = match(line, rgx.heading)) { -      /* heading match */ +      /+ heading match +/          ft["heading"] = 1;          ft["header"] = 0;          ft["header_make"] = 0; @@ -1362,7 +1382,7 @@ if (auto m = match(line, rgx.block_curly_code_open)) {  #+name: abs_loop_body_not_block_obj  #+BEGIN_SRC d        } 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); @@ -1413,7 +1433,7 @@ if (auto m = match(line, rgx.block_curly_code_open)) {  #+name: abs_loop_body_not_block_obj  #+BEGIN_SRC d      } else if (line_occur["header_make"] > 0) { -    /* header_make */ +    /+ header_make +/      // should be caught by sub-header        debug(header) {          tell_l("red", line); @@ -1425,7 +1445,7 @@ if (auto m = match(line, rgx.block_curly_code_open)) {  #+name: abs_loop_body_not_block_obj  #+BEGIN_SRC d      } else if (line_occur["header_metadata"] > 0) { -    /* header_metadata */ +    /+ header_metadata +/      // should be caught by sub-header        debug(header) {                          // para          tell_l("red", line); @@ -1437,7 +1457,7 @@ if (auto m = match(line, rgx.block_curly_code_open)) {  #+name: abs_loop_body_not_block_obj  #+BEGIN_SRC d      } else if (line_occur["heading"] > 0) { -    /* heading */ +    /+ heading +/        debug(heading) {                         // heading          tell_l("blue", line);        } @@ -1448,7 +1468,7 @@ if (auto m = match(line, rgx.block_curly_code_open)) {  #+name: abs_loop_body_not_block_obj  #+BEGIN_SRC d      } else if (line_occur["para"] > 0) { -    /* paragraph */ +    /+ paragraph +/        debug(para) {          tell_l("blue", line);        } @@ -1461,7 +1481,7 @@ if (auto m = match(line, rgx.block_curly_code_open)) {  #+name: abs_loop_body_not_block_obj  #+BEGIN_SRC d  } else if (ft["blocks"] == 2) { -/* line empty, with blocks flag */ +/+ line empty, with blocks flag +/    assert(      line.empty,      "line should be empty" @@ -1490,7 +1510,7 @@ if (auto m = match(line, rgx.block_curly_code_open)) {        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"], @@ -1520,7 +1540,7 @@ if (auto m = match(line, rgx.block_curly_code_open)) {          heading_pointer-1,          object["is"]        ); -    contents_arbitrary_max_length_set[counter] = +    contents ~=        set_oa.contents_block_ocn_string(          "poem",          "", @@ -1554,7 +1574,7 @@ if (auto m = match(line, rgx.block_curly_code_open)) {        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"], @@ -1587,7 +1607,7 @@ if (auto m = match(line, rgx.block_curly_code_open)) {        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"], @@ -1620,7 +1640,7 @@ if (auto m = match(line, rgx.block_curly_code_open)) {        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"], @@ -1654,7 +1674,7 @@ if (auto m = match(line, rgx.block_curly_code_open)) {        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"], @@ -1676,12 +1696,12 @@ if (auto m = match(line, rgx.block_curly_code_open)) {  #+name: abs_loop_body_not_block_obj  #+BEGIN_SRC d  } else { -/* line empty */ +/+ line empty +/  #+END_SRC  ******* assert line empty                                            :assert:  #+name: abs_loop_body_not_block_obj_line_empty  #+BEGIN_SRC d -/* line.empty, post contents, empty variables: */ +/+ line.empty, post contents, empty variables: +/  assert(    line.empty,    "line should be empty" @@ -1696,7 +1716,7 @@ assert(  #+BEGIN_SRC d  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)); @@ -1721,7 +1741,7 @@ if ((ft["header_make"] == 1)  #+BEGIN_SRC d  } 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)); @@ -1748,7 +1768,7 @@ if ((ft["header_make"] == 1)  #+BEGIN_SRC d  } 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"] : ""; @@ -1769,7 +1789,7 @@ if ((ft["header_make"] == 1)    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"], @@ -1805,7 +1825,7 @@ if ((ft["header_make"] == 1)  #+name: abs_loop_body_not_block_obj_line_empty  #+BEGIN_SRC d  } 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"] : ""; @@ -1824,7 +1844,7 @@ if ((ft["header_make"] == 1)      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"], @@ -1871,16 +1891,19 @@ if ((ft["header_make"] == 1)  *** regular text objects  #+name: abs_loop_body_01  #+BEGIN_SRC d -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 +    );    }  }  #+END_SRC @@ -1891,30 +1914,32 @@ if (((contents_arbitrary_max_length_set[counter-1]["is"] == "para")  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)); @@ -1962,10 +1987,10 @@ debug(heading) {                         // heading          spc="";          break;        } -      writeln( -        spc, "* ", " ", +      writefln( +        "%s*  $s\n            %s", +        spc,          strip(o["obj"]), -        "\n            ",          o["attrib"]        );        // tell_l("yellow", spc, strip(o["obj"])); @@ -1990,17 +2015,19 @@ return t;  ** code structure:                                :ao_abstract_doc_source.d:  #+name: tangle_ao_abstract_doc_source  #+BEGIN_SRC d :tangle ../lib/sdp/ao_abstract_doc_source.d -/* +/+    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) {        <<abs_init>> +      /+ ↓ loop markup document/text line by line +/        foreach (line; markup_sourcefile_content) { -      /* loop markup document/text line by line */ +        /+ ↓ markup document/text line by line +/          <<abs_loop_body_00>>            <<abs_loop_body_non_code_obj>>              <<abs_loop_body_open_block_obj>> @@ -2008,8 +2035,8 @@ mixin template SiSUdocAbstraction() {                <<abs_loop_body_not_block_obj_line_empty>>          <<abs_loop_body_00_closed>>          <<abs_loop_body_01>> -      } // 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 +/        <<abs_post>>      }    } diff --git a/org/ao_assertions.org b/org/ao_assertions.org index 0502d46..948bb5e 100644 --- a/org/ao_assertions.org +++ b/org/ao_assertions.org @@ -122,7 +122,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; @@ -244,9 +244,9 @@ mixin template AssertionsOnBlocks() {  ** code structure:                                           :ao_assertions.d:  #+name: tangle_ao_assertions  #+BEGIN_SRC d :tangle ../lib/sdp/ao_assertions.d -/* +/+    assertions    ao_assertions.d -*/ ++/  <<ao_assertions>>  #+END_SRC diff --git a/org/ao_defaults.org b/org/ao_defaults.org index 928bfa6..fc176d0 100644 --- a/org/ao_defaults.org +++ b/org/ao_defaults.org @@ -184,7 +184,7 @@ template SiSUheader() {  ** template: flags regex initialize                             :regex_flags:  #+name: ao_defaults_templates  #+BEGIN_SRC d -/* regex flags */ +/+ regex flags +/  template SiSUrgxInitFlags() {    int[string] flag_type = [      "make_headings"        : 0, @@ -274,9 +274,77 @@ template SiSUbiblio() {  #+name: ao_defaults_templates  #+BEGIN_SRC d  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 = "\\}\\#"; +    // ⊹    }  }  #+END_SRC @@ -285,9 +353,9 @@ template InternalMarkup() {  ** code structure:                                               :ao_defaults.d:  #+name: tangle_ao_defaults  #+BEGIN_SRC d :tangle ../lib/sdp/ao_defaults.d -/* +/+    defaults    ao_defaults.d -*/ ++/  <<ao_defaults_templates>>  #+END_SRC diff --git a/org/ao_emitters_and_interfaces.org b/org/ao_emitter.org index 74b80fc..0ecbc2e 100644 --- a/org/ao_emitters_and_interfaces.org +++ b/org/ao_emitter.org @@ -9,19 +9,17 @@  #+PROPERTY: header-args :padline no :exports code :noweb yes  #+EXPORT_SELECT_TAGS: export  #+EXPORT_EXCLUDE_TAGS: noexport -#+FILETAGS: :sdp:rel:ao: +#+FILETAGS: :sdp:dev:ao:  #+TAGS: assert(a) class(c) debug(d) mixin(m) sdp(s) tangle(T) template(t) WEB(W) noexport(n) -* emitters & interfaces -[[./sdp.org][sdp]]  [[./][org/]] -ao_interface.d +* emitters +[[./sdp.org][sdp]]  ao_emitter.d  various emitters and their interfaces (where available) -** e:   command line interface/instructions -*** emitter                                                         :emitter: +** command line interface/instructions  #+name: ao_emitter  #+BEGIN_SRC d -class CLI { +struct CLI {    string[string] extract_actions(string cmdlnins, string[string] actions)    in { }    body { @@ -36,11 +34,11 @@ class CLI {    }  }  #+END_SRC -** e&i: ocn -*** emitter                                                         :emitter: +** ocn  #+name: ao_emitter  #+BEGIN_SRC d -class OCNemitter : AssertOCN { +struct OCNemitter { +// class OCNemitter : AssertOCN {    int ocn, ocn_;    int ocn_emitter(int ocn_status_flag)    in { assert(ocn_status_flag <= 2); } @@ -50,31 +48,23 @@ class OCNemitter : AssertOCN {      } else {        ocn=0;      } +    assert(ocn >= 0);      return ocn;    }    invariant() {    }  }  #+END_SRC -*** interface assert                                       :interface:assert: -#+name: ao_interface -#+BEGIN_SRC d -interface AssertOCN { -  int ocn_emitter(int ocn_status_flag) -    in { assert(ocn_status_flag <= 2); } -    out(ocn) { assert(ocn >= 0); } -} -#+END_SRC -** e:   object attributes -*** emitter                                                         :emitter: +** object attributes  #+name: ao_emitter  #+BEGIN_SRC d -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\"," @@ -117,6 +107,7 @@ class ObjAttributes {      obj_txt["attrib"] = " \"use\": \"content\","      ~ " \"of\": \"para\","      ~ " \"is\": \"heading\""; +    // obj_txt["struct"]=;      return obj_txt["attrib"];    }    invariant() { @@ -222,11 +213,11 @@ class ObjAttributes {    }  }  #+END_SRC -** e:   object inline markup munge -*** emitter                                                         :emitter: +** object inline markup munge  #+name: ao_emitter  #+BEGIN_SRC d -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; @@ -239,8 +230,8 @@ class ObjInlineMarkupMunge {    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( @@ -278,6 +269,11 @@ class ObjInlineMarkupMunge {            (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; @@ -298,7 +294,7 @@ class ObjInlineMarkupMunge {    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, ""); @@ -314,7 +310,7 @@ class ObjInlineMarkupMunge {    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, ""); @@ -406,12 +402,12 @@ class ObjInlineMarkupMunge {    }  }  #+END_SRC -** e&i: object inline markup -*** emitter                                                         :emitter: +** object inline markup  #+name: ao_emitter  #+BEGIN_SRC d -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 { } @@ -466,28 +462,20 @@ class ObjInlineMarkup : AssertObjInlineMarkup {    }  }  #+END_SRC -*** interface assert                                       :interface:assert: -#+name: ao_interface -#+BEGIN_SRC d -interface AssertObjInlineMarkup { -  string obj_inline_markup(string obj_raw, string obj_type_) -    in { -    } -    out(inline_markup) { -    } -} -#+END_SRC -** e&i: object attrib -*** emitter                                                         :emitter: +** object attrib  #+name: ao_emitter  #+BEGIN_SRC d -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);      } @@ -555,36 +543,28 @@ class ObjAttrib : AssertObjAttrib {      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() {    }  }  #+END_SRC -*** interface assert                                       :interface:assert: -#+name: ao_interface -#+BEGIN_SRC d -interface AssertObjAttrib { -  string obj_attributes(string obj_raw, string node, string obj_type_) -    in { -    } -    out(obj_attrib_json) { -    } -} -#+END_SRC -** e:   header document metadata in json -*** emitter                                                         :emitter: +** header document metadata in json  #+name: ao_emitter  #+BEGIN_SRC d -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, @@ -756,6 +736,15 @@ class HeaderDocMetadataMakeJson {                  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; @@ -772,14 +761,16 @@ class HeaderDocMetadataMakeJson {      static assert(!isTypeTuple!(t));      return t;    } +  // invariant() { +  // }  }  #+END_SRC -** e:   header document metadata as hash -*** emitter                                                         :emitter: +** header document metadata as hash  #+name: ao_emitter  #+BEGIN_SRC d  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) @@ -827,11 +818,11 @@ class HeaderMetadataMakeHash {    }  }  #+END_SRC -** e&i: book index nugget hash -*** emitter                                                         :emitter: +** book index nugget hash  #+name: ao_emitter  #+BEGIN_SRC d -class BookIndexNuggetHash : AssertBookIndexNuggetHash { +struct BookIndexNuggetHash { +// class BookIndexNuggetHash : AssertBookIndexNuggetHash {    string main_term, sub_term, sub_term_bits;    uint ocn_offset, ocn_endpoint;    string[] ocns; @@ -839,9 +830,19 @@ class BookIndexNuggetHash : AssertBookIndexNuggetHash {    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); @@ -884,40 +885,22 @@ class BookIndexNuggetHash : AssertBookIndexNuggetHash {              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() {    }  }  #+END_SRC -*** interface assert                                       :interface:assert: -#+name: ao_interface -#+BEGIN_SRC d -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) { -    } -} -#+END_SRC -** e&i: book index report -*** emitter                                                         :emitter: +** book index report  #+name: ao_emitter  #+BEGIN_SRC d -class BookIndexReport { +struct BookIndexReport { +// class BookIndexReport : AssertBookIndexReport {    int mkn, skn;    auto bookindex_report_sorted(      string[][string][string] bookindex_unordered_hashes @@ -935,27 +918,19 @@ class BookIndexReport {              to!string(bookindex_unordered_hashes[mainkey][subkey])            );          } +        // bookindex_the[mkn][mainkey][skn][subkey] ~= (bookindex_unordered_hashes[mainkey][subkey]);          skn++;        }        mkn++;      } +    // return bookindex_the;    }  }  #+END_SRC -*** interface assert                                       :interface:assert: -#+name: ao_interface -#+BEGIN_SRC d -interface AssertBookIndexReport { -  string[][string][][string][] bookindex_nugget_hash(string[][string][string] bookindex_unordered_hashes) -    in { -    } -} -#+END_SRC -** e:   book index report indented -*** emitter                                                         :emitter: +** book index report indented  #+name: ao_emitter  #+BEGIN_SRC d -class BookIndexReportIndent { +struct BookIndexReportIndent {    int mkn, skn;    auto bookindex_report_indented(      string[][string][string] bookindex_unordered_hashes @@ -975,6 +950,7 @@ class BookIndexReportIndent {              bookindex_unordered_hashes[mainkey][subkey]            ));          } +        // bookindex_the[mkn][mainkey][skn][subkey] ~= (bookindex_unordered_hashes[mainkey][subkey]);          skn++;        }        mkn++; @@ -982,14 +958,13 @@ class BookIndexReportIndent {    }  }  #+END_SRC -** e:   book index report section -*** emitter                                                         :emitter: +** book index report section  #+name: ao_emitter  #+BEGIN_SRC d -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    ) { @@ -1026,19 +1001,20 @@ class BookIndexReportSection {      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, @@ -1050,13 +1026,14 @@ class BookIndexReportSection {        );      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, @@ -1070,6 +1047,7 @@ class BookIndexReportSection {      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 ~ ", "; @@ -1093,7 +1071,7 @@ class BookIndexReportSection {        indent_first = "0";        indent_second = "1";        attrib=""; -      bookindex_arbitrary_max_length_set[mkn] = +      bookindex ~=          set_oa.contents_para(            type,            bi_tmp, @@ -1106,8 +1084,6 @@ class BookIndexReportSection {        ocn++;        mkn++;      } -    auto bookindex = -      bookindex_arbitrary_max_length_set[0..mkn].dup;      auto t = tuple(bookindex, ocn);      return t;    } @@ -1117,7 +1093,8 @@ class BookIndexReportSection {      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 ~ "}! "; @@ -1131,6 +1108,7 @@ class BookIndexReportSection {          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 ~ ", "; @@ -1139,28 +1117,25 @@ class BookIndexReportSection {          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;    }  }  #+END_SRC -** e:   (end)notes section -*** emitter                                                         :emitter: +** (end)notes section  #+name: ao_emitter  #+BEGIN_SRC d -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 @@ -1183,6 +1158,7 @@ class NotesSection {          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_" ~ @@ -1204,21 +1180,23 @@ class NotesSection {    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", @@ -1230,12 +1208,13 @@ class NotesSection {        );      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", @@ -1253,7 +1232,7 @@ class NotesSection {        indent_first = "0";        indent_second = "0";        attrib=""; -      endnotes_arbitrary_max_length_set[mkn] = +      endnotes ~=          set_oa.contents_para(            type,            endnote, @@ -1266,33 +1245,31 @@ class NotesSection {        ocn++;        mkn++;      } -    auto endnotes = -      endnotes_arbitrary_max_length_set[0..mkn].dup;      auto t = tuple(endnotes, ocn);      return t;    }  }  #+END_SRC -** e:   bibliography -*** emitter                                                         :emitter: +** bibliography  #+name: ao_emitter  #+BEGIN_SRC d -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 @@ -1311,12 +1288,15 @@ class Bibliography {             "; "  ~             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) { @@ -1329,6 +1309,7 @@ class Bibliography {        foreach (j; biblio_sorted) {          if (!empty(j["fulltitle"].str)) {            writeln(j["sortby_deemed_author_year_title"]); +          // writeln(j["deemed_author"], " (", j["author"], ") ",  j["fulltitle"]);          }        }      } @@ -1345,11 +1326,11 @@ class Bibliography {    }  }  #+END_SRC -** e&i: node structure metadata -*** emitter                                                         :emitter: +** node structure metadata  #+name: ao_emitter  #+BEGIN_SRC d -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_ @@ -1362,9 +1343,16 @@ class NodeStructureMetadata : AssertNodeJSON {      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_); @@ -1386,10 +1374,26 @@ class NodeStructureMetadata : AssertNodeJSON {        ", \"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() {    } +#+END_SRC + +#+name: ao_emitter +#+BEGIN_SRC d    string node_emitter_heading(      string lvn,      string lcn, @@ -1399,9 +1403,28 @@ class NodeStructureMetadata : AssertNodeJSON {      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": @@ -1453,6 +1476,15 @@ class NodeStructureMetadata : AssertNodeJSON {        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=("{ " ~ @@ -1466,67 +1498,6 @@ class NodeStructureMetadata : AssertNodeJSON {        ", \"parent_lvn\": " ~ to!string(p_["lvn"]) ~        " }"      ); -    return node; -  } -  invariant() { -  } -} -#+END_SRC - -*** interface assert                                       :interface:assert: -#+name: ao_interface -#+BEGIN_SRC d -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)) { @@ -1570,32 +1541,28 @@ interface AssertNodeJSON {        } 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() {    }  }  #+END_SRC +  * tangles                                                            :tangle:  ** code structure:                                                :ao_emitter.d:  #+name: tangle_ao_emitter  #+BEGIN_SRC d :tangle ../lib/sdp/ao_emitter.d -/* +/+    emitters    ao_emitters.d -*/ ++/  mixin template Emitters() {    mixin InternalMarkup;    <<ao_emitter>>  }  #+END_SRC -** code structure:                                             :ao_interface.d: -#+name: tangle_ao_interface -#+BEGIN_SRC d :tangle ../lib/sdp/ao_interface.d -/* -  interface -  ao_interface.d -*/ -mixin template Interfaces() { -  <<ao_interface>> -} -#+END_SRC diff --git a/org/ao_object_setter.org b/org/ao_object_setter.org index 51dd9bc..2ee9423 100644 --- a/org/ao_object_setter.org +++ b/org/ao_object_setter.org @@ -17,6 +17,25 @@  ** struct                                                            :struct:  #+name: ao_object_setter  #+BEGIN_SRC d +mixin Structs; +#+END_SRC +** comment                                                          :comment: +#+name: ao_object_setter +#+BEGIN_SRC d +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; +} +#+END_SRC + +#+name: ao_object_setter +#+BEGIN_SRC d  string[string] contents_comment(in string object) {    string[string] object_set;    object_set["use"]           = "comment"; @@ -29,6 +48,32 @@ string[string] contents_comment(in string object) {  ** heading                                                          :heading:  #+name: ao_object_setter  #+BEGIN_SRC d +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; +} +#+END_SRC + +#+name: ao_object_setter +#+BEGIN_SRC d  string[string] contents_heading(    in int type,    in string object, @@ -53,10 +98,36 @@ string[string] contents_heading(  }  #+END_SRC  ** para                                                                :para: + +#+name: ao_object_setter +#+BEGIN_SRC d +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; +} +#+END_SRC +  #+name: ao_object_setter  #+BEGIN_SRC d  string[string] contents_para( -  in string type, +  in string is_a,    in string object,    in string attrib,    in int ocn, @@ -67,7 +138,7 @@ string[string] contents_para(    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; @@ -80,6 +151,26 @@ string[string] contents_para(  ** block                                                              :block:  #+name: ao_object_setter  #+BEGIN_SRC d +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; +} +#+END_SRC + +#+name: ao_object_setter +#+BEGIN_SRC d  string[string] contents_block(    in string type,    in string object, @@ -99,6 +190,26 @@ string[string] contents_block(  ** block ocn string                                                   :block:  #+name: ao_object_setter  #+BEGIN_SRC d +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; +} +#+END_SRC + +#+name: ao_object_setter +#+BEGIN_SRC d  string[string] contents_block_ocn_string(    in string type,    in string object, @@ -120,12 +231,12 @@ string[string] contents_block_ocn_string(  ** code structure:                                          :ao_object_setter.d:  #+name: tangle_ao_object_setter  #+BEGIN_SRC d :tangle ../lib/sdp/ao_object_setter.d -/* +/+    object setter    ao_object_setter.d -*/ ++/  mixin template ObjectSetters() { -  class ObjectAbstractSet { +  struct ObjectAbstractSet {      import std.conv : to;      <<ao_object_setter>>    } diff --git a/org/ao_output_debugs.org b/org/ao_output_debugs.org index 5fd0d98..3f9b59f 100644 --- a/org/ao_output_debugs.org +++ b/org/ao_output_debugs.org @@ -18,11 +18,17 @@  #+name: ao_output_debugs  #+BEGIN_SRC d  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"], @@ -34,18 +40,45 @@ debug(parent) {    }  }  #+END_SRC +** (dumpdoc)                                                        :objects: +#+name: ao_output_debugs +#+BEGIN_SRC d +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"] +      ); +    } +  } +} +#+END_SRC  ** (objects)                                                        :objects:  #+name: ao_output_debugs  #+BEGIN_SRC d  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"]        ); @@ -57,17 +90,21 @@ debug(objects) {  #+name: ao_output_debugs  #+BEGIN_SRC d  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]            );          } @@ -83,16 +120,21 @@ debug(headermakejson) {  #+name: ao_output_debugs  #+BEGIN_SRC d  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]            );          } @@ -101,8 +143,10 @@ debug(headermetadatajson) {      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]            );          } @@ -111,8 +155,10 @@ debug(headermetadatajson) {      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]            );          } @@ -121,8 +167,10 @@ debug(headermetadatajson) {      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]            );          } @@ -131,8 +179,10 @@ debug(headermetadatajson) {      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]            );          } @@ -141,8 +191,10 @@ debug(headermetadatajson) {      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]            );          } @@ -151,8 +203,10 @@ debug(headermetadatajson) {      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]            );          } @@ -161,8 +215,10 @@ debug(headermetadatajson) {      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]            );          } @@ -171,8 +227,10 @@ debug(headermetadatajson) {      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]            );          } @@ -188,9 +246,13 @@ debug(headermetadatajson) {  #+name: ao_output_debugs  #+BEGIN_SRC d  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);  }  #+END_SRC @@ -219,28 +281,39 @@ debug(checkdoc) {  #+name: ao_output_debugs_summary  #+BEGIN_SRC d  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__,  );  #+END_SRC  *** compare number of ocn for known sisu markup output (checkdoc) @@ -377,12 +450,12 @@ debug(checkdoc) {  ** code structure:                                          :ao_output_debugs.d:  #+name: tangle_ao_output_debugs  #+BEGIN_SRC d :tangle ../lib/sdp/ao_output_debugs.d -/* +/+    output debugs    ao_output_debugs.d -*/ ++/  template SiSUoutputDebugs() { -  class SDPoutputDebugs { +  struct SDPoutputDebugs {      auto abstract_doc_source_debugs(        string[string][] contents,        JSONValue[string] docmake, @@ -394,7 +467,7 @@ template SiSUoutputDebugs() {      ) {        mixin RgxInit;        mixin ScreenTxtColors; -      auto rgx = new Rgx(); +      auto rgx = Rgx();        <<ao_output_debugs>>          <<ao_output_debugs_summary>>        } diff --git a/org/ao_read_markup_source.org b/org/ao_read_markup_source.org index e1fbc8d..08f1b45 100644 --- a/org/ao_read_markup_source.org +++ b/org/ao_read_markup_source.org @@ -85,13 +85,13 @@ final char[][] markupSourceContentRawLineArray(in char[] fn_src) {  ** code structure:                                   :ao_read_markup_source.d:  #+name: tangle_ao_read_markup_source  #+BEGIN_SRC d :tangle ../lib/sdp/ao_read_markup_source.d -/* +/+    read markup source    ao_read_markup_source.d -*/ ++/  mixin template SiSUmarkupRaw() { -  class MarkupRaw { -    auto rgx = new Rgx(); +  struct MarkupRaw { +    auto rgx = Rgx();      <<ao_read_markup_source>>    }  } diff --git a/org/ao_rgx.org b/org/ao_rgx.org index 1292bf8..7306cd3 100644 --- a/org/ao_rgx.org +++ b/org/ao_rgx.org @@ -17,7 +17,7 @@  ** misc                                                                :misc:  #+name: ao_rgx  #+BEGIN_SRC d -/* misc */ +/+ 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])$`); @@ -42,20 +42,20 @@ static levels_numbered_headings  = ctRegex!(`^[0-7]$`);  ** markup insert file                                           :insert:file:  #+name: ao_rgx  #+BEGIN_SRC d -/* 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]`);  #+END_SRC  ** comments                                                         :comment:  #+name: ao_rgx  #+BEGIN_SRC d -/* comments */ +/+ comments +/  static comment                   = ctRegex!(`^%+ `);  #+END_SRC  ** header                                                            :header:  #+name: ao_rgx  #+BEGIN_SRC d -/* header */ +/+ header +/  static header                    = ctRegex!(`^@([a-z_]+):(?:\s|$)`);  static header_make               = ctRegex!(`^@(make):(?:\s|$)`);  static header_metadata           = ctRegex!(`^@([a-z_]+):(?:\s|$)`); @@ -66,7 +66,7 @@ static head_sub                  = ctRegex!(`^[ ]*:([a-z_]+):\s+(.+)`, "m");  ** header & paragraph operators                          :paragraph:operator:  #+name: ao_rgx  #+BEGIN_SRC d -/* 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+(.+?)$`); @@ -82,7 +82,7 @@ static para_attribs       = ctRegex!(`^_(([0-9])(_([0-9]))?|_([1-9])?[*]) `);  ** blocked markup tics                                            :block:tic:  #+name: ao_rgx  #+BEGIN_SRC d -/* 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)"); @@ -94,7 +94,7 @@ static block_tic_close           = ctRegex!("^(`{3})$","m");  ** blocked markup curly                                         :block:curly:  #+name: ao_rgx  #+BEGIN_SRC d -/* 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[{].*?$)`); @@ -111,7 +111,7 @@ static block_curly_table_close   = ctRegex!(`^([}]table)`);  ** inline markup font face mod                             :inline:font:face:  #+name: ao_rgx  #+BEGIN_SRC d -/* 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>.+?)\}/`); @@ -124,7 +124,7 @@ static inline_mono               = ctRegex!(`#\{(?P<text>.+?)\}#`);  ** inline markup footnotes                                  :inline:footnote:  #+name: ao_rgx  #+BEGIN_SRC d -/* 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"); @@ -155,7 +155,7 @@ static inline_note_square_delimiters         = ctRegex!(`(~\[\s*)(.+?)(\]~)`, "m  ** inline markup book index                                :inline:bookindex:  #+name: ao_rgx  #+BEGIN_SRC d -/* 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 @@ -163,7 +163,7 @@ static book_index_close          = ctRegex!(`^(.*?)\}$`, "m"); // strip  ** no ocn object                                              :ocn:off:object:  #+name: ao_rgx  #+BEGIN_SRC d -/* no ocn object */ +/+ no ocn object +/  static ocn_off                   = ctRegex!(`~#$`, "m");  static ocn_off_dh                = ctRegex!(`-#$`, "m");  static ocn_off_all               = ctRegex!(`[~-]#$`, "m"); @@ -171,7 +171,7 @@ static ocn_off_all               = ctRegex!(`[~-]#$`, "m");  ** no ocn block                                               :ocn:off:block:  #+name: ao_rgx  #+BEGIN_SRC d -/* no ocn block */ +/+ no ocn block +/  static ocn_off_block             = ctRegex!(`^--~#$`);  static ocn_off_block_dh          = ctRegex!(`^---#$`);  static ocn_off_block_close       = ctRegex!(`^--\+#$`); @@ -181,13 +181,13 @@ static ocn_block_marks           = ctRegex!(`^--[+~-]#$`);  ** ignore outside code blocks                                    :block:code:  #+name: ao_rgx  #+BEGIN_SRC d -/* ignore outside code blocks */ +/+ ignore outside code blocks +/  static regular_parse_skip        = ctRegex!(`^(--[+~-]#|-[\\]{2}-|=[.\\]{2}=)$`); // not structural info  #+END_SRC  ** line & page breaks                                                 :break:  #+name: ao_rgx  #+BEGIN_SRC d -/* 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}-$`); @@ -200,13 +200,13 @@ static parent                    = ctRegex!(`([0-7]):([0-9]+)`);  ** json                                                                :json:  #+name: ao_rgx  #+BEGIN_SRC d -/* json */ +/+ json +/  static tailing_comma             = ctRegex!(`,$`, "m");  #+END_SRC  ** head                                                              :header:  #+name: ao_rgx  #+BEGIN_SRC d -/* 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"); @@ -222,14 +222,14 @@ static subhead_make              = ctRegex!(`^(?:cover_image|home_button_image|h  ** biblio tags                                                  :biblio:tags:  #+name: ao_rgx  #+BEGIN_SRC d -/* 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)$`);  #+END_SRC  ** bookindex split                                          :bookindex:split:  #+name: ao_rgx  #+BEGIN_SRC d -/* 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*`); @@ -239,12 +239,12 @@ static bi_term_and_ocns_match    = ctRegex!(`^(.+?)\+(\d+)`);  ** code structure:                                                   :ao_rgx.d:  #+name: tangle_ao_rgx  #+BEGIN_SRC d :tangle ../lib/sdp/ao_rgx.d -/* +/+    regex    ao_rgx.d -*/ ++/  mixin template RgxInit() { -  class Rgx { +  struct Rgx {      <<ao_rgx>>    }  } diff --git a/org/ao_scan_inserts.org b/org/ao_scan_inserts.org index 930d875..2b76960 100644 --- a/org/ao_scan_inserts.org +++ b/org/ao_scan_inserts.org @@ -19,16 +19,10 @@  *** scan subdoc source  #+name: ao_inserts_scan  #+BEGIN_SRC d -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; @@ -36,6 +30,7 @@ int tell_l(string color, in char[] line) {  auto fn_pth_full = match(fn_src, rgx.src_pth);  auto markup_src_file_path = fn_pth_full.captures[1];  #+END_SRC +  *** loop insert (sub-document)  #+name: ao_inserts_scan_loop  #+BEGIN_SRC d @@ -45,44 +40,36 @@ if (ft1["curly_code"] == 1) {    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; @@ -90,7 +77,7 @@ if (ft1["curly_code"] == 1) {    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 @@ -102,7 +89,7 @@ if (ft1["curly_code"] == 1) {        markup_sourcesubfile_insert_content.length      );    } -  auto ins = new Inserts(); +  auto ins = Inserts();    /+      1. load file,      2. read lines; @@ -115,31 +102,24 @@ if (ft1["curly_code"] == 1) {  } 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 +  *** post loop  #+name: ao_inserts_scan_post  #+BEGIN_SRC d -auto contents_ = cont_arbitrary_max_length_set_[0 .. counter["add"]].dup; -auto t = tuple(contents_, add); -return t; +return contents_insert;  #+END_SRC  ** scan document source                                            :scan_src:  *** scan doc source  #+name: ao_doc_scan  #+BEGIN_SRC d -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(); +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; @@ -147,6 +127,7 @@ int tell_l(string color, in char[] line) {  auto fn_pth_full = match(fn_src, rgx.src_pth);  auto markup_src_file_path = fn_pth_full.captures[1];  #+END_SRC +  *** loop insert (document)  #+name: ao_doc_scan_loop  #+BEGIN_SRC d @@ -156,49 +137,42 @@ if (ft["curly_code"] == 1) {    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; @@ -206,7 +180,7 @@ if (ft["curly_code"] == 1) {    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 @@ -217,15 +191,12 @@ if (ft["curly_code"] == 1) {        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; @@ -238,18 +209,16 @@ if (ft["curly_code"] == 1) {  } else {    ft["header_make"] = 0;    ft["header_metadata"] = 0; -  cont_arbitrary_max_length_set[add] = line; -  ++add; +  contents ~= line;  }  #+END_SRC +  *** post loop  #+name: ao_doc_scan_post  #+BEGIN_SRC d -auto contents = cont_arbitrary_max_length_set[0..add].dup;  debug(insert) {                              // insert file    writeln(__LINE__);    writeln(contents.length); -  writeln(add);  }  return contents;  #+END_SRC @@ -263,9 +232,11 @@ return contents;    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      ) {        <<ao_inserts_scan>>        foreach (line; markup_sourcefile_insert_content) { @@ -273,7 +244,10 @@ mixin template SiSUdocInserts() {        } // end src subdoc (inserts) loop        <<ao_inserts_scan_post>>      } -    auto scan_doc_source(char[][] markup_sourcefile_content, string fn_src) { +    auto scan_doc_source( +      char[][] markup_sourcefile_content, +      string fn_src +    ) {        <<ao_doc_scan>>        foreach (line; markup_sourcefile_content) {          <<ao_doc_scan_loop>> diff --git a/org/ao_structs.org b/org/ao_structs.org new file mode 100644 index 0000000..9350eb5 --- /dev/null +++ b/org/ao_structs.org @@ -0,0 +1,71 @@ +#+TITLE: sdp structs +#+AUTHOR: Ralph Amissah +#+EMAIL: ralph.amissah@gmail.com +#+STARTUP: indent +#+LANGUAGE: en +#+OPTIONS: H:3 num:nil toc:t \n:nil @:t ::t |:t ^:nil _:nil -:t f:t *:t <:t +#+OPTIONS: TeX:t LaTeX:t skip:nil d:nil todo:t pri:nil tags:not-in-toc +#+OPTIONS: author:nil email:nil creator:nil timestamp:nil +#+PROPERTY: header-args :padline no :exports code :noweb yes +#+EXPORT_SELECT_TAGS: export +#+EXPORT_EXCLUDE_TAGS: noexport +#+FILETAGS: :sdp:dev:ao: +#+TAGS: assert(a) class(c) debug(d) mixin(m) sdp(s) tangle(T) template(t) WEB(W) noexport(n) + +* structs                                                            :struct: +[[./sdp.org][sdp]] + +** initialize +#+name: structs +#+BEGIN_SRC 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; +  } +} +#+END_SRC + +* tangles                                                            :tangle: +** code structure:                                :ao_structs.d: +#+name: tangle_ao_structs +#+BEGIN_SRC d :tangle ../lib/sdp/ao_structs.d +/+ +  structs +  ao_structs.d ++/ +<<structs>> +#+END_SRC diff --git a/org/ao_utils.org b/org/ao_utils.org index 2d29628..3e1e42d 100644 --- a/org/ao_utils.org +++ b/org/ao_utils.org @@ -104,10 +104,10 @@ writefln("Inside function %s at file %s, line %s",  ** code structure:                                                   :ao_util.d:  #+name: tangle_ao_utils  #+BEGIN_SRC d :tangle ../lib/sdp/ao_utils.d -/* +/+    utils    ao_util.d -*/ ++/  mixin template ScreenTxtColors() {    <<ao_utils>>  } diff --git a/org/compile_time_info.org b/org/compile_time_info.org new file mode 100644 index 0000000..d733d0b --- /dev/null +++ b/org/compile_time_info.org @@ -0,0 +1,101 @@ +#+TITLE: sdp compile time info +#+AUTHOR: Ralph Amissah +#+EMAIL: ralph.amissah@gmail.com +#+STARTUP: indent +#+LANGUAGE: en +#+OPTIONS: H:3 num:nil toc:t \n:nil @:t ::t |:t ^:nil _:nil -:t f:t *:t <:t +#+OPTIONS: TeX:t LaTeX:t skip:nil d:nil todo:t pri:nil tags:not-in-toc +#+OPTIONS: author:nil email:nil creator:nil timestamp:nil +#+PROPERTY: header-args :padline no :exports code :noweb yes +#+EXPORT_SELECT_TAGS: export +#+EXPORT_EXCLUDE_TAGS: noexport +#+FILETAGS: :sdp:niu:compile:info: +#+TAGS: assert(a) class(c) debug(d) mixin(m) sdp(s) tangle(T) template(t) WEB(W) noexport(n) + +* compilation info                                                  :compile: +[[../maker.org][maker.org makefile]] +[[./sdp.org][sdp hub]]  [[./][org/]] + +e.g. do on linux bsd osx not windows: +version(Windows) {} else { ... } + +*** complile time os +OS type shows during compilation + +**** set os flags +#+name: sdp_compile_time_info +#+BEGIN_SRC d +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"); +} +#+END_SRC + +*** complile time static if os +OS type compiled in and shows during program run + +**** report os flag (set) (not used here) +#+BEGIN_SRC d +static if(sysWindows) { +  writeln("Windows"); +} else static if(sysOSX) { +  writeln("OSX"); +} else static if(sysLinux) { +  writeln("Linux"); +} else static if(sysFreeBSD) { +  writeln("FreeBSD"); +} else static if(sysOpenBSD) { +  writeln("OpenBSD"); +} else static if(sysNetBSD) { +  writeln("NetBSD"); +} else static if(sysDragonFlyBSD) { +  writeln("DragonFlyBSD"); +} else { +  writeln("other"); +} +#+END_SRC + +*** 64 bit compilation? +#+name: sdp_compile_time_info +#+BEGIN_SRC d +version(D_LP64) { +  enum bits = "64 bit"; +} else { +  enum bits = "32 bit"; +} +#+END_SRC + +* tangles                                                            :tangle: +** code structure                                                    :sdp.d: +#+begin_src d  :tangle ../lib/sdp/compile_time_info.d +/+ +  compile_time_info +  compile_time_info.d ++/ +mixin template CompileTimeInfo() { +  <<sdp_compile_time_info>> +} +#+end_src diff --git a/org/sdp.org b/org/sdp.org index bd0ad84..e8e100a 100644 --- a/org/sdp.org +++ b/org/sdp.org @@ -17,20 +17,34 @@  Deal with imports.  Take command line instructions and process files as instructed. +** TODO version, (version.txt) set version (with structure)         :version: + +#+NAME: version_txt +#+BEGIN_SRC d +struct Version { +  int major; +  int minor; +  int patch; +} +enum ver = Version(1, 0, 0); +#+END_SRC +  ** imports                                                           :import: +[[./compile_time_info.org][compile time info]]  [[./ao_abstract_doc_source.org][ao_abstract_doc_source]]  [[./ao_assertions.org][ao_assertions]]  [[./ao_defaults.org][ao_defaults]] -[[./ao_emitters_and_interfaces.org][ao_emitters_and_interfaces: ao_emitter; ao_interface]] +[[./ao_emitter.org][ao_emitter]]  [[./ao_read_markup_source.org][ao_read_markup_source]] -// [[./ao_read_markup_source.org][ao_read_markup_source]]  [[./ao_object_setter.org][ao_object_setter]]  [[./ao_output_debugs.org][ao_output_debugs]]  [[./ao_rgx.org][ao_rgx]]  [[./ao_scan_inserts.org][ao_scan_inserts]] +[[./ao_structs.org][ao_structs]]  [[./ao_utils.org][ao_utils]] -#+name: sdp_imports +*** std                                                          :import:std: +#+NAME: sdp_imports  #+BEGIN_SRC d  /+ sdp  sisu document parser +/  import @@ -50,24 +64,60 @@ import    std.typecons,    std.utf,    // std.variant, +  std.conv : to; +#+END_SRC + +*** sdp                                                          :import:sdp: +**** TODO lib/sdp.d +#+NAME: sdp_imports_use +#+BEGIN_SRC d +/+ 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; +#+END_SRC + +**** TODO lib/sdp/std.d (rdmd)                                         :rdmd: +#+NAME: sdp_imports_rdmd +#+BEGIN_SRC d +/+ sdp  sisu document parser +/ +import +  compile_time_info,            // compile_time_info.d +  ao_abstract_doc_source,       // ao_abstract_doc_source.d +  ao_assertions,                // ao_assertions.d +  ao_defaults,                  // ao_defaults.d +  ao_emitter,                   // ao_emitter.d +  ao_read_markup_source,        // sdp/ao_read_markup_source.d +  ao_object_setter,             // ao_object_setter.d +  ao_output_debugs,             // ao_output_debugs.d +  ao_rgx,                       // ao_rgx.d +  ao_scan_inserts,              // ao_scan_inserts.d +  ao_structs,                   // ao_structs.d +  ao_utils;                     // ao_utils.d +  // std.conv; +#+END_SRC + +*** version.txt                                                     :version: +#+NAME: sdp_version_mixin +#+BEGIN_SRC d +// import std.stdio; +mixin(import("version.txt"));  #+END_SRC  ** argv [+3]                                                           :argv:  *** argv mixins & init -#+name: sdp_argv +#+NAME: sdp_argv  #+BEGIN_SRC d  mixin SiSUheader;  mixin SiSUbiblio; @@ -77,10 +127,10 @@ mixin SiSUdocInserts;  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; @@ -88,47 +138,60 @@ auto dbg = new SDPoutputDebugs();  //   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");  }  #+END_SRC  *** argv loop -#+name: sdp_argv +#+NAME: sdp_argv  #+BEGIN_SRC d  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;    }  }  #+END_SRC @@ -136,29 +199,38 @@ foreach(cmdlnins; argv) {  *** each file [+2]                                                     :file:  **** filename provided [+1]  ***** scope                                                           :scope: -#+name: sdp_each_file_do +#+NAME: sdp_each_file_do  #+BEGIN_SRC d  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), @@ -167,9 +239,9 @@ enforce(  #+END_SRC  ***** read file                                                   :file:read: -[[./ao_read_markup_source.org][ao_read_markup_source]] +[[./ao_markup_source_raw.org][ao_markup_source_raw]] -#+name: sdp_each_file_do +#+NAME: sdp_each_file_do  #+BEGIN_SRC d  auto markup_sourcefile_content =    raw.markupSourceContentRawLineArray(fn_src); // alternative call @@ -181,7 +253,10 @@ debug(insert) {    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]);  }  #+END_SRC @@ -189,32 +264,35 @@ debug(insert) {  ****** incorporate any inserts  [[./ao_scan_inserts.org][ao_scan_inserts]] -#+name: sdp_each_file_do +#+NAME: sdp_each_file_do  #+BEGIN_SRC d  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);    }  }  #+END_SRC  ***** send for processing                                        :processing: -#+name: sdp_each_file_do +#+NAME: sdp_each_file_do  #+BEGIN_SRC d -/+ 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)); @@ -226,7 +304,7 @@ auto biblio = t[4];  #+END_SRC  ***** debug document parts (checkdoc) -#+name: sdp_each_file_do +#+NAME: sdp_each_file_do  #+BEGIN_SRC d  // DocumentParts  debug(checkdoc) { @@ -245,10 +323,10 @@ debug(checkdoc) {  #+END_SRC  ***** on exit -#+name: sdp_each_file_do +#+NAME: sdp_each_file_do  #+BEGIN_SRC d  scope(exit) { -  destroy(msc); +  destroy(markup_sourcefile_content);    destroy(t);    destroy(contents);    destroy(make_json); @@ -260,25 +338,29 @@ scope(exit) {  #+END_SRC  **** no filename provided -#+name: sdp_no_filename_provided +#+NAME: sdp_no_filename_provided  #+BEGIN_SRC d -/* no recognized filename provided */ +/+ no recognized filename provided +/  writeln("no recognized filename");  break;  // terminate, stop  #+END_SRC  * tangles                                                            :tangle: -** code structure                                                    :sdp.d: -#+name: tangle_sdp +** sdp code structure                                                    :sdp.d: +*** TODO lib/sdp.d  #+BEGIN_SRC d  :tangle ../lib/sdp.d :shebang #!/usr/bin/env rdmd -/* +/+    sdp    sdp.d -*/ ++/  <<sdp_imports>> -mixin RgxInit; mixin Interfaces; mixin Emitters; +<<sdp_imports_use>> +<<sdp_version_mixin>> +mixin CompileTimeInfo; +mixin RgxInit; mixin Emitters;  void main(string[] argv) { +  <<sdp_compilation>>    <<sdp_argv>>    foreach(fn_src; fns_src) {      if (!empty(fn_src)) { @@ -289,3 +371,18 @@ void main(string[] argv) {    }  }  #+end_src + +** version.txt                                                      :version: + +*** TODO lib/version.txt +#+BEGIN_SRC d  :tangle ../lib/version.txt +/+ obt - org generated file +/ +<<version_txt>> +#+END_SRC + +*** TODO lib/sdp/version.txt                                           :rdmd: +#+BEGIN_SRC d  :tangle ../lib/sdp/version.txt +/+ obt - org generated file +/ +// [used by rdmd] +<<version_txt>> +#+END_SRC | 
