diff options
| author | Ralph Amissah <ralph@amissah.com> | 2016-09-06 20:58:58 -0400 | 
|---|---|---|
| committer | Ralph Amissah <ralph@amissah.com> | 2019-04-10 15:14:13 -0400 | 
| commit | ff78ec1fffc029a6947528f4b546dde57a633549 (patch) | |
| tree | 7b77ccd936719da2538ade75d3bdeb4a8c490a59 | |
| parent | naming of para indent attributes (diff) | |
0.6.8 work on heading & anchor tag attributes, re-fix header_make headings
| -rw-r--r-- | org/ao_abstract_doc_source.org | 83 | ||||
| -rw-r--r-- | org/ao_defaults.org | 1 | ||||
| -rw-r--r-- | org/sdp.org | 2 | ||||
| -rw-r--r-- | src/sdp/ao_abstract_doc_source.d | 37 | ||||
| -rw-r--r-- | src/sdp/ao_object_setter.d | 34 | ||||
| -rw-r--r-- | src/sdp/ao_rgx.d | 1 | ||||
| -rw-r--r-- | views/version.txt | 2 | 
7 files changed, 108 insertions, 52 deletions
| diff --git a/org/ao_abstract_doc_source.org b/org/ao_abstract_doc_source.org index b2f38c8..6bbf233 100644 --- a/org/ao_abstract_doc_source.org +++ b/org/ao_abstract_doc_source.org @@ -463,11 +463,11 @@ if (matchFirst(line, rgx.block_open)) {      && ((type["para"] == State.off)      && (type["heading"] == State.off))) {        /+ heading or para but neither flag nor line exists +/ -      if ((to!string(dochead_make_json["make"]["headings"]).length > 2) +      if ((dochead_make_aa["make"]["headings"].length > 2)        && (type["make_headings"] == State.off)) {          /+ heading found +/          auto dochead_make_headings = -          to!string(dochead_make_json["make"]["headings"]); +          dochead_make_aa["make"]["headings"];          heading_found(line, dochead_make_headings, heading_match_str, heading_match_rgx, type);        }        if ((type["make_headings"] == State.on) @@ -480,7 +480,7 @@ if (matchFirst(line, rgx.block_open)) {        }        if (matchFirst(line, rgx.heading)) {          /+ heading match +/ -        heading_matched(line, line_occur, an_object, lv, collapsed_lev, type, dochead_meta_json); +        heading_matched(line, line_occur, an_object, lv, collapsed_lev, type, dochead_meta_aa);        } else if (line_occur["para"] == State.off) {          /+ para match +/          para_match(line, an_object, indent, bullet, type, line_occur); @@ -1773,7 +1773,7 @@ auto block_flag_line_empty(      an_object["attrib"] =        obj_att.obj_attributes(an_object["is"], an_object["obj"], node);      contents_the_objects ~= -      set_abstract_object.contents_block( +      set_abstract_object.contents_block_code(          an_object["is"],          an_object["substantive"],          an_object["attrib"], @@ -2007,19 +2007,15 @@ auto heading_found(    ref Regex!(char)[string] heading_match_rgx,    ref int[string] type  ) { -  if ((to!string(dochead_make_headings).length > 2) +  if ((dochead_make_headings.length > 2)    && (type["make_headings"] == State.off)) {      /+ headings found +/      debug(headingsfound) {        writeln(dochead_make_headings);      } -    auto make_headings_txt = -      match( -        to!string(dochead_make_headings), -        rgx.within_quotes);      char[][] make_headings_spl =        split( -        cast(char[]) make_headings_txt.captures[1], +        cast(char[]) dochead_make_headings,          rgx.make_heading_delimiter);      debug(headingsfound) {        writeln(make_headings_spl.length); @@ -2163,7 +2159,7 @@ auto heading_matched(    ref int[string] lv,    ref int[string] collapsed_lev,    ref int[string] type, -  ref string[string][string] dochead_meta_json +  ref string[string][string] dochead_meta_aa  ) {    if (auto m = match(line, rgx.heading)) {      /+ heading match +/ @@ -2177,8 +2173,8 @@ auto heading_matched(      assertions_doc_structure(an_object, lv); // includes most of the logic for collapsed levels      switch (an_object["lev"]) {      case "A": -      an_object["obj"]=replaceFirst(an_object["obj"], rgx.variable_doc_title, to!string(dochead_meta_json["title"]["main"])); -      an_object["obj"]=replaceFirst(an_object["obj"], rgx.variable_doc_author, to!string(dochead_meta_json["creator"]["author"])); +      an_object["obj"]=replaceFirst(an_object["obj"], rgx.variable_doc_title, to!string(dochead_meta_aa["title"]["main"])); +      an_object["obj"]=replaceFirst(an_object["obj"], rgx.variable_doc_author, to!string(dochead_meta_aa["creator"]["author"]));        collapsed_lev["h0"] = 1;        an_object["lev_collapsed_number"] =          to!string(collapsed_lev["h0"]); @@ -3271,10 +3267,7 @@ struct NotesSection {      ++obj_cite_number;      ++mkn;      foreach (endnote; endnotes_) { -      type="para";        attrib=""; -      indent["first"] = "0"; -      indent["second"] = "0";        attrib="";        // endnotes ~=        //   set_abstract_object.contents_para( @@ -3284,15 +3277,9 @@ struct NotesSection {        //     false        //   );        endnotes_section ~= -        set_abstract_object.contents_para( -          type, +        set_abstract_object.contents_endnote(            endnote, -          attrib, -          obj_cite_number, -          indent, -          false          ); -      ++obj_cite_number;        ++mkn;      }      auto t = tuple(endnotes_section, obj_cite_number); @@ -3874,6 +3861,7 @@ struct ParaAttrib {    bool bullet               = false;  }  struct BlockAttrib { +  string syntax                 = "";  }  struct Comment {    // no .attrib and no .obj_cite_number @@ -3967,6 +3955,29 @@ auto contents_para(  }  #+END_SRC +*** para_endnote                                                       :para: + +#+name: ao_object_setter +#+BEGIN_SRC d +auto contents_endnote( +  in string object, +) { +  auto m = (matchFirst(object, rgx.note_ref)); +  string notenumber = to!string(m.captures[1]); +  string anchor_tag = "note_" ~ notenumber; +  ObjComposite object_set; +  object_set.use                      = "content"; +  object_set.of                       = "para"; +  object_set.is_a                     = "endnote"; +  object_set.object                   = object.strip; +  object_set.obj_cite_number          = ""; +  object_set.para_attrib.indent_start = 0; +  object_set.para_attrib.indent_rest  = 0; +  object_set.para_attrib.bullet       = false; +  return object_set; +} +#+END_SRC +  *** block                                                             :block:  #+name: ao_object_setter @@ -3988,6 +3999,28 @@ auto contents_block(  }  #+END_SRC +*** block code                                                   :block:code: + +#+name: ao_object_setter +#+BEGIN_SRC d +auto contents_block_code( +  in string type, +  in string object, +  in string attrib_language_syntax, +  in int obj_cite_number +) { +  ObjComposite object_set; +  object_set.use                 = "content"; +  object_set.of                  = "block"; +  object_set.is_a                = type; +  object_set.block_attrib.syntax = attrib_language_syntax; +  object_set.object              = object; +  object_set.obj_cite_number     = (obj_cite_number==0) ? "" : to!string(obj_cite_number); +  // object_set.node_structure.node               = node; +  return object_set; +} +#+END_SRC +  *** block obj_cite_number string                                      :block:  #+name: ao_object_setter @@ -4029,8 +4062,8 @@ template SiSUdocAbstraction() {      /+ ↓ abstract marked up document +/      auto abstract_doc_source(        char[][] markup_sourcefile_content, -      string[string][string] dochead_make_json, -      string[string][string] dochead_meta_json +      string[string][string] dochead_make_aa, +      string[string][string] dochead_meta_aa      ) {        /+ ↓ abstraction init +/        <<abs_init_rest>> diff --git a/org/ao_defaults.org b/org/ao_defaults.org index 78b1de8..3ea0a6f 100644 --- a/org/ao_defaults.org +++ b/org/ao_defaults.org @@ -721,6 +721,7 @@ static inline_notes_square                   = ctRegex!(`~\[\s*(.+?)\]~`, "mg");  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"); +static note_ref                              = ctRegex!(`^\S+?noteref_([0-9]+)`, "mg");     // {^{73.}^}#noteref_73  #+END_SRC  ** inline markup book index                                :inline:bookindex: diff --git a/org/sdp.org b/org/sdp.org index 2c28c18..af16b3d 100644 --- a/org/sdp.org +++ b/org/sdp.org @@ -24,7 +24,7 @@ struct Version {    int minor;    int patch;  } -enum ver = Version(0, 6, 7); +enum ver = Version(0, 6, 8);  #+END_SRC  * sdp.d   sisu document parser                                       :sdp.d: diff --git a/src/sdp/ao_abstract_doc_source.d b/src/sdp/ao_abstract_doc_source.d index 3971db1..0ef486e 100644 --- a/src/sdp/ao_abstract_doc_source.d +++ b/src/sdp/ao_abstract_doc_source.d @@ -109,8 +109,8 @@ template SiSUdocAbstraction() {      /+ ↓ abstract marked up document +/      auto abstract_doc_source(        char[][] markup_sourcefile_content, -      string[string][string] dochead_make_json, -      string[string][string] dochead_meta_json +      string[string][string] dochead_make_aa, +      string[string][string] dochead_meta_aa      ) {        /+ ↓ abstraction init +/        scope(success) { @@ -327,11 +327,11 @@ template SiSUdocAbstraction() {                  && ((type["para"] == State.off)                  && (type["heading"] == State.off))) {                    /+ heading or para but neither flag nor line exists +/ -                  if ((to!string(dochead_make_json["make"]["headings"]).length > 2) +                  if ((dochead_make_aa["make"]["headings"].length > 2)                    && (type["make_headings"] == State.off)) {                      /+ heading found +/                      auto dochead_make_headings = -                      to!string(dochead_make_json["make"]["headings"]); +                      dochead_make_aa["make"]["headings"];                      heading_found(line, dochead_make_headings, heading_match_str, heading_match_rgx, type);                    }                    if ((type["make_headings"] == State.on) @@ -344,7 +344,7 @@ template SiSUdocAbstraction() {                    }                    if (matchFirst(line, rgx.heading)) {                      /+ heading match +/ -                    heading_matched(line, line_occur, an_object, lv, collapsed_lev, type, dochead_meta_json); +                    heading_matched(line, line_occur, an_object, lv, collapsed_lev, type, dochead_meta_aa);                    } else if (line_occur["para"] == State.off) {                      /+ para match +/                      para_match(line, an_object, indent, bullet, type, line_occur); @@ -1381,7 +1381,7 @@ template SiSUdocAbstraction() {          an_object["attrib"] =            obj_att.obj_attributes(an_object["is"], an_object["obj"], node);          contents_the_objects ~= -          set_abstract_object.contents_block( +          set_abstract_object.contents_block_code(              an_object["is"],              an_object["substantive"],              an_object["attrib"], @@ -1602,19 +1602,15 @@ template SiSUdocAbstraction() {        ref Regex!(char)[string] heading_match_rgx,        ref int[string] type      ) { -      if ((to!string(dochead_make_headings).length > 2) +      if ((dochead_make_headings.length > 2)        && (type["make_headings"] == State.off)) {          /+ headings found +/          debug(headingsfound) {            writeln(dochead_make_headings);          } -        auto make_headings_txt = -          match( -            to!string(dochead_make_headings), -            rgx.within_quotes);          char[][] make_headings_spl =            split( -            cast(char[]) make_headings_txt.captures[1], +            cast(char[]) dochead_make_headings,              rgx.make_heading_delimiter);          debug(headingsfound) {            writeln(make_headings_spl.length); @@ -1746,7 +1742,7 @@ template SiSUdocAbstraction() {        ref int[string] lv,        ref int[string] collapsed_lev,        ref int[string] type, -      ref string[string][string] dochead_meta_json +      ref string[string][string] dochead_meta_aa      ) {        if (auto m = match(line, rgx.heading)) {          /+ heading match +/ @@ -1760,8 +1756,8 @@ template SiSUdocAbstraction() {          assertions_doc_structure(an_object, lv); // includes most of the logic for collapsed levels          switch (an_object["lev"]) {          case "A": -          an_object["obj"]=replaceFirst(an_object["obj"], rgx.variable_doc_title, to!string(dochead_meta_json["title"]["main"])); -          an_object["obj"]=replaceFirst(an_object["obj"], rgx.variable_doc_author, to!string(dochead_meta_json["creator"]["author"])); +          an_object["obj"]=replaceFirst(an_object["obj"], rgx.variable_doc_title, to!string(dochead_meta_aa["title"]["main"])); +          an_object["obj"]=replaceFirst(an_object["obj"], rgx.variable_doc_author, to!string(dochead_meta_aa["creator"]["author"]));            collapsed_lev["h0"] = 1;            an_object["lev_collapsed_number"] =              to!string(collapsed_lev["h0"]); @@ -2781,10 +2777,7 @@ template SiSUdocAbstraction() {          ++obj_cite_number;          ++mkn;          foreach (endnote; endnotes_) { -          type="para";            attrib=""; -          indent["first"] = "0"; -          indent["second"] = "0";            attrib="";            // endnotes ~=            //   set_abstract_object.contents_para( @@ -2794,15 +2787,9 @@ template SiSUdocAbstraction() {            //     false            //   );            endnotes_section ~= -            set_abstract_object.contents_para( -              type, +            set_abstract_object.contents_endnote(                endnote, -              attrib, -              obj_cite_number, -              indent, -              false              ); -          ++obj_cite_number;            ++mkn;          }          auto t = tuple(endnotes_section, obj_cite_number); diff --git a/src/sdp/ao_object_setter.d b/src/sdp/ao_object_setter.d index bb7a17e..0d8107c 100644 --- a/src/sdp/ao_object_setter.d +++ b/src/sdp/ao_object_setter.d @@ -15,6 +15,7 @@ template ObjectSetter() {      bool bullet               = false;    }    struct BlockAttrib { +    string syntax                 = "";    }    struct Comment {      // no .attrib and no .obj_cite_number @@ -89,6 +90,23 @@ template ObjectSetter() {        // object_set.node_structure.node               = node;        return object_set;      } +    auto contents_endnote( +      in string object, +    ) { +      auto m = (matchFirst(object, rgx.note_ref)); +      string notenumber = to!string(m.captures[1]); +      string anchor_tag = "note_" ~ notenumber; +      ObjComposite object_set; +      object_set.use                      = "content"; +      object_set.of                       = "para"; +      object_set.is_a                     = "endnote"; +      object_set.object                   = object.strip; +      object_set.obj_cite_number          = ""; +      object_set.para_attrib.indent_start = 0; +      object_set.para_attrib.indent_rest  = 0; +      object_set.para_attrib.bullet       = false; +      return object_set; +    }      auto contents_block(        in string type,        in string object, @@ -104,6 +122,22 @@ template ObjectSetter() {        // object_set.node_structure.node               = node;        return object_set;      } +    auto contents_block_code( +      in string type, +      in string object, +      in string attrib_language_syntax, +      in int obj_cite_number +    ) { +      ObjComposite object_set; +      object_set.use                 = "content"; +      object_set.of                  = "block"; +      object_set.is_a                = type; +      object_set.block_attrib.syntax = attrib_language_syntax; +      object_set.object              = object; +      object_set.obj_cite_number     = (obj_cite_number==0) ? "" : to!string(obj_cite_number); +      // object_set.node_structure.node               = node; +      return object_set; +    }      auto contents_block_obj_cite_number_string(        in string type,        in string object, diff --git a/src/sdp/ao_rgx.d b/src/sdp/ao_rgx.d index 15f9ed9..cd97a02 100644 --- a/src/sdp/ao_rgx.d +++ b/src/sdp/ao_rgx.d @@ -149,6 +149,7 @@ 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"); +    static note_ref                              = ctRegex!(`^\S+?noteref_([0-9]+)`, "mg");     // {^{73.}^}#noteref_73      /+ inline markup book index +/      static book_index                = ctRegex!(`^=\{\s*(.+?)\}$`, "m");      static book_index_open           = ctRegex!(`^=\{\s*([^}]+?)$`); diff --git a/views/version.txt b/views/version.txt index 074c093..8aa3390 100644 --- a/views/version.txt +++ b/views/version.txt @@ -4,4 +4,4 @@ struct Version {    int minor;    int patch;  } -enum ver = Version(0, 6, 7); +enum ver = Version(0, 6, 8); | 
