diff options
| author | Ralph Amissah <ralph.amissah@gmail.com> | 2019-04-20 14:44:42 -0400 | 
|---|---|---|
| committer | Ralph Amissah <ralph.amissah@gmail.com> | 2019-05-17 16:59:54 -0400 | 
| commit | d60c328d3bd3d1a8be39dd835b2ee96640490120 (patch) | |
| tree | 9f0c930715dcf9ba2fd5800447b96f49fad1b82c /src/doc_reform | |
| parent | text format delimiter, use: "┃" instead of "┋" (diff) | |
(segmented html) dummy heading related
Diffstat (limited to 'src/doc_reform')
| -rw-r--r-- | src/doc_reform/meta/defaults.d | 2 | ||||
| -rw-r--r-- | src/doc_reform/meta/metadoc_from_src.d | 49 | ||||
| -rw-r--r-- | src/doc_reform/meta/object_setter.d | 1 | ||||
| -rw-r--r-- | src/doc_reform/meta/rgx.d | 4 | ||||
| -rw-r--r-- | src/doc_reform/output/xmls.d | 30 | 
5 files changed, 70 insertions, 16 deletions
| diff --git a/src/doc_reform/meta/defaults.d b/src/doc_reform/meta/defaults.d index 1bfc859..8fb9b89 100644 --- a/src/doc_reform/meta/defaults.d +++ b/src/doc_reform/meta/defaults.d @@ -37,6 +37,8 @@ template DocReformRgxInitFlags() {        "tic_table"                           : 0,        "ocn_status"                          : 0, // 0 object_number; 1 no object_number; 2 no object_number & dummy headings        "ocn_status_off_for_multiple_objects" : 0, // 0 object_number; 1 no object_number; 2 no object_number & dummy headings +      "heading_status"                      : 0, +      "heading_off_for_multiple_objects"    : 0,        "book_index"                          : 0,      ];      return flags_type_init; diff --git a/src/doc_reform/meta/metadoc_from_src.d b/src/doc_reform/meta/metadoc_from_src.d index 3862403..9ad6004 100644 --- a/src/doc_reform/meta/metadoc_from_src.d +++ b/src/doc_reform/meta/metadoc_from_src.d @@ -50,6 +50,7 @@ template DocReformDocAbstraction() {      h_text_5, // extra level, drop      content_non_header    } // header section A-D; header text 1-4 +  enum Status { off, on, }    enum OCNstatus { on, off, bkidx, closing, reset, }    enum OCN_off_block_status { off, on }    enum OCNtype { ocn, non, bkidx, } @@ -406,6 +407,7 @@ template DocReformDocAbstraction() {      comp_obj_heading_.text                                         = "Table of Contents";      comp_obj_heading_.metainfo.ocn                                 = 0;      comp_obj_heading_.metainfo.identifier                          = ""; +    comp_obj_heading_.metainfo.dummy_heading                       = false;      comp_obj_heading_.metainfo.object_number_off                   = true;      comp_obj_heading_.metainfo.object_number_type                  = 0;      comp_obj_heading_.tags.segment_anchor_tag_epub                 = "toc"; @@ -556,6 +558,7 @@ template DocReformDocAbstraction() {                comp_obj_heading_.text                           = "Glossary";                comp_obj_heading_.metainfo.ocn                   = 0;                comp_obj_heading_.metainfo.identifier            = ""; +              comp_obj_heading_.metainfo.dummy_heading         = false;                comp_obj_heading_.metainfo.object_number_off     = true;                comp_obj_heading_.metainfo.object_number_type    = 0;                comp_obj_heading_.tags.segment_anchor_tag_epub   = "_part_glossary"; @@ -578,6 +581,7 @@ template DocReformDocAbstraction() {                comp_obj_heading_.text                           = "Glossary";                comp_obj_heading_.metainfo.ocn                   = 0;                comp_obj_heading_.metainfo.identifier            = ""; +              comp_obj_heading_.metainfo.dummy_heading         = true;                comp_obj_heading_.metainfo.object_number_off     = true;                comp_obj_heading_.metainfo.object_number_type    = 0;                comp_obj_heading_.tags.segment_anchor_tag_epub   = "glossary"; @@ -679,6 +683,7 @@ template DocReformDocAbstraction() {                comp_obj_heading_.text                                         = "Blurb";                comp_obj_heading_.metainfo.ocn                                 = 0;                comp_obj_heading_.metainfo.identifier                          = ""; +              comp_obj_heading_.metainfo.dummy_heading                       = false;                comp_obj_heading_.metainfo.object_number_off                   = true;                comp_obj_heading_.metainfo.object_number_type                  = 0;                comp_obj_heading_.tags.segment_anchor_tag_epub                 = "_part_blurb"; @@ -701,6 +706,7 @@ template DocReformDocAbstraction() {                comp_obj_heading_.text                                         = "Blurb";                comp_obj_heading_.metainfo.ocn                                 = 0;                comp_obj_heading_.metainfo.identifier                          = ""; +              comp_obj_heading_.metainfo.dummy_heading                       = true;                comp_obj_heading_.metainfo.object_number_off                   = true;                comp_obj_heading_.metainfo.object_number_type                  = 0;                comp_obj_heading_.tags.segment_anchor_tag_epub                 = "blurb"; @@ -726,6 +732,7 @@ template DocReformDocAbstraction() {                comp_obj_heading_.text                           = line.to!string;                comp_obj_heading_.metainfo.ocn                   = 0;                comp_obj_heading_.metainfo.identifier            = ""; +              comp_obj_heading_.metainfo.dummy_heading         = false;                comp_obj_heading_.metainfo.object_number_off     = true;                comp_obj_heading_.metainfo.object_number_type    = 0;                comp_obj_heading_.tags.segment_anchor_tag_epub                 = "blurb"; @@ -1037,6 +1044,7 @@ template DocReformDocAbstraction() {                    an_object["substantive"],                    an_object["lev_markup_number"],                    an_object["lev_collapsed_number"], +                  an_object["dummy_heading_status"],                    tag_in_seg,                    lev_anchor_tag,                    tag_assoc, @@ -1203,6 +1211,7 @@ template DocReformDocAbstraction() {        comp_obj_heading_.text                            = "(skip) there is no Glossary section";        comp_obj_heading_.metainfo.ocn                    = 0;        comp_obj_heading_.metainfo.identifier             = ""; +      comp_obj_heading_.metainfo.dummy_heading          = true;        comp_obj_heading_.metainfo.object_number_off      = true;        comp_obj_heading_.metainfo.object_number_type     = 0;        comp_obj_heading_.metainfo.heading_lev_markup     = 1; @@ -1229,6 +1238,7 @@ template DocReformDocAbstraction() {        comp_obj_heading_.text                            = "Bibliography";        comp_obj_heading_.metainfo.ocn                    = 0;        comp_obj_heading_.metainfo.identifier             = ""; +      comp_obj_heading_.metainfo.dummy_heading          = true;        comp_obj_heading_.metainfo.object_number_off      = true;        comp_obj_heading_.metainfo.object_number_type     = 0;        comp_obj_heading_.tags.segment_anchor_tag_epub    = "_part_bibliography"; @@ -1249,6 +1259,7 @@ template DocReformDocAbstraction() {        comp_obj_heading_.text                            = "Bibliography";        comp_obj_heading_.metainfo.ocn                    = 0;        comp_obj_heading_.metainfo.identifier             = ""; +      comp_obj_heading_.metainfo.dummy_heading          = true;        comp_obj_heading_.metainfo.object_number_off      = true;        comp_obj_heading_.metainfo.object_number_type     = 0;        comp_obj_heading_.tags.segment_anchor_tag_epub    = "bibliography"; @@ -1271,6 +1282,7 @@ template DocReformDocAbstraction() {        comp_obj_heading_.text                            = "(skip) there is no Bibliography";        comp_obj_heading_.metainfo.ocn                    = 0;        comp_obj_heading_.metainfo.identifier             = ""; +      comp_obj_heading_.metainfo.dummy_heading          = true;        comp_obj_heading_.metainfo.object_number_off      = true;        comp_obj_heading_.metainfo.object_number_type     = 0;        comp_obj_heading_.metainfo.heading_lev_markup     = 1; @@ -2248,8 +2260,9 @@ template DocReformDocAbstraction() {      comp_obj_heading_.metainfo.is_a                   = "heading";      comp_obj_heading_.metainfo.ocn                    = 0;      comp_obj_heading_.metainfo.identifier             = ""; -    comp_obj_para.metainfo.object_number_off          = true; -    comp_obj_para.metainfo.object_number_type         = 0; +    comp_obj_heading_.metainfo.dummy_heading          = true; +    comp_obj_heading_.metainfo.object_number_off      = true; +    comp_obj_heading_.metainfo.object_number_type     = 0;      comp_obj_heading_.tags.segment_anchor_tag_epub    = "";      comp_obj_heading_.tags.anchor_tag_html            = "";      comp_obj_heading_.tags.in_segment_html            = ""; @@ -2406,8 +2419,9 @@ template DocReformDocAbstraction() {              writeln(line);            }          } -        if (line.matchFirst(rgx.object_number_off_block_dh)) { +        if (line.matchFirst(rgx.object_number_off_block_dummy_heading)) {            obj_type_status["ocn_status_off_for_multiple_objects"] = OCN_off_block_status.on; +          obj_type_status["heading_off_for_multiple_objects"]    = Status.on;            obj_type_status["ocn_status"]                          = OCNstatus.off;            debug(ocnoff) {              writeln(line); @@ -2415,15 +2429,21 @@ template DocReformDocAbstraction() {          }        } else {          if (obj_type_status["ocn_status_off_for_multiple_objects"] == OCN_off_block_status.off) { +          obj_type_status["dummy_heading_status"] = Status.off; +          if (obj_type_status["heading_off_for_multiple_objects"]) { +            obj_type_status["dummy_heading_status"] = Status.on; +          }            if (line.matchFirst(rgx.object_number_off)) {              obj_type_status["ocn_status"] = OCNstatus.off; -          } else if (line.matchFirst(rgx.object_number_off_dh)) { -            obj_type_status["ocn_status"] = OCNstatus.off; +          } else if (line.matchFirst(rgx.object_number_off_dummy_heading)) { +            obj_type_status["ocn_status"]           = OCNstatus.off; +            obj_type_status["dummy_heading_status"] = Status.on;            } else { -            obj_type_status["ocn_status"] = OCNstatus.on; +            obj_type_status["ocn_status"]           = OCNstatus.on; +            obj_type_status["dummy_heading_status"] = Status.off;            }          } else { -          obj_type_status["ocn_status"] = obj_type_status["ocn_status_off_for_multiple_objects"]; +          obj_type_status["ocn_status"]             = obj_type_status["ocn_status_off_for_multiple_objects"];          }        }      } else if ( @@ -2433,6 +2453,7 @@ template DocReformDocAbstraction() {        if (line.matchFirst(rgx.object_number_off_block_close)) {          obj_type_status["ocn_status_off_for_multiple_objects"] = OCN_off_block_status.off;          obj_type_status["ocn_status"]                          = OCNstatus.on; +        obj_type_status["dummy_heading_status"]                = Status.off;          debug(ocnoff) {            writeln(line);          } @@ -3989,6 +4010,7 @@ template DocReformDocAbstraction() {        default:          an_object["lev_markup_number"] = lv["lv"].to!string;        } +      an_object["dummy_heading_status"] = (obj_type_status["dummy_heading_status"] == State.off) ? "f" : "t";        debug(heading) {          writeln(line.strip);        } @@ -4791,6 +4813,7 @@ template DocReformDocAbstraction() {          comp_obj_toc.metainfo.identifier         = "";          comp_obj_toc.metainfo.object_number_off  = true;          comp_obj_toc.metainfo.object_number_type = 0; +        comp_obj_toc.metainfo.dummy_heading      = (an_object["dummy_heading_status"] == "t") ? true: false;          comp_obj_toc.attrib.indent_hang          = indent["hang_position"];          comp_obj_toc.attrib.indent_base          = indent["base_position"];          comp_obj_toc.attrib.bullet               = false; @@ -4807,6 +4830,7 @@ template DocReformDocAbstraction() {        comp_obj_toc.metainfo.identifier           = "";        comp_obj_toc.metainfo.object_number_off    = true;        comp_obj_toc.metainfo.object_number_type   = 0; +      comp_obj_toc.metainfo.dummy_heading        = (an_object["dummy_heading_status"] == "t") ? true: false;        comp_obj_toc.attrib.bullet                 = false;        comp_obj_toc.has.inline_links              = true;        switch (obj_["lev_markup_number"].to!int) { @@ -5506,6 +5530,7 @@ template DocReformDocAbstraction() {          comp_obj_heading_.text                           = "Book Index";          comp_obj_heading_.metainfo.ocn                   = 0;          comp_obj_heading_.metainfo.identifier            = ""; +        comp_obj_heading_.metainfo.dummy_heading         = false;          comp_obj_heading_.metainfo.object_number_off     = true;          comp_obj_heading_.metainfo.object_number_type    = 0;          comp_obj_heading_.tags.segment_anchor_tag_epub   = "_part_book_index"; @@ -5528,6 +5553,7 @@ template DocReformDocAbstraction() {          comp_obj_heading_.text                           = "Index";          comp_obj_heading_.metainfo.ocn                   = 0;          comp_obj_heading_.metainfo.identifier            = ""; +        comp_obj_heading_.metainfo.dummy_heading         = true;          comp_obj_heading_.metainfo.object_number_off     = true;          comp_obj_heading_.metainfo.object_number_type    = 0;          comp_obj_heading_.tags.segment_anchor_tag_epub   = "bookindex"; @@ -5604,6 +5630,7 @@ template DocReformDocAbstraction() {          comp_obj_heading_.text                           = "(skip) there is no Book Index";          comp_obj_heading_.metainfo.ocn                   = 0;          comp_obj_heading_.metainfo.identifier            = ""; +        comp_obj_heading_.metainfo.dummy_heading         = true;          comp_obj_heading_.metainfo.object_number_off     = true;          comp_obj_heading_.metainfo.object_number_type    = 0;          comp_obj_heading_.metainfo.heading_lev_markup    = 1; @@ -5718,6 +5745,7 @@ template DocReformDocAbstraction() {          comp_obj_heading_.text                           = "Endnotes";          comp_obj_heading_.metainfo.ocn                   = 0;          comp_obj_heading_.metainfo.identifier            = ""; +        comp_obj_heading_.metainfo.dummy_heading         = false;          comp_obj_heading_.metainfo.object_number_off     = true;          comp_obj_heading_.metainfo.object_number_type    = 0;          comp_obj_heading_.tags.segment_anchor_tag_epub   = "_part_endnotes"; @@ -5739,6 +5767,7 @@ template DocReformDocAbstraction() {          comp_obj_heading_.text                           = "Endnotes";          comp_obj_heading_.metainfo.ocn                   = 0;          comp_obj_heading_.metainfo.identifier            = ""; +        comp_obj_heading_.metainfo.dummy_heading         = true;          comp_obj_heading_.metainfo.object_number_off     = true;          comp_obj_heading_.metainfo.object_number_type    = 0;          comp_obj_heading_.tags.segment_anchor_tag_epub   = "endnotes"; @@ -5762,6 +5791,7 @@ template DocReformDocAbstraction() {          comp_obj_heading_.text                           = "(skip) there are no Endnotes";          comp_obj_heading_.metainfo.ocn                   = 0;          comp_obj_heading_.metainfo.identifier            = ""; +        comp_obj_heading_.metainfo.dummy_heading         = true;          comp_obj_heading_.metainfo.object_number_off     = true;          comp_obj_heading_.metainfo.object_number_type    = 0;          comp_obj_heading_.metainfo.heading_lev_markup    = 1; @@ -5779,6 +5809,7 @@ template DocReformDocAbstraction() {          comp_obj_endnote_.metainfo.is_a                  = "endnote";          comp_obj_endnote_.metainfo.ocn                   = 0;          comp_obj_endnote_.metainfo.identifier            = ""; +        // comp_obj_heading_.metainfo.dummy_heading         = false;          comp_obj_heading_.metainfo.object_number_off     = true; // check          comp_obj_heading_.metainfo.object_number_type    = 0; // check          comp_obj_endnote_.attrib.indent_hang             = 0; @@ -5966,10 +5997,11 @@ template DocReformDocAbstraction() {      }      invariant() {      } -    ObjGenericComposite node_emitter_heading(T,Lm,Lc,TaB,TaL,TA,N,C,P,LA,I,PSn,fNr,fNs,fL)( +    ObjGenericComposite node_emitter_heading(T,Lm,Lc,Hd,TaB,TaL,TA,N,C,P,LA,I,PSn,fNr,fNs,fL)(        T   _text,        Lm  lev_markup_number,        Lc  lev_collapsed_number, +      Hd  dummy_heading_status,        TaB tag_in_seg,        TaL lev_anchor_tag,        TA  tag_assoc, @@ -6106,6 +6138,7 @@ template DocReformDocAbstraction() {        _comp_obj_heading_.text                             = _text.to!string.strip;        _comp_obj_heading_.metainfo.ocn                     = obj_cite_digits.object_number;        _comp_obj_heading_.metainfo.identifier              = obj_cite_digits.identifier; +      _comp_obj_heading_.metainfo.dummy_heading           = (dummy_heading_status == "t") ? true: false;        _comp_obj_heading_.metainfo.object_number_off       = obj_cite_digits.off;        // _comp_obj_heading_.metainfo.o_n_book_index       = obj_cite_digits.bkidx;        _comp_obj_heading_.metainfo.object_number_type      = obj_cite_digits.type; diff --git a/src/doc_reform/meta/object_setter.d b/src/doc_reform/meta/object_setter.d index 7b94027..c675f9e 100644 --- a/src/doc_reform/meta/object_setter.d +++ b/src/doc_reform/meta/object_setter.d @@ -68,6 +68,7 @@ template ObjectSetter() {        }        return _out;      } +    bool                   dummy_heading                       = false;      int[]                  markedup_ancestors                  = [ 0, 0, 0, 0, 0, 0, 0, 0,];      int[]                  collapsed_ancestors                 = [ 0, 0, 0, 0, 0, 0, 0, 0,];      int[]                  dom_structure_markedup_tags_status  = [ 0, 0, 0, 0, 0, 0, 0, 0,]; diff --git a/src/doc_reform/meta/rgx.d b/src/doc_reform/meta/rgx.d index 3dcc214..8982ea5 100644 --- a/src/doc_reform/meta/rgx.d +++ b/src/doc_reform/meta/rgx.d @@ -183,12 +183,12 @@ static template DocReformRgxInit() {      static auto_heading_numbering_off_lv4                = ctRegex!(`^4~\S*?-\s`, "m");      /+ no object_number object +/      static object_number_off                            = ctRegex!(`~#[ ]*$`, "m"); -    static object_number_off_dh                         = ctRegex!(`-#$`, "m"); +    static object_number_off_dummy_heading              = ctRegex!(`-#$`, "m");      static object_number_off_all                        = ctRegex!(`[~-]#$`, "m");      static repeated_character_line_separator            = ctRegex!(`^(?:(?:(?:[.][ ]?){4,}|(?:[-][ ]?|[~][ ]?|[*][ ]?|[$][ ]?|[#][ ]?|[\\][ ]?|[/][ ]?){2,})\s*?)*$`);      /+ no object_number block +/      static object_number_off_block                      = ctRegex!(`^--~#$`); -    static object_number_off_block_dh                   = ctRegex!(`^---#$`); +    static object_number_off_block_dummy_heading        = ctRegex!(`^---#$`);      static object_number_off_block_close                = ctRegex!(`^--\+#$`);      static object_number_block_marks                    = ctRegex!(`^--[+~-]#$`);      /+ ignore outside code blocks +/ diff --git a/src/doc_reform/output/xmls.d b/src/doc_reform/output/xmls.d index 30e876d..ffcbd1a 100644 --- a/src/doc_reform/output/xmls.d +++ b/src/doc_reform/output/xmls.d @@ -502,9 +502,14 @@ template outputXHTMLs() {                     M  doc_matters,        string          _suffix = ".html",      ) { -      _txt = inline_images(_txt, obj, doc_matters, _suffix, "scroll"); -      _txt = inline_links(_txt, obj, doc_matters, _suffix, "scroll"); -      _txt = inline_notes_scroll(_txt, obj, doc_matters); +      if (obj.metainfo.dummy_heading +        && (obj.metainfo.is_a == "toc" || obj.metainfo.is_a == "heading")) { +        _txt = ""; +      } else { +        _txt = inline_images(_txt, obj, doc_matters, _suffix, "scroll"); +        _txt = inline_links(_txt, obj, doc_matters, _suffix, "scroll"); +        _txt = inline_notes_scroll(_txt, obj, doc_matters); +      }        return _txt;      }      auto inline_markup_seg(O,M)( @@ -514,8 +519,16 @@ template outputXHTMLs() {        string          _suffix = ".html",        string          _xml_type = "seg",      ) { -      _txt = inline_images(_txt, obj, doc_matters, _suffix, _xml_type); // TODO -      _txt = inline_links(_txt, obj, doc_matters, _suffix, _xml_type); // TODO +      if (obj.metainfo.dummy_heading +        && ((_xml_type == "epub" +        && (obj.metainfo.is_a == "toc" || obj.metainfo.is_a == "heading")) +        || obj.metainfo.is_a == "heading") +      ) { +        _txt = ""; +      } else { +        _txt = inline_images(_txt, obj, doc_matters, _suffix, _xml_type); // TODO +        _txt = inline_links(_txt, obj, doc_matters, _suffix, _xml_type); // TODO +      }        auto t = inline_notes_seg(_txt, obj, doc_matters);        return t;      } @@ -645,7 +658,12 @@ template outputXHTMLs() {        heading_lev_anchor_tag = (obj.tags.heading_lev_anchor_tag.empty)          ? ""          : "<a name=\"" ~ obj.tags.heading_lev_anchor_tag ~ "\"></a>"; -      if (!(obj.metainfo.identifier.empty)) { +      if (_txt.empty) { +        o = format(q"┃%s +      ┃", +        _horizontal_rule, +        ); +      } else if (!(obj.metainfo.identifier.empty)) {          o = format(q"┃%s        <div class="substance">          <label class="ocn"><a href="#%s" class="lnkocn">%s</a></label> | 
