diff options
| author | Ralph Amissah <ralph.amissah@gmail.com> | 2020-04-28 22:47:10 -0400 | 
|---|---|---|
| committer | Ralph Amissah <ralph.amissah@gmail.com> | 2020-05-20 11:27:26 -0400 | 
| commit | 33d4cd24013c8660c100a0070802a0e9d1211421 (patch) | |
| tree | 104a4739bbc12a749b9b7a1aef56aec2ef8ec4c7 /org | |
| parent | 0.11.0 in_source_files, changed tracking of code blocks (diff) | |
metaverse, doc structure & blocks, change tracking
Diffstat (limited to 'org')
| -rw-r--r-- | org/default_misc.org | 32 | ||||
| -rw-r--r-- | org/default_regex.org | 6 | ||||
| -rw-r--r-- | org/metaverse.org | 78 | 
3 files changed, 74 insertions, 42 deletions
diff --git a/org/default_misc.org b/org/default_misc.org index ab7033f..2ba2b8d 100644 --- a/org/default_misc.org +++ b/org/default_misc.org @@ -37,6 +37,38 @@ module doc_reform.meta.defaults;  #+NAME: meta_defaults_template_init_flags  #+BEGIN_SRC d +template spineDocStatus() { +  @safe static auto status() { +    struct _e { +      enum sect { +        unset, +        head, +        toc, +        substantive, +        bibliography, +        glossary, +        book_index, +        blurb, +      } +      enum block { +        off, +        closing, +        code, +        poem, +        block, +        group, +        table, +        quote, +      } +      enum ocn { +        on,    // 0 object_number; +        off,   // 1 no object_number; +        dummy, // 2 no object_number & dummy headings +      } +    } +    return _e(); +  } +}  template spineRgxDocStructFlags() {    /+ regex flags +/    @safe static int[string] flags_type_init() { diff --git a/org/default_regex.org b/org/default_regex.org index e432a32..6e6ee00 100644 --- a/org/default_regex.org +++ b/org/default_regex.org @@ -253,9 +253,9 @@ static smid_image_delimit                              = ctRegex!(`(?P<pre>^|[ ]  #+NAME: meta_rgx  #+BEGIN_SRC d  /+ inline markup book index +/ -static book_index                                     = ctRegex!(`^=\{\s*(?P<bookindex>.+?)\}$`, "m"); -static book_index_open                                = ctRegex!(`^=\{\s*([^}]*?)$`); -static book_index_close                               = ctRegex!(`^(.*?)\}$`, "m"); +static book_index_item                                = ctRegex!(`^=\{\s*(?P<bookindex>.+?)\}$`, "m"); +static book_index_item_open                           = ctRegex!(`^=\{\s*([^}]*?)$`); +static book_index_item_close                          = ctRegex!(`^(.*?)\}$`, "m");  #+END_SRC  ** switch diff --git a/org/metaverse.org b/org/metaverse.org index b51f4da..88c5e59 100644 --- a/org/metaverse.org +++ b/org/metaverse.org @@ -536,6 +536,7 @@ scope(exit) {  #+NAME: abs_init_rest  #+BEGIN_SRC d  mixin spineRgxDocStructFlags; +mixin spineDocStatus;  mixin spineNode;  auto node_para_int_    = node_metadata_para_int;  auto node_para_str_    = node_metadata_para_str; @@ -559,6 +560,12 @@ uint[string] dochas = [    "images"            : 0,  ];  auto obj_type_status = flags_type_init; +int[string] track = [ +  "section" : 0, +  "block"   : 0, +  "obj"     : 0, +  "ocn"     : 0, +];  string[string] object_number_poem = [    "start" : "",    "end"   : "" @@ -739,18 +746,15 @@ line = line.inline_markup_faces; // by text line (rather than by text object), l  #+NAME: abs_in_loop_body_non_code_obj  #+BEGIN_SRC d  if (line.matchFirst(rgx.heading_biblio) -|| (obj_type_status["biblio_section"] == State.on +|| (track["section"] == status.sect.bibliography    && ((!(line.matchFirst(rgx.heading_glossary)))    && (!(line.matchFirst(rgx.heading_blurb)))    && (!(line.matchFirst(rgx.heading)))    && (!(line.matchFirst(rgx.comment)))))  ) { -  /+ within section (block object): biblio +/ -  obj_type_status["glossary_section"] = State.off; -  obj_type_status["biblio_section"]   = State.on; -  obj_type_status["blurb_section"]    = State.off; +  track["section"] = status.sect.bibliography;    if (opt_action.backmatter && opt_action.section_biblio) { -    line.flow_txt_block_biblio(obj_type_status, bib_entry, biblio_entry_str_json, biblio_arr_json); +    line.flow_txt_block_biblio(obj_type_status, bib_entry, biblio_entry_str_json, biblio_arr_json, track);      debug(bibliobuild) {        writeln("-  ", biblio_entry_str_json);        writeln("-> ", biblio_arr_json.length); @@ -771,7 +775,7 @@ if there is a glossary section you need to:  #+NAME: abs_in_loop_body_non_code_obj  #+BEGIN_SRC d  } else if (line.matchFirst(rgx.heading_glossary) -|| (obj_type_status["glossary_section"] == State.on +|| (track["section"] == status.sect.glossary    && ((!(line.matchFirst(rgx.heading_biblio)))    && (!(line.matchFirst(rgx.heading_blurb)))    && (!(line.matchFirst(rgx.heading))) @@ -782,9 +786,7 @@ if there is a glossary section you need to:      writeln(__LINE__);      writeln(line);    } -  obj_type_status["glossary_section"] = State.on; -  obj_type_status["biblio_section"]   = State.off; -  obj_type_status["blurb_section"]    = State.off; +  track["section"] = status.sect.glossary;    if (opt_action.backmatter && opt_action.section_glossary) {      indent=[        "hang_position" : 0, @@ -881,20 +883,17 @@ if there is a blurb section you need to:  #+NAME: abs_in_loop_body_non_code_obj  #+BEGIN_SRC d  } else if (line.matchFirst(rgx.heading_blurb) -|| (obj_type_status["blurb_section"] == State.on +|| (track["section"] == status.sect.blurb    && ((!(line.matchFirst(rgx.heading_glossary)))    && (!(line.matchFirst(rgx.heading_biblio)))    && (!(line.matchFirst(rgx.heading)))    && (!(line.matchFirst(rgx.comment)))))  ) { -  /+ within section (block object): blurb +/ +  track["section"] = status.sect.blurb;    debug(blurb) {      writeln(__LINE__);      writeln(line);    } -  obj_type_status["glossary_section"] = State.off; -  obj_type_status["biblio_section"]   = State.off; -  obj_type_status["blurb_section"]    = State.on;    if (opt_action.backmatter && opt_action.section_blurb) {      indent=[        "hang_position" : 0, @@ -1139,9 +1138,9 @@ if (obj_type_status["blocks"] == TriState.closing) {      writeln(line);    }    assert( -    line.matchFirst(rgx.book_index) -    || line.matchFirst(rgx.book_index_open) -    || obj_type_status["book_index"] == State.on, +    line.matchFirst(rgx.book_index_item) +    || line.matchFirst(rgx.book_index_item_open) +    || track["section"] == status.sect.book_index,      "\nblocks closed, unless followed by book index, non-matching line:\n  \""      ~ line ~ "\""    ); @@ -1152,10 +1151,10 @@ if (obj_type_status["blocks"] == TriState.closing) {  #+NAME: abs_in_loop_body_not_block_obj  #+BEGIN_SRC d -if (line.matchFirst(rgx.book_index) -|| line.matchFirst(rgx.book_index_open) -|| obj_type_status["book_index"] == State.on )  {                              /+ book_index +/ -  an_object = line.flow_book_index_(an_object, book_idx_tmp, obj_type_status, opt_action); +if (line.matchFirst(rgx.book_index_item) +|| line.matchFirst(rgx.book_index_item_open) +|| track["section"] == status.sect.book_index)  {                              /+ book_index +/ +  an_object = line.flow_book_index_(an_object, book_idx_tmp, obj_type_status, track, opt_action);  #+END_SRC  ******* not book index [+1] @@ -1221,7 +1220,8 @@ if (line.matchFirst(rgx.book_index)          lv,          collapsed_lev,          obj_type_status, -        conf_make_meta +        conf_make_meta, +        track,        );      } else if (line_occur["para"] == State.off) {                              /+ para match +/        an_object_key="body_nugget"; @@ -1512,9 +1512,7 @@ if (the_document_body_section.length > 0) {    && (the_document_body_section.length > previous_length)) {      if ((the_document_body_section[$-1].metainfo.is_a == "heading")      && (the_document_body_section[$-1].metainfo.heading_lev_markup < 5)) { -      obj_type_status["glossary_section"] = State.off; -      obj_type_status["biblio_section"]   = State.off; -      obj_type_status["blurb_section"]    = State.off; +      track["section"] = status.sect.unset;      }      if (the_document_body_section[$-1].metainfo.is_a == "verse") {             /+ scan for endnotes for whole poem (each verse in poem) +/        foreach (i; previous_length .. the_document_body_section.length) { @@ -3658,15 +3656,15 @@ final string biblio_tag_map_()(string abr) {    return ref int[string] obj_type_status,    return ref int         bib_entry,    return ref string      biblio_entry_str_json, -  return ref string[]    biblio_arr_json +  return ref string[]    biblio_arr_json, +  return ref int[string] track,  ) {    mixin spineBiblio; +  mixin spineDocStatus;    auto jsn = BibJsnStr();    static auto rgx = RgxI();    if (line.matchFirst(rgx.heading_biblio)) { -    obj_type_status["glossary_section"] = State.off; -    obj_type_status["biblio_section"]   = TriState.on; -    obj_type_status["blurb_section"]    = State.off; +    track["section"] = status.sect.bibliography;    }    if (line.empty) {      debug { @@ -4671,10 +4669,12 @@ process and use an_object["table_head"] (then empty it)               string[string]  an_object,    return ref string          book_idx_tmp,    return ref int[string]     obj_type_status, +  return ref int[string]     track,               B               opt_action,  ) { +  mixin spineDocStatus;    static auto rgx = RgxI(); -  if (auto m = line.match(rgx.book_index)) {                                   /+ match book_index +/ +  if (auto m = line.match(rgx.book_index_item)) {                                   /+ match book_index +/      debug(bookindexmatch) {        writefln(          "* [bookindex] %s\n", @@ -4682,8 +4682,8 @@ process and use an_object["table_head"] (then empty it)        );      }      an_object["bookindex_nugget"] = m.captures[1].to!string; -  } else if (auto m = line.match(rgx.book_index_open))  {                      /+ match open book_index +/ -    obj_type_status["book_index"] = State.on; +  } else if (auto m = line.match(rgx.book_index_item_open))  {                      /+ match open book_index +/ +    track["section"] = status.sect.book_index;      if (opt_action.backmatter && opt_action.section_bookindex) {        book_idx_tmp = m.captures[1].to!string;        debug(bookindexmatch) { @@ -4693,9 +4693,9 @@ process and use an_object["table_head"] (then empty it)          );        }      } -  } else if (obj_type_status["book_index"] == State.on )  {                    /+ book_index flag set +/ -    if (auto m = line.match(rgx.book_index_close))  { -      obj_type_status["book_index"] = State.off; +  } else if (track["section"] == status.sect.book_index)  {                    /+ book_index flag set +/ +    if (auto m = line.match(rgx.book_index_item_close))  { +      track["section"] = status.sect.unset;        if (opt_action.backmatter        && opt_action.section_bookindex) {          an_object["bookindex_nugget"] = book_idx_tmp ~ m.captures[1].to!string; @@ -4881,16 +4881,16 @@ process and use an_object["table_head"] (then empty it)    return ref int[string]     collapsed_lev,    return ref int[string]     obj_type_status,    return ref CMM             conf_make_meta, +  return ref int[string]     track,  ) { +  mixin spineDocStatus;    static auto rgx = RgxI();    if (auto m = line.match(rgx.headings)) {                                      /+ heading match +/      ++line_occur["heading"];      obj_type_status["heading"]            = State.on;      obj_type_status["para"]               = State.off;      if (line.match(rgx.heading_seg_and_above)) { -      obj_type_status["glossary_section"] = State.off; -      obj_type_status["biblio_section"]   = State.off; -      obj_type_status["blurb_section"]    = State.off; +      track["section"]                    = status.sect.unset;      }      an_object[an_object_key] ~= line ~= "\n";      an_object["lev"] ~= m.captures[1];  | 
