diff options
author | Ralph Amissah <ralph@amissah.com> | 2018-06-25 12:50:54 -0400 |
---|---|---|
committer | Ralph Amissah <ralph@amissah.com> | 2019-04-10 15:14:15 -0400 |
commit | c9c1b3501569d83f9c1e9f7ca153230cd117b8a9 (patch) | |
tree | b4d15bcdfe5c2881b6e17d33eceb2c70cb910664 /src | |
parent | doc object metainfo consolidation (diff) |
obj.metainfo node type info, ancestors
Diffstat (limited to 'src')
-rw-r--r-- | src/sdp/meta/doc_debugs.d | 4 | ||||
-rw-r--r-- | src/sdp/meta/metadoc_from_src.d | 473 | ||||
-rw-r--r-- | src/sdp/meta/object_setter.d | 72 | ||||
-rw-r--r-- | src/sdp/output/epub3.d | 4 | ||||
-rw-r--r-- | src/sdp/output/sqlite.d | 4 |
5 files changed, 396 insertions, 161 deletions
diff --git a/src/sdp/meta/doc_debugs.d b/src/sdp/meta/doc_debugs.d index c8b9dc1..bc781ee 100644 --- a/src/sdp/meta/doc_debugs.d +++ b/src/sdp/meta/doc_debugs.d @@ -120,7 +120,7 @@ template SiSUdebugs() { foreach (obj; contents[sect]) { if (obj.metainfo.is_a == "heading") { foreach_reverse (k; 0 .. 7) { - switch (obj.dom_markedup[k]) { + switch (obj.dom_structure_markedup_tags_status[k]) { case DomTags.close : writeln(markup.indent_by_spaces_provided(k), "</", k, ">"); break; @@ -147,7 +147,7 @@ template SiSUdebugs() { foreach (obj; contents[sect]) { if (obj.metainfo.is_a == "heading") { foreach_reverse (k; 0 .. 7) { - switch (obj.dom_collapsed[k]) { + switch (obj.dom_structure_collapsed_tags_status[k]) { case DomTags.close : writeln(markup.indent_by_spaces_provided(k), "</", k, ">"); break; diff --git a/src/sdp/meta/metadoc_from_src.d b/src/sdp/meta/metadoc_from_src.d index 9c01a47..ee82257 100644 --- a/src/sdp/meta/metadoc_from_src.d +++ b/src/sdp/meta/metadoc_from_src.d @@ -79,10 +79,10 @@ template SiSUdocAbstraction() { OCNset obj_cite_digits; int obj_cite_digit_, obj_cite_digit_off, obj_cite_digit_bkidx, obj_cite_digit_type; auto object_citation_number = OCNemitter(); - int[] dom_markedup = [ 0, 0, 0, 0, 0, 0, 0, 0, 0,]; - int[] dom_markedup_buffer = [ 0, 0, 0, 0, 0, 0, 0, 0, 0,]; - int[] dom_collapsed = [ 0, 0, 0, 0, 0, 0, 0, 0, 0,]; - int[] dom_collapsed_buffer = [ 0, 0, 0, 0, 0, 0, 0, 0, 0,]; + int[] dom_structure_markedup_tags_status = [ 0, 0, 0, 0, 0, 0, 0, 0, 0,]; + int[] dom_structure_markedup_tags_status_buffer = [ 0, 0, 0, 0, 0, 0, 0, 0, 0,]; + int[] dom_structure_collapsed_tags_status = [ 0, 0, 0, 0, 0, 0, 0, 0, 0,]; + int[] dom_structure_collapsed_tags_status_buffer = [ 0, 0, 0, 0, 0, 0, 0, 0, 0,]; enum DomTags { none, open, close, close_and_open, open_still, } pure auto obj_heading_ancestors(O)( O obj, @@ -178,7 +178,7 @@ template SiSUdocAbstraction() { debug(dom_magic_numbers) { writeln("marked up: ", lev, ": ", dom); } - obj.metainfo.dom_markedup = dom.dup; + obj.metainfo.dom_structure_markedup_tags_status = dom.dup; return obj; } pure auto obj_dom_set_collapsed_tags(O)( @@ -222,7 +222,7 @@ template SiSUdocAbstraction() { debug(dom_magic_numbers) { writeln("collapsed: ", lev, ": ", dom); } - obj.metainfo.dom_collapsed = dom.dup; + obj.metainfo.dom_structure_collapsed_tags_status = dom.dup; return obj; } static auto ocn_emit(int ocn_status_flag) { @@ -323,27 +323,27 @@ template SiSUdocAbstraction() { ]; string _anchor_tag; string toc_txt_; - an_object["glossary_nugget"] = ""; - an_object["blurb_nugget"] = ""; - comp_obj_heading_ = comp_obj_heading_.init; - comp_obj_heading_.metainfo.is_of_part = "frontmatter"; - comp_obj_heading_.metainfo.is_of_section = "toc"; - comp_obj_heading_.metainfo.is_of_type = "para"; - comp_obj_heading_.metainfo.is_a = "heading"; - comp_obj_heading_.text = "Table of Contents"; - comp_obj_heading_.metainfo.ocn = 0; - comp_obj_heading_.metainfo.object_number_off = ""; - comp_obj_heading_.metainfo.object_number_type = 0; - comp_obj_heading_.tags.segment_anchor_tag = "toc"; - comp_obj_heading_.metainfo.heading_lev_markup = 4; - comp_obj_heading_.metainfo.heading_lev_collapsed = 1; - comp_obj_heading_.metainfo.parent_ocn = 1; - comp_obj_heading_.metainfo.parent_lev_markup = 0; - comp_obj_heading_.ptr.html_segnames = html_segnames_ptr; - comp_obj_heading_.tags.anchor_tags = ["toc"]; - comp_obj_heading_.metainfo.dom_markedup = [ 1, 1, 0, 0, 1, 0, 0, 0]; - comp_obj_heading_.metainfo.dom_collapsed = [ 1, 1, 1, 0, 0, 0, 0, 0]; - auto toc_head = comp_obj_heading_; + an_object["glossary_nugget"] = ""; + an_object["blurb_nugget"] = ""; + comp_obj_heading_ = comp_obj_heading_.init; + comp_obj_heading_.metainfo.is_of_part = "frontmatter"; + comp_obj_heading_.metainfo.is_of_section = "toc"; + comp_obj_heading_.metainfo.is_of_type = "para"; + comp_obj_heading_.metainfo.is_a = "heading"; + comp_obj_heading_.text = "Table of Contents"; + comp_obj_heading_.metainfo.ocn = 0; + comp_obj_heading_.metainfo.object_number_off = ""; + comp_obj_heading_.metainfo.object_number_type = 0; + comp_obj_heading_.tags.segment_anchor_tag = "toc"; + comp_obj_heading_.metainfo.heading_lev_markup = 4; + comp_obj_heading_.metainfo.heading_lev_collapsed = 1; + comp_obj_heading_.metainfo.parent_ocn = 1; + comp_obj_heading_.metainfo.parent_lev_markup = 0; + comp_obj_heading_.ptr.html_segnames = html_segnames_ptr; + comp_obj_heading_.tags.anchor_tags = ["toc"]; + comp_obj_heading_.metainfo.dom_structure_markedup_tags_status = [ 1, 1, 0, 0, 1, 0, 0, 0]; + comp_obj_heading_.metainfo.dom_structure_collapsed_tags_status = [ 1, 1, 1, 0, 0, 0, 0, 0]; + auto toc_head = comp_obj_heading_; html_segnames_ptr_cntr++; the_table_of_contents_section = [ "seg": [toc_head], @@ -478,8 +478,8 @@ template SiSUdocAbstraction() { comp_obj_heading_.metainfo.heading_lev_collapsed = 1; comp_obj_heading_.metainfo.parent_ocn = 1; comp_obj_heading_.metainfo.parent_lev_markup = 0; - comp_obj_heading_.metainfo.dom_markedup = [ 1, 1, 0, 0, 0, 0, 0, 0]; - comp_obj_heading_.metainfo.dom_collapsed = [ 1, 1, 0, 0, 0, 0, 0, 0]; + comp_obj_heading_.metainfo.dom_structure_markedup_tags_status = [ 1, 1, 0, 0, 0, 0, 0, 0]; + comp_obj_heading_.metainfo.dom_structure_collapsed_tags_status = [ 1, 1, 0, 0, 0, 0, 0, 0]; the_glossary_section ~= comp_obj_heading_; comp_obj_heading_ = comp_obj_heading_.init; comp_obj_heading_.metainfo.is_of_part = "backmatter"; @@ -495,8 +495,8 @@ template SiSUdocAbstraction() { comp_obj_heading_.metainfo.heading_lev_collapsed = 2; comp_obj_heading_.metainfo.parent_ocn = 1; comp_obj_heading_.metainfo.parent_lev_markup = 0; - comp_obj_heading_.metainfo.dom_markedup = [ 1, 1, 0, 0, 1, 0, 0, 0]; - comp_obj_heading_.metainfo.dom_collapsed = [ 1, 1, 1, 0, 0, 0, 0, 0]; + comp_obj_heading_.metainfo.dom_structure_markedup_tags_status = [ 1, 1, 0, 0, 1, 0, 0, 0]; + comp_obj_heading_.metainfo.dom_structure_collapsed_tags_status = [ 1, 1, 1, 0, 0, 0, 0, 0]; comp_obj_heading_.tags.anchor_tags = ["glossary"]; the_glossary_section ~= comp_obj_heading_; } else { @@ -570,41 +570,41 @@ template SiSUdocAbstraction() { line_occur["para"] = State.off; an_object_key="blurb_nugget"; if (line.matchFirst(rgx.heading_blurb)) { - comp_obj_heading_ = comp_obj_heading_.init; - comp_obj_heading_.metainfo.is_of_part = "backmatter"; - comp_obj_heading_.metainfo.is_of_section = "blurb"; - comp_obj_heading_.metainfo.is_of_type = "para"; - comp_obj_heading_.metainfo.is_a = "heading"; - comp_obj_heading_.text = "Blurb"; - comp_obj_heading_.metainfo.ocn = 0; - comp_obj_heading_.metainfo.object_number_off = ""; - comp_obj_heading_.metainfo.object_number_type = 0; - comp_obj_heading_.tags.segment_anchor_tag = "_part_blurb"; - comp_obj_heading_.metainfo.heading_lev_markup = 1; - comp_obj_heading_.metainfo.heading_lev_collapsed = 1; - comp_obj_heading_.metainfo.parent_ocn = 1; - comp_obj_heading_.metainfo.parent_lev_markup = 0; - comp_obj_heading_.metainfo.dom_markedup = [ 1, 1, 0, 0, 0, 0, 0, 0]; - comp_obj_heading_.metainfo.dom_collapsed = [ 1, 1, 0, 0, 0, 0, 0, 0]; - the_blurb_section ~= comp_obj_heading_; - comp_obj_heading_ = comp_obj_heading_.init; - comp_obj_heading_.metainfo.is_of_part = "backmatter"; - comp_obj_heading_.metainfo.is_of_section = "blurb"; - comp_obj_heading_.metainfo.is_of_type = "para"; - comp_obj_heading_.metainfo.is_a = "heading"; - comp_obj_heading_.text = "Blurb"; - comp_obj_heading_.metainfo.ocn = 0; - comp_obj_heading_.metainfo.object_number_off = ""; - comp_obj_heading_.metainfo.object_number_type = 0; - comp_obj_heading_.tags.segment_anchor_tag = "blurb"; - comp_obj_heading_.metainfo.heading_lev_markup = 4; - comp_obj_heading_.metainfo.heading_lev_collapsed = 2; - comp_obj_heading_.metainfo.parent_ocn = 1; - comp_obj_heading_.metainfo.parent_lev_markup = 0; - comp_obj_heading_.tags.anchor_tags = ["blurb"]; - comp_obj_heading_.metainfo.dom_markedup = [ 1, 1, 0, 0, 1, 0, 0, 0]; - comp_obj_heading_.metainfo.dom_collapsed = [ 1, 1, 1, 0, 0, 0, 0, 0]; - the_blurb_section ~= comp_obj_heading_; + comp_obj_heading_ = comp_obj_heading_.init; + comp_obj_heading_.metainfo.is_of_part = "backmatter"; + comp_obj_heading_.metainfo.is_of_section = "blurb"; + comp_obj_heading_.metainfo.is_of_type = "para"; + comp_obj_heading_.metainfo.is_a = "heading"; + comp_obj_heading_.text = "Blurb"; + comp_obj_heading_.metainfo.ocn = 0; + comp_obj_heading_.metainfo.object_number_off = ""; + comp_obj_heading_.metainfo.object_number_type = 0; + comp_obj_heading_.tags.segment_anchor_tag = "_part_blurb"; + comp_obj_heading_.metainfo.heading_lev_markup = 1; + comp_obj_heading_.metainfo.heading_lev_collapsed = 1; + comp_obj_heading_.metainfo.parent_ocn = 1; + comp_obj_heading_.metainfo.parent_lev_markup = 0; + comp_obj_heading_.metainfo.dom_structure_markedup_tags_status = [ 1, 1, 0, 0, 0, 0, 0, 0]; + comp_obj_heading_.metainfo.dom_structure_collapsed_tags_status = [ 1, 1, 0, 0, 0, 0, 0, 0]; + the_blurb_section ~= comp_obj_heading_; + comp_obj_heading_ = comp_obj_heading_.init; + comp_obj_heading_.metainfo.is_of_part = "backmatter"; + comp_obj_heading_.metainfo.is_of_section = "blurb"; + comp_obj_heading_.metainfo.is_of_type = "para"; + comp_obj_heading_.metainfo.is_a = "heading"; + comp_obj_heading_.text = "Blurb"; + comp_obj_heading_.metainfo.ocn = 0; + comp_obj_heading_.metainfo.object_number_off = ""; + comp_obj_heading_.metainfo.object_number_type = 0; + comp_obj_heading_.tags.segment_anchor_tag = "blurb"; + comp_obj_heading_.metainfo.heading_lev_markup = 4; + comp_obj_heading_.metainfo.heading_lev_collapsed = 2; + comp_obj_heading_.metainfo.parent_ocn = 1; + comp_obj_heading_.metainfo.parent_lev_markup = 0; + comp_obj_heading_.tags.anchor_tags = ["blurb"]; + comp_obj_heading_.metainfo.dom_structure_markedup_tags_status = [ 1, 1, 0, 0, 1, 0, 0, 0]; + comp_obj_heading_.metainfo.dom_structure_collapsed_tags_status = [ 1, 1, 1, 0, 0, 0, 0, 0]; + the_blurb_section ~= comp_obj_heading_; } else if (line.matchFirst(rgx.heading) && (opt_action.backmatter && opt_action.section_blurb)) { comp_obj_heading_ = comp_obj_heading_.init; @@ -621,7 +621,7 @@ template SiSUdocAbstraction() { comp_obj_heading_.metainfo.heading_lev_collapsed = an_object["lev_collapsed_number"].to!int; // make int, remove need to conv comp_obj_heading_.metainfo.parent_ocn = 1; comp_obj_heading_.metainfo.parent_lev_markup = 0; - the_blurb_section ~= comp_obj_heading_; + the_blurb_section ~= comp_obj_heading_; } else { _para_match_(line, an_object, an_object_key, indent, bullet, obj_type_status, line_occur); comp_obj_para = comp_obj_para.init; @@ -1325,6 +1325,197 @@ template SiSUdocAbstraction() { } the_document_head_section ~= the_document_body_section[0]; the_document_body_section=the_document_body_section[1..$]; + int[] _get_ancestors_markup(O)(O obj, ref int[] _ancestors_markup) { + if (obj.metainfo.is_a == "heading") { + debug(dom) { + writeln(obj.text); + } + if (obj.metainfo.heading_lev_markup == 1) { + _ancestors_markup = [ + _ancestors_markup[0], + 0,0,0,0,0,0,0 + ]; + } + if (obj.metainfo.heading_lev_markup == 2) { + _ancestors_markup = [ + _ancestors_markup[0], + _ancestors_markup[1], + 0,0,0,0,0,0 + ]; + } + if (obj.metainfo.heading_lev_markup == 3) { + _ancestors_markup = [ + _ancestors_markup[0], + _ancestors_markup[1], + _ancestors_markup[2], + 0,0,0,0,0 + ]; + } + if (obj.metainfo.heading_lev_markup == 4) { + _ancestors_markup = [ + _ancestors_markup[0], + _ancestors_markup[1], + _ancestors_markup[2], + _ancestors_markup[3], + 0,0,0,0 + ]; + } + if (obj.metainfo.heading_lev_markup == 5) { + _ancestors_markup = [ + _ancestors_markup[0], + _ancestors_markup[1], + _ancestors_markup[2], + _ancestors_markup[3], + _ancestors_markup[4], + 0,0,0 + ]; + } + if (obj.metainfo.heading_lev_markup == 6) { + _ancestors_markup = [ + _ancestors_markup[0], + _ancestors_markup[1], + _ancestors_markup[2], + _ancestors_markup[3], + _ancestors_markup[4], + _ancestors_markup[5], + 0,0 + ]; + } + if (obj.metainfo.heading_lev_markup == 7) { + _ancestors_markup = [ + _ancestors_markup[0], + _ancestors_markup[1], + _ancestors_markup[2], + _ancestors_markup[3], + _ancestors_markup[4], + _ancestors_markup[5], + _ancestors_markup[6], + 0 + ]; + } + if (obj.metainfo.heading_lev_markup == 8) { + _ancestors_markup = [ + _ancestors_markup[0], + _ancestors_markup[1], + _ancestors_markup[2], + _ancestors_markup[3], + _ancestors_markup[4], + _ancestors_markup[5], + _ancestors_markup[6], + _ancestors_markup[7] + ]; + } + _ancestors_markup[obj.metainfo.heading_lev_markup] = obj.metainfo.ocn; + } + debug(ancestor_markup) { + writeln("marked up: ", _ancestors_markup); + } + return _ancestors_markup; + } + int[] _get_ancestors_collapsed(O)(O obj, ref int[] _ancestors_collapsed) { + if (obj.metainfo.is_a == "heading") { + if (obj.metainfo.heading_lev_collapsed == 1) { + _ancestors_collapsed = [ + _ancestors_collapsed[0], + 0,0,0,0,0,0,0 + ]; + } + if (obj.metainfo.heading_lev_collapsed == 2) { + _ancestors_collapsed = [ + _ancestors_collapsed[0], + _ancestors_collapsed[1], + 0,0,0,0,0,0 + ]; + } + if (obj.metainfo.heading_lev_collapsed == 3) { + _ancestors_collapsed = [ + _ancestors_collapsed[0], + _ancestors_collapsed[1], + _ancestors_collapsed[2], + 0,0,0,0,0 + ]; + } + if (obj.metainfo.heading_lev_collapsed == 4) { + _ancestors_collapsed = [ + _ancestors_collapsed[0], + _ancestors_collapsed[1], + _ancestors_collapsed[2], + _ancestors_collapsed[3], + 0,0,0,0 + ]; + } + if (obj.metainfo.heading_lev_collapsed == 5) { + _ancestors_collapsed = [ + _ancestors_collapsed[0], + _ancestors_collapsed[1], + _ancestors_collapsed[2], + _ancestors_collapsed[3], + _ancestors_collapsed[4], + 0,0,0 + ]; + } + if (obj.metainfo.heading_lev_collapsed == 6) { + _ancestors_collapsed = [ + _ancestors_collapsed[0], + _ancestors_collapsed[1], + _ancestors_collapsed[2], + _ancestors_collapsed[3], + _ancestors_collapsed[4], + _ancestors_collapsed[5], + 0,0 + ]; + } + if (obj.metainfo.heading_lev_collapsed == 7) { + _ancestors_collapsed = [ + _ancestors_collapsed[0], + _ancestors_collapsed[1], + _ancestors_collapsed[2], + _ancestors_collapsed[3], + _ancestors_collapsed[4], + _ancestors_collapsed[5], + _ancestors_collapsed[6], + 0 + ]; + } + if (obj.metainfo.heading_lev_collapsed == 8) { + _ancestors_collapsed = [ + _ancestors_collapsed[0], + _ancestors_collapsed[1], + _ancestors_collapsed[2], + _ancestors_collapsed[3], + _ancestors_collapsed[4], + _ancestors_collapsed[5], + _ancestors_collapsed[6], + _ancestors_collapsed[7] + ]; + } + _ancestors_collapsed[obj.metainfo.heading_lev_collapsed] = obj.metainfo.ocn; + } + debug(ancestor_collapsed) { + writeln("collapsed: ", _ancestors_collapsed); + } + return _ancestors_collapsed; + } + /+ multiple 1~ levels, loop through document body +/ + if (the_document_body_section.length > 1) { + int[] _ancestors_markup = [0,0,0,0,0,0,0,0]; + int[][] _ancestors_markup_; + _ancestors_markup = [1,0,0,0,0,0,0,0]; + _ancestors_markup_ ~= _ancestors_markup; + int[] _ancestors_collapsed = [0,0,0,0,0,0,0,0]; + int[][] _ancestors_collapsed_; + _ancestors_collapsed = [1,0,0,0,0,0,0,0]; + _ancestors_collapsed_ ~= _ancestors_collapsed; + foreach (ref obj; the_document_body_section) { + if (obj.metainfo.is_a == "heading") { + obj.metainfo.markedup_ancestors = _get_ancestors_markup(obj, _ancestors_markup); + } + } + debug(ancestors) { + writeln("ancestors markup o_n: ", obj.metainfo.markedup_ancestors); + writeln("ancestors collapsed o_n: ", obj.metainfo.markedup_ancestors); + } + } if (the_endnotes_section.length > 1) { html_segnames ~= "endnotes"; html_segnames_ptr = html_segnames_ptr_cntr; @@ -1453,16 +1644,16 @@ template SiSUdocAbstraction() { || (opt_action.sqlite_discrete) || (opt_action.sqlite_update) || (opt_action.postgresql)) { - obj = obj_dom_structure_set_markup_tags(obj, dom_markedup, obj.metainfo.heading_lev_markup); - obj = obj_dom_set_collapsed_tags(obj, dom_collapsed, obj.metainfo.heading_lev_collapsed); + obj = obj_dom_structure_set_markup_tags(obj, dom_structure_markedup_tags_status, obj.metainfo.heading_lev_markup); + obj = obj_dom_set_collapsed_tags(obj, dom_structure_collapsed_tags_status, obj.metainfo.heading_lev_collapsed); } obj = obj_heading_ancestors(obj, lv_ancestors_txt); } } if (the_table_of_contents_section["scroll"].length > 1) { /+ scroll +/ - dom_markedup_buffer = dom_markedup.dup; - dom_collapsed_buffer = dom_collapsed.dup; + dom_structure_markedup_tags_status_buffer = dom_structure_markedup_tags_status.dup; + dom_structure_collapsed_tags_status_buffer = dom_structure_collapsed_tags_status.dup; foreach (ref obj; the_table_of_contents_section["scroll"]) { if (obj.metainfo.is_a == "heading") { if (obj.metainfo.heading_lev_markup <= 4) { @@ -1481,15 +1672,15 @@ template SiSUdocAbstraction() { || (opt_action.sqlite_discrete) || (opt_action.sqlite_update) || (opt_action.postgresql)) { - obj = obj_dom_structure_set_markup_tags(obj, dom_markedup, obj.metainfo.heading_lev_markup); - obj = obj_dom_set_collapsed_tags(obj, dom_collapsed, obj.metainfo.heading_lev_collapsed); + obj = obj_dom_structure_set_markup_tags(obj, dom_structure_markedup_tags_status, obj.metainfo.heading_lev_markup); + obj = obj_dom_set_collapsed_tags(obj, dom_structure_collapsed_tags_status, obj.metainfo.heading_lev_collapsed); } obj = obj_heading_ancestors(obj, lv_ancestors_txt); } } /+ seg +/ - dom_markedup = dom_markedup_buffer.dup; - dom_collapsed = dom_collapsed_buffer.dup; + dom_structure_markedup_tags_status = dom_structure_markedup_tags_status_buffer.dup; + dom_structure_collapsed_tags_status = dom_structure_collapsed_tags_status_buffer.dup; foreach (ref obj; the_table_of_contents_section["seg"]) { if (obj.metainfo.is_a == "heading") { debug(dom) { @@ -1507,8 +1698,8 @@ template SiSUdocAbstraction() { || (opt_action.html_scroll) || (opt_action.html_seg) || (opt_action.epub)) { - obj = obj_dom_structure_set_markup_tags(obj, dom_markedup, obj.metainfo.heading_lev_markup); - obj = obj_dom_set_collapsed_tags(obj, dom_collapsed, obj.metainfo.heading_lev_collapsed); + obj = obj_dom_structure_set_markup_tags(obj, dom_structure_markedup_tags_status, obj.metainfo.heading_lev_markup); + obj = obj_dom_set_collapsed_tags(obj, dom_structure_collapsed_tags_status, obj.metainfo.heading_lev_collapsed); } obj = obj_heading_ancestors(obj, lv_ancestors_txt); } @@ -1541,8 +1732,8 @@ template SiSUdocAbstraction() { || (opt_action.sqlite_discrete) || (opt_action.sqlite_update) || (opt_action.postgresql)) { - obj = obj_dom_structure_set_markup_tags(obj, dom_markedup, obj.metainfo.heading_lev_markup); - obj = obj_dom_set_collapsed_tags(obj, dom_collapsed, obj.metainfo.heading_lev_collapsed); + obj = obj_dom_structure_set_markup_tags(obj, dom_structure_markedup_tags_status, obj.metainfo.heading_lev_markup); + obj = obj_dom_set_collapsed_tags(obj, dom_structure_collapsed_tags_status, obj.metainfo.heading_lev_collapsed); } obj = obj_heading_ancestors(obj, lv_ancestors_txt); } else if (obj.metainfo.is_a == "para") { @@ -1554,10 +1745,10 @@ template SiSUdocAbstraction() { auto images=uniq(_images.sort()); /+ optional only one 1~ level +/ if (the_endnotes_section.length > 1) { - dom_markedup_buffer = dom_markedup.dup; - dom_collapsed_buffer = dom_collapsed.dup; - dom_markedup = dom_markedup_buffer.dup; - dom_collapsed = dom_collapsed_buffer.dup; + dom_structure_markedup_tags_status_buffer = dom_structure_markedup_tags_status.dup; + dom_structure_collapsed_tags_status_buffer = dom_structure_collapsed_tags_status.dup; + dom_structure_markedup_tags_status = dom_structure_markedup_tags_status_buffer.dup; + dom_structure_collapsed_tags_status = dom_structure_collapsed_tags_status_buffer.dup; foreach (ref obj; the_endnotes_section) { if (obj.metainfo.is_a == "heading") { debug(dom) { @@ -1584,8 +1775,8 @@ template SiSUdocAbstraction() { || (opt_action.sqlite_discrete) || (opt_action.sqlite_update) || (opt_action.postgresql)) { - obj = obj_dom_structure_set_markup_tags(obj, dom_markedup, obj.metainfo.heading_lev_markup); - obj = obj_dom_set_collapsed_tags(obj, dom_collapsed, obj.metainfo.heading_lev_collapsed); + obj = obj_dom_structure_set_markup_tags(obj, dom_structure_markedup_tags_status, obj.metainfo.heading_lev_markup); + obj = obj_dom_set_collapsed_tags(obj, dom_structure_collapsed_tags_status, obj.metainfo.heading_lev_collapsed); } obj = obj_heading_ancestors(obj, lv_ancestors_txt); } @@ -1619,8 +1810,8 @@ template SiSUdocAbstraction() { || (opt_action.sqlite_discrete) || (opt_action.sqlite_update) || (opt_action.postgresql)) { - obj = obj_dom_structure_set_markup_tags(obj, dom_markedup, obj.metainfo.heading_lev_markup); - obj = obj_dom_set_collapsed_tags(obj, dom_collapsed, obj.metainfo.heading_lev_collapsed); + obj = obj_dom_structure_set_markup_tags(obj, dom_structure_markedup_tags_status, obj.metainfo.heading_lev_markup); + obj = obj_dom_set_collapsed_tags(obj, dom_structure_collapsed_tags_status, obj.metainfo.heading_lev_collapsed); } obj = obj_heading_ancestors(obj, lv_ancestors_txt); } else if (obj.metainfo.is_a == "glossary") { @@ -1657,8 +1848,8 @@ template SiSUdocAbstraction() { || (opt_action.sqlite_discrete) || (opt_action.sqlite_update) || (opt_action.postgresql)) { - obj = obj_dom_structure_set_markup_tags(obj, dom_markedup, obj.metainfo.heading_lev_markup); - obj = obj_dom_set_collapsed_tags(obj, dom_collapsed, obj.metainfo.heading_lev_collapsed); + obj = obj_dom_structure_set_markup_tags(obj, dom_structure_markedup_tags_status, obj.metainfo.heading_lev_markup); + obj = obj_dom_set_collapsed_tags(obj, dom_structure_collapsed_tags_status, obj.metainfo.heading_lev_collapsed); } obj = obj_heading_ancestors(obj, lv_ancestors_txt); } else if (obj.metainfo.is_a == "bibliography") { @@ -1673,8 +1864,8 @@ template SiSUdocAbstraction() { int ocn_bidx_; if (the_bookindex_section["scroll"].length > 1) { /+ scroll +/ - dom_markedup_buffer = dom_markedup.dup; - dom_collapsed_buffer = dom_collapsed.dup; + dom_structure_markedup_tags_status_buffer = dom_structure_markedup_tags_status.dup; + dom_structure_collapsed_tags_status_buffer = dom_structure_collapsed_tags_status.dup; foreach (ref obj; the_bookindex_section["scroll"]) { if (obj.metainfo.is_a == "heading") { debug(dom) { @@ -1700,20 +1891,20 @@ template SiSUdocAbstraction() { || (opt_action.sqlite_discrete) || (opt_action.sqlite_update) || (opt_action.postgresql)) { - obj = obj_dom_structure_set_markup_tags(obj, dom_markedup, obj.metainfo.heading_lev_markup); - obj = obj_dom_set_collapsed_tags(obj, dom_collapsed, obj.metainfo.heading_lev_collapsed); + obj = obj_dom_structure_set_markup_tags(obj, dom_structure_markedup_tags_status, obj.metainfo.heading_lev_markup); + obj = obj_dom_set_collapsed_tags(obj, dom_structure_collapsed_tags_status, obj.metainfo.heading_lev_collapsed); } obj = obj_heading_ancestors(obj, lv_ancestors_txt); } else if (obj.metainfo.is_a == "bookindex") { - obj_cite_digits = ocn_emit(OCNstatus.bkidx); + obj_cite_digits = ocn_emit(OCNstatus.bkidx); obj.metainfo.ocn = obj_cite_digits.digit; obj.metainfo.o_n_book_index = obj_cite_digits.bkidx; obj.metainfo.object_number_type = OCNtype.bkidx; } } /+ seg +/ - dom_markedup = dom_markedup_buffer.dup; - dom_collapsed = dom_collapsed_buffer.dup; + dom_structure_markedup_tags_status = dom_structure_markedup_tags_status_buffer.dup; + dom_structure_collapsed_tags_status = dom_structure_collapsed_tags_status_buffer.dup; foreach (ref obj; the_bookindex_section["seg"]) { if (obj.metainfo.is_a == "heading") { debug(dom) { @@ -1739,12 +1930,12 @@ template SiSUdocAbstraction() { || (opt_action.sqlite_discrete) || (opt_action.sqlite_update) || (opt_action.postgresql)) { - obj = obj_dom_structure_set_markup_tags(obj, dom_markedup, obj.metainfo.heading_lev_markup); - obj = obj_dom_set_collapsed_tags(obj, dom_collapsed, obj.metainfo.heading_lev_collapsed); + obj = obj_dom_structure_set_markup_tags(obj, dom_structure_markedup_tags_status, obj.metainfo.heading_lev_markup); + obj = obj_dom_set_collapsed_tags(obj, dom_structure_collapsed_tags_status, obj.metainfo.heading_lev_collapsed); } obj = obj_heading_ancestors(obj, lv_ancestors_txt); } else if (obj.metainfo.is_a == "bookindex") { - ocn_bidx_ = ++ocn_bkidx_; + ocn_bidx_ = ++ocn_bkidx_; obj.metainfo.o_n_book_index = ocn_bidx_; // FIX need to distinguish from regular ocn obj.metainfo.object_number_type = OCNtype.bkidx; } @@ -1782,8 +1973,8 @@ template SiSUdocAbstraction() { || (opt_action.sqlite_discrete) || (opt_action.sqlite_update) || (opt_action.postgresql)) { - obj = obj_dom_structure_set_markup_tags(obj, dom_markedup, obj.metainfo.heading_lev_markup); - obj = obj_dom_set_collapsed_tags(obj, dom_collapsed, obj.metainfo.heading_lev_collapsed); + obj = obj_dom_structure_set_markup_tags(obj, dom_structure_markedup_tags_status, obj.metainfo.heading_lev_markup); + obj = obj_dom_set_collapsed_tags(obj, dom_structure_collapsed_tags_status, obj.metainfo.heading_lev_collapsed); } obj = obj_heading_ancestors(obj, lv_ancestors_txt); } else if (obj.metainfo.is_a == "blurb") { @@ -1796,8 +1987,8 @@ template SiSUdocAbstraction() { /+ TODO - note create/insert heading object sole purpose eof close all open tags sort out: - - obj.metainfo.dom_markedup = dom_markedup; - - obj.metainfo.dom_collapsed = dom_collapsed; + - obj.metainfo.dom_structure_markedup_tags_status = dom_structure_markedup_tags_status; + - obj.metainfo.dom_structure_collapsed_tags_status = dom_structure_collapsed_tags_status; +/ comp_obj_heading_ = comp_obj_heading_.init; comp_obj_heading_.metainfo.is_of_part = "empty"; @@ -1812,10 +2003,10 @@ template SiSUdocAbstraction() { comp_obj_heading_.metainfo.heading_lev_collapsed = 9; comp_obj_heading_.metainfo.parent_ocn = 0; comp_obj_heading_.metainfo.parent_lev_markup = 0; - comp_obj_heading_.metainfo.dom_markedup = dom_markedup.dup; - comp_obj_heading_.metainfo.dom_collapsed = dom_collapsed.dup; - comp_obj_heading_ = obj_dom_structure_set_markup_tags(comp_obj_heading_, dom_markedup, 0); - comp_obj_heading_ = obj_dom_set_collapsed_tags(comp_obj_heading_, dom_collapsed, 0); + comp_obj_heading_.metainfo.dom_structure_markedup_tags_status = dom_structure_markedup_tags_status.dup; + comp_obj_heading_.metainfo.dom_structure_collapsed_tags_status = dom_structure_collapsed_tags_status.dup; + comp_obj_heading_ = obj_dom_structure_set_markup_tags(comp_obj_heading_, dom_structure_markedup_tags_status, 0); + comp_obj_heading_ = obj_dom_set_collapsed_tags(comp_obj_heading_, dom_structure_collapsed_tags_status, 0); comp_obj_heading_ = obj_heading_ancestors(comp_obj_heading_, lv_ancestors_txt); // the_dom_tail_section ~= comp_obj_heading_; // remove tail for now, decide on later auto document_the = [ @@ -1885,16 +2076,60 @@ template SiSUdocAbstraction() { destroy(html_segnames); destroy(bookindex_unordered_hashes); destroy(an_object); - obj_cite_digits = ocn_emit(OCNstatus.reset); - biblio_arr_json = []; - obj_cite_digit_ = 0; - html_segnames_ptr = 0; - html_segnames_ptr_cntr = 0; - content_non_header = "8"; - dom_markedup = [ 0, 0, 0, 0, 0, 0, 0, 0, 0,]; - dom_markedup_buffer = [ 0, 0, 0, 0, 0, 0, 0, 0, 0,]; - dom_collapsed = [ 0, 0, 0, 0, 0, 0, 0, 0, 0,]; - dom_collapsed_buffer = [ 0, 0, 0, 0, 0, 0, 0, 0, 0,]; + obj_cite_digits = ocn_emit(OCNstatus.reset); + biblio_arr_json = []; + obj_cite_digit_ = 0; + html_segnames_ptr = 0; + html_segnames_ptr_cntr = 0; + content_non_header = "8"; + dom_structure_markedup_tags_status = [ 0, 0, 0, 0, 0, 0, 0, 0, 0,]; + dom_structure_markedup_tags_status_buffer = [ 0, 0, 0, 0, 0, 0, 0, 0, 0,]; + dom_structure_collapsed_tags_status = [ 0, 0, 0, 0, 0, 0, 0, 0, 0,]; + dom_structure_collapsed_tags_status_buffer = [ 0, 0, 0, 0, 0, 0, 0, 0, 0,]; + debug(abstraction) { + foreach (part; sequenced_document_keys.scroll) { + foreach (ref obj; document_the[part]) { + debug(node_misc) { + if (obj.metainfo.is_a == "heading") { + writeln("heading ancestors text?: ", obj.tags.heading_ancestors_text); + } + } + debug(node_headings) { + if (obj.metainfo.is_a == "heading") { + writeln("---"); + writeln(obj.text); + writeln(" node: ", obj.metainfo.node); + writeln(" ocn: ", obj.metainfo.ocn); + writeln(" markedup heading lev: ", obj.metainfo.heading_lev_markup); + writeln(" collapsed heading lev ", obj.metainfo.heading_lev_collapsed); + writeln(" parent ocn: ", obj.metainfo.parent_ocn); + writeln(" parent lev: ", obj.metainfo.parent_lev_markup); + writeln(" markedup ancestors o_n: ", obj.metainfo.markedup_ancestors); + writeln(" dom markedup: ", obj.metainfo.dom_structure_markedup_tags_status); + writeln(" collapsed ancestors o_n: ", obj.metainfo.collapsed_ancestors); + writeln(" dom collapsed: ", obj.metainfo.dom_structure_collapsed_tags_status); + } + } + debug(node_all) { + writeln("---"); + if (obj.metainfo.is_a == "heading") { + writeln(obj.text); + } + writeln("node: ", obj.metainfo.node); + writeln("ocn: ", obj.metainfo.ocn); + writeln("markedup heading lev: ", obj.metainfo.heading_lev_markup); + writeln("collapsed heading lev ", obj.metainfo.heading_lev_collapsed); + writeln("markedup ancestors o_n: ", obj.metainfo.markedup_ancestors); + writeln("collapsed ancestors o_n: ", obj.metainfo.collapsed_ancestors); + writeln("dom markedup: ", obj.metainfo.dom_structure_markedup_tags_status); + writeln("dom collapsed: ", obj.metainfo.dom_structure_collapsed_tags_status); + writeln("parent ocn: ", obj.metainfo.parent_ocn); + writeln("parent lev: ", obj.metainfo.parent_lev_markup); + writeln("Node: ", obj.metainfo.ocn); + } + } + } + } auto t = tuple( document_the, sequenced_document_keys, @@ -5473,7 +5708,7 @@ template SiSUdocAbstraction() { comp_obj_location.tags.segment_anchor_tag = segment_anchor_tag.to!string; comp_obj_location.metainfo.parent_ocn = p_["object_number"]; comp_obj_location.metainfo.parent_lev_markup = p_["lev_markup_number"]; - debug(node) { + debug(_node) { if (lev_markup_number.match(rgx.levels_numbered_headings)) { writeln("x ", _node.to!string); } else { @@ -5638,7 +5873,7 @@ template SiSUdocAbstraction() { _comp_obj_heading_.has.inline_notes_reg = flag_notes_reg; _comp_obj_heading_.has.inline_notes_star = flag_notes_star; _comp_obj_heading_.has.inline_links = flag_links; - debug(node) { + debug(_node) { if (lev_markup_number.match(rgx.levels_numbered_headings)) { writeln("* ", _node.to!string); } diff --git a/src/sdp/meta/object_setter.d b/src/sdp/meta/object_setter.d index a928ec8..09ce2ee 100644 --- a/src/sdp/meta/object_setter.d +++ b/src/sdp/meta/object_setter.d @@ -99,50 +99,50 @@ template ObjectSetter() { } return _out; } - int[] dom_markedup = [ 0, 0, 0, 0, 0, 0, 0, 0,]; - int[] dom_collapsed = [ 0, 0, 0, 0, 0, 0, 0, 0,]; - int[] heading_ancestors = [ 0, 0, 0, 0, 0, 0, 0, 0,]; - int parent_lev_markup = 0; - int parent_ocn = 0; - int[] ancestors = []; + 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,]; + int[] dom_structure_collapsed_tags_status = [ 0, 0, 0, 0, 0, 0, 0, 0,]; + int parent_lev_markup = 0; + int parent_ocn = 0; } - struct DocObj_TxtAttrib_ { // attrib - int indent_base = 0; - int indent_hang = 0; - bool bullet = false; - string language = ""; // not implemented, consider + struct DocObj_TxtAttrib_ { // attrib + int indent_base = 0; + int indent_hang = 0; + bool bullet = false; + string language = ""; // not implemented, consider } - struct DocObj_Has_ { // has - bool inline_links = false; - bool inline_notes_reg = false; - bool inline_notes_star = false; - bool contains_image_without_dimensions = false; + struct DocObj_Has_ { // has + bool inline_links = false; + bool inline_notes_reg = false; + bool inline_notes_star = false; + bool contains_image_without_dimensions = false; } - struct DocObj_Table_ { // table - int number_of_columns = 0; - double[] column_widths = []; - string[] column_aligns = []; - bool heading = false; - bool walls = false; // not implemented + struct DocObj_Table_ { // table + int number_of_columns = 0; + double[] column_widths = []; + string[] column_aligns = []; + bool heading = false; + bool walls = false; // not implemented } - struct DocObj_CodeBlock_ { // code_block - string syntax = ""; + struct DocObj_CodeBlock_ { // code_block + string syntax = ""; } - struct DocObj_Pointer_ { // ptr - int doc_object = 0; - int html_segnames = 0; - int heading = 0; + struct DocObj_Pointer_ { // ptr + int doc_object = 0; + int html_segnames = 0; + int heading = 0; } - struct DocObj_Tags_ { // tags - string[] heading_ancestors_text = [ "", "", "", "", "", "", "", "", ]; - string segment_anchor_tag = ""; - string segname_prev = ""; - string segname_next = ""; - string[] lev4_subtoc = []; - string[] anchor_tags = []; + struct DocObj_Tags_ { // tags + string[] heading_ancestors_text = [ "", "", "", "", "", "", "", "", ]; // TODO redundant? see markedup and collapsed ancestors DONE + string segment_anchor_tag = ""; + string segname_prev = ""; + string segname_next = ""; + string[] lev4_subtoc = []; + string[] anchor_tags = []; } struct ObjGenericComposite { - string text = ""; + string text = ""; DocObj_MetaInfo_ metainfo; DocObj_TxtAttrib_ attrib; DocObj_Tags_ tags; diff --git a/src/sdp/output/epub3.d b/src/sdp/output/epub3.d index 0e864f7..dce1b0c 100644 --- a/src/sdp/output/epub3.d +++ b/src/sdp/output/epub3.d @@ -150,7 +150,7 @@ template outputEPub3() { string _txt = obj.text.replaceAll(rgx.inline_notes_al_gen, "").strip; foreach_reverse (n; 0 .. 7) { string k = n.to!string; - switch (obj.metainfo.dom_collapsed[n]) { + switch (obj.metainfo.dom_structure_collapsed_tags_status[n]) { case DomTags.close : toc ~= markup.indent_by_spaces_provided((n + 1), " ") ~ "</li>" ~ "\n"; toc ~= markup.indent_by_spaces_provided(n, " ") ~ "</ol>" ~ "\n"; @@ -247,7 +247,7 @@ template outputEPub3() { string _txt = obj.text.replaceAll(rgx.inline_notes_al_gen, "").strip; string hashtag =(obj.metainfo.heading_lev_markup <= 4) ? "" : ("#" ~ obj.metainfo.ocn.to!string); foreach_reverse (k; 0 .. 7) { - switch (obj.metainfo.dom_markedup[k]) { + switch (obj.metainfo.dom_structure_markedup_tags_status[k]) { case DomTags.close : toc ~= "\n </navPoint>"; break; diff --git a/src/sdp/output/sqlite.d b/src/sdp/output/sqlite.d index 1aa578d..636fe6f 100644 --- a/src/sdp/output/sqlite.d +++ b/src/sdp/output/sqlite.d @@ -1031,9 +1031,9 @@ template SQLiteInsertDocObjectsLoop() { if ((doc_matters.opt.action.verbose)) { writeln( "markup: ", obj.metainfo.heading_lev_markup, - "> ", obj.metainfo.dom_markedup, + "> ", obj.metainfo.dom_structure_markedup_tags_status, "; collapsed: ", obj.metainfo.heading_lev_collapsed, - "> ", obj.metainfo.dom_collapsed, + "> ", obj.metainfo.dom_structure_collapsed_tags_status, "; ocn: ", obj.metainfo.ocn, " node: ", obj.metainfo.node, "; parent: ", obj.metainfo.parent_lev_markup, |