diff options
author | Ralph Amissah <ralph.amissah@gmail.com> | 2019-05-08 18:45:02 -0400 |
---|---|---|
committer | Ralph Amissah <ralph.amissah@gmail.com> | 2019-08-19 14:42:40 -0400 |
commit | 6b46ba599b7f687a592e2e50fdd007ed31319243 (patch) | |
tree | 9ba93fc931804a14506bae682eadaaef413f0024 | |
parent | book index sort: Aa-Zz (replaces A-Za-z) (diff) |
0.7.0 meta_abstruction, doc "has" struct replaces several tuples
-rw-r--r-- | org/doc_reform.org | 104 | ||||
-rw-r--r-- | org/meta_abstraction.org | 131 | ||||
-rw-r--r-- | org/meta_debugs.org | 18 | ||||
-rw-r--r-- | org/output_sqlite.org | 8 | ||||
-rw-r--r-- | org/output_xmls.org | 23 | ||||
-rwxr-xr-x | src/doc_reform/doc_reform.d | 1 | ||||
-rw-r--r-- | src/doc_reform/meta/doc_debugs.d | 18 | ||||
-rw-r--r-- | src/doc_reform/meta/metadoc.d | 57 | ||||
-rw-r--r-- | src/doc_reform/meta/metadoc_from_src.d | 121 | ||||
-rw-r--r-- | src/doc_reform/meta/metadoc_summary.d | 44 | ||||
-rw-r--r-- | src/doc_reform/meta/object_setter.d | 3 | ||||
-rw-r--r-- | src/doc_reform/output/epub3.d | 11 | ||||
-rw-r--r-- | src/doc_reform/output/html.d | 6 | ||||
-rw-r--r-- | src/doc_reform/output/sqlite.d | 8 | ||||
-rw-r--r-- | src/doc_reform/output/xmls.d | 6 | ||||
-rw-r--r-- | views/version.txt | 2 |
16 files changed, 343 insertions, 218 deletions
diff --git a/org/doc_reform.org b/org/doc_reform.org index 32b08be..5b1fc23 100644 --- a/org/doc_reform.org +++ b/org/doc_reform.org @@ -27,7 +27,7 @@ struct Version { int minor; int patch; } -enum _ver = Version(0, 6, 0); +enum _ver = Version(0, 7, 0); #+END_SRC ** compilation restrictions (supported compilers) @@ -583,6 +583,7 @@ struct OptActions { || manifest || pod || source + || sqlite_discrete ) { _is = true; } else { _is = false; } @@ -932,7 +933,7 @@ template DocReformAbstraction() { <<doc_reform_mixin>> enum headBody { header, body_content, insert_file_list, image_list } enum makeMeta { make, meta } - enum docAbst { doc_abstraction, section_keys, segnames, segnames_0_4, tag_assoc, images } + enum docAbst { doc_abstract_obj, doc_has } static auto rgx = Rgx(); auto DocReformAbstraction(E,P,O,M)( E _env, @@ -1068,17 +1069,9 @@ auto da = DocReformDocAbstraction!()( true, ); static assert(!isTypeTuple!(da)); -static assert(da.length==6); -auto doc_abstraction = da[docAbst.doc_abstraction]; /+ head ~ toc ~ body ~ endnotes_seg ~ glossary ~ bibliography ~ bookindex ~ blurb; +/ -auto _document_section_keys_sequenced = da[docAbst.section_keys]; -string[] _doc_html_segnames = da[docAbst.segnames]; -string[] _doc_epub_segnames_0_4 = da[docAbst.segnames_0_4]; -debug(segnames) { - writeln("segnames lv4: ", _doc_html_segnames); - writeln("segnames lv0 to 4: ", _doc_epub_segnames_0_4); -} -auto _doc_tag_assoc = da[docAbst.tag_assoc]; -auto _images = da[docAbst.images]; +static assert(da.length==2); +auto doc_abstraction = da[docAbst.doc_abstract_obj]; /+ head ~ toc ~ body ~ endnotes_seg ~ glossary ~ bibliography ~ bookindex ~ blurb; +/ +auto _doc_has_struct = da[docAbst.doc_has]; if ((_opt_action.debug_do) || (_opt_action.very_verbose) ) { @@ -1151,6 +1144,9 @@ struct DocumentMatters { auto conf_make_meta() { // TODO meld with all make instructions return _make_and_meta_struct; } + auto has() { + return _doc_has_struct; + } #+END_SRC **** env related @@ -1198,17 +1194,6 @@ struct DocumentMatters { auto src_path_info() { return DocReformPathsSRC!()(_manifest.env.pwd, _manifest.src.file_with_absolute_path); // would like (to have and use) relative path } - auto srcs() { - struct SRC_ { - auto file_insert_list() { - return _header_body_insertfilelist_imagelist[headBody.insert_file_list]; - } - auto image_list() { - return _images; - } - } - return SRC_(); - } auto pod() { return _manifest.pod; } @@ -1220,26 +1205,19 @@ struct DocumentMatters { } return SQLite_(); } - auto xml() { - struct XML_ { - auto keys_seq() { - /+ contains .seg & .scroll sequences +/ - return _document_section_keys_sequenced; - } - string[] segnames() { - return _doc_html_segnames; - } - string[] segnames_lv_0_to_4() { - return _doc_epub_segnames_0_4; + auto output_path() { + return _manifest.output.path; + } + auto srcs() { + struct SRC_ { + auto file_insert_list() { + return _header_body_insertfilelist_imagelist[headBody.insert_file_list]; } - auto tag_associations() { - return _doc_tag_assoc; + auto image_list() { + return _doc_has_struct.imagelist; } } - return XML_(); - } - auto output_path() { - return _manifest.output.path; + return SRC_(); } #+END_SRC @@ -1320,7 +1298,7 @@ string[string] check = [ "last_object_number_body" : "0", "last_object_number_book_index" : "0", ]; -foreach (k; doc_matters.xml.keys_seq.seg) { +foreach (k; doc_matters.has.keys_seq.seg) { foreach (obj; doc_abstraction[k]) { if (obj.metainfo.is_of_part != "empty") { if (!empty(obj.metainfo.object_number)) { @@ -1352,48 +1330,58 @@ char_repeat_number = (char_repeat_number > min_repeat_number) ? char_repeat_number : min_repeat_number; writefln( - "%s\n\"%s\", %s\n%s\n%s\n%30-s%10-d\n%30-s%10-d\n%30-s%10-d\n%30-s%10-d\n%30-s%10-d\n%30-s%10-d\n%30-s%10-d\n%30-s%10-d\n%30-s%10-d\n%30-s%10-d\n%30-s%10-d\n(%s: %s)\n%s", + "%s\n\"%s\", %s\n%s\n%s\n%30-s%10-d\n%30-s%10-d\n%30-s%10-d\n%30-s%10-d\n%30-s%10-d\n%30-s%10-d\n%30-s%10-d\n%30-s%10-d\n%30-s%10-d\n%30-s%10-d\n%30-s%10-d\n%30-s%10-d\n%30-s%10-d\n%30-s%10-d\n%30-s%10-d\n%30-s%10-d\n%30-s%10-d\n%s", markup.repeat_character_by_number_provided("-", char_repeat_number), doc_matters.conf_make_meta.meta.title_full, doc_matters.conf_make_meta.meta.creator_author, doc_matters.src.filename, markup.repeat_character_by_number_provided("-", char_repeat_number), - "length toc arr:", + "- toc arr length:", to!int(doc_abstraction["toc"].length), - "length doc_abstraction arr:", + "- doc_abstraction arr length:", to!int(doc_abstraction["body"].length), - "last doc body ocn:", + " doc body last obj on.#:", to!int(check["last_object_number_body"]), - "last object_number:", - to!int(check["last_object_number"]), - "length endnotes:", // subtract headings + " - number of tables:", + doc_matters.has.tables, + " - number of codeblocks:", + doc_matters.has.codeblocks, + " - number of poems:", + doc_matters.has.poems, + " - number of blocks:", + doc_matters.has.blocks, + " - number of groups:", + doc_matters.has.groups, + " - number of images:", + doc_matters.has.images, + "- endnotes length:", // subtract headings (doc_abstraction["endnotes"].length > 2) ? (to!int(doc_abstraction["endnotes"].length - 2)) : 0, - "length glossary:", + "- glossary length:", (doc_abstraction["glossary"].length > 1) ? (to!int(doc_abstraction["glossary"].length)) : 0, - "length biblio:", + "- biblio length:", (doc_abstraction["bibliography"].length > 1) ? (to!int(doc_abstraction["bibliography"].length)) : 0, - "length bookindex:", + "- bookindex length:", (doc_abstraction["bookindex"].length > 1) ? (to!int(doc_abstraction["bookindex"].length)) : 0, - " last book idx ocn:", + " book idx last obj on.#:", to!int(check["last_object_number_book_index"]), - "length blurb:", + "- blurb length:", (doc_abstraction["blurb"].length > 1) ? (to!int(doc_abstraction["blurb"].length)) : 0, + "* last obj on.#:", + to!int(check["last_object_number"]), "number of segments:", - (doc_matters.xml.segnames.length > 1) - ? (to!int(doc_matters.xml.segnames.length)) + (doc_matters.has.segnames_lv4.length > 1) + ? (to!int(doc_matters.has.segnames_lv4.length)) : 0, - __FILE__, - __LINE__, markup.repeat_character_by_number_provided("-", min_repeat_number), ); #+END_SRC diff --git a/org/meta_abstraction.org b/org/meta_abstraction.org index 3f5ba11..d6d687e 100644 --- a/org/meta_abstraction.org +++ b/org/meta_abstraction.org @@ -82,6 +82,7 @@ template DocReformDocAbstraction() { /+ ↓ post loop markup document/text +/ <<abs_post>> <<abs_post_doc_reloop_processing>> + <<abs_struct_doc_has>> <<abs_return_tuple>> /+ post loop markup document/text ↑ +/ } /+ ← closed: abstract doc source +/ @@ -526,6 +527,18 @@ line_occur = [ "glossary" : 0, "blurb" : 0, ]; +uint[string] dochas = [ + "inline_links" : 0, + "inline_notes" : 0, + "inline_notes_star" : 0, + "codeblock" : 0, + "table" : 0, + "block" : 0, + "group" : 0, + "poem" : 0, + "quote" : 0, + "images" : 0, +]; auto obj_type_status = flags_type_init; string[string] object_number_poem = [ "start" : "", @@ -1085,7 +1098,7 @@ if (line.matchFirst(rgx.block_poem_open)) { / processing.remove("verse"); object_number_poem["start"] = obj_cite_digits.object_number.to!string; } -line.flow_txt_block_start(obj_type_status, object_number_poem); +line.flow_txt_block_start(obj_type_status, dochas, object_number_poem); continue; #+END_SRC @@ -2315,7 +2328,7 @@ auto extract_images(S)(S content_block) { } return images_; } -string[] segnames_lv0_to_4; +string[] segnames_0_to_4; #+END_SRC ****** images: dimensions @@ -2405,7 +2418,7 @@ foreach (ref obj; the_document_head_section) { writeln(obj.text); } if (obj.metainfo.heading_lev_markup <= 4) { - segnames_lv0_to_4 ~= obj.tags.segment_anchor_tag_epub; + segnames_0_to_4 ~= obj.tags.segment_anchor_tag_epub; } if (obj.metainfo.heading_lev_markup == 0) { /+ TODO second hit (of two) with same assertion failure, check, fix and reinstate @@ -2443,7 +2456,7 @@ if (the_table_of_contents_section.length > 1) { foreach (ref obj; the_table_of_contents_section) { if (obj.metainfo.is_a == "heading") { if (obj.metainfo.heading_lev_markup <= 4) { - segnames_lv0_to_4 ~= obj.tags.segment_anchor_tag_epub; + segnames_0_to_4 ~= obj.tags.segment_anchor_tag_epub; if (obj.metainfo.heading_lev_markup == 4) { obj.tags.segname_next = segnames["html"][obj.ptr.html_segnames + 1]; assert(obj.tags.anchor_tag_html == segnames["html"][obj.ptr.html_segnames], @@ -2489,7 +2502,7 @@ if (the_document_body_section.length > 1) { writeln(obj.text); } if (obj.metainfo.heading_lev_markup <= 4) { - segnames_lv0_to_4 ~= obj.tags.segment_anchor_tag_epub; + segnames_0_to_4 ~= obj.tags.segment_anchor_tag_epub; if (obj.metainfo.heading_lev_markup == 4) { obj.tags.lev4_subtoc = lev4_subtoc[obj.tags.anchor_tag_html]; obj.tags.segname_prev = segnames["html"][obj.ptr.html_segnames - 1]; @@ -2518,7 +2531,7 @@ if (the_document_body_section.length > 1) { obj = _links(obj); } } -auto images=uniq(_images.sort()); +auto image_list = (_images.sort()).uniq; #+END_SRC ***** ↻ Loop section: endnotes [en] @@ -2542,7 +2555,7 @@ if (the_endnotes_section.length > 1) { obj.metainfo.ocn = obj_cite_digits.object_number; obj.metainfo.identifier = obj_cite_digits.identifier; if (obj.metainfo.heading_lev_markup <= 4) { - segnames_lv0_to_4 ~= obj.tags.segment_anchor_tag_epub; + segnames_0_to_4 ~= obj.tags.segment_anchor_tag_epub; if (obj.metainfo.heading_lev_markup == 4) { obj.tags.segname_prev = segnames["html"][obj.ptr.html_segnames - 1]; if (segnames["html"].length > obj.ptr.html_segnames + 1) { @@ -2586,7 +2599,7 @@ if (the_glossary_section.length > 1) { obj.metainfo.ocn = obj_cite_digits.object_number; obj.metainfo.identifier = obj_cite_digits.identifier; if (obj.metainfo.heading_lev_markup <= 4) { - segnames_lv0_to_4 ~= obj.tags.segment_anchor_tag_epub; + segnames_0_to_4 ~= obj.tags.segment_anchor_tag_epub; if (obj.metainfo.heading_lev_markup == 4) { obj.tags.segname_prev = segnames["html"][obj.ptr.html_segnames - 1]; if (segnames["html"].length > obj.ptr.html_segnames + 1) { @@ -2634,7 +2647,7 @@ if (the_bibliography_section.length > 1) { obj.metainfo.ocn = obj_cite_digits.object_number; obj.metainfo.identifier = obj_cite_digits.identifier; if (obj.metainfo.heading_lev_markup <= 4) { - segnames_lv0_to_4 ~= obj.tags.segment_anchor_tag_epub; + segnames_0_to_4 ~= obj.tags.segment_anchor_tag_epub; if (obj.metainfo.heading_lev_markup == 4) { obj.tags.segname_prev = segnames["html"][obj.ptr.html_segnames - 1]; if (segnames["html"].length > obj.ptr.html_segnames + 1) { @@ -2683,7 +2696,7 @@ if (the_bookindex_section.length > 1) { / debug(dom) { } if (obj.metainfo.heading_lev_markup <= 4) { - segnames_lv0_to_4 ~= obj.tags.segment_anchor_tag_epub; + segnames_0_to_4 ~= obj.tags.segment_anchor_tag_epub; } obj_cite_digits = ocn_emit(OCNstatus.on); obj.metainfo.ocn = obj_cite_digits.object_number; @@ -2740,7 +2753,7 @@ if (the_blurb_section.length > 1) { obj.metainfo.ocn = obj_cite_digits.object_number; obj.metainfo.identifier = obj_cite_digits.identifier; if (obj.metainfo.heading_lev_markup <= 4) { - segnames_lv0_to_4 ~= obj.tags.segment_anchor_tag_epub; + segnames_0_to_4 ~= obj.tags.segment_anchor_tag_epub; if (obj.metainfo.heading_lev_markup == 4) { obj.tags.segname_prev = segnames["html"][obj.ptr.html_segnames - 1]; if (segnames["html"].length > obj.ptr.html_segnames + 1) { @@ -2967,17 +2980,16 @@ if ((opt_action.html) document_section_keys_sequenced["scroll"] ~= "tail"; document_section_keys_sequenced["seg"] ~= "tail"; } -auto sequenced_document_keys = docSectKeysSeq!()(document_section_keys_sequenced); #+END_SRC *** dup #+name: abs_post #+BEGIN_SRC d -auto segnames_lv4 = segnames["html"].dup; +auto segnames_4 = segnames["html"].dup; auto segnames_lv1_to_4 = segnames["epub"].dup; debug(segnames) { - writeln("segnames_lv4: ", segnames_lv4); + writeln("segnames_lv4: ", segnames_4); writeln("segnames_lv1_to_4: ", segnames_lv1_to_4); } #+END_SRC @@ -3009,17 +3021,69 @@ 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,]; #+END_SRC +*** doc_has struct + +#+name: abs_struct_doc_has +#+BEGIN_SRC d +auto doc_has() { + struct DocHas_ { + uint inline_links() { + return dochas["inline_links"]; + } + uint inline_notes_reg() { + return dochas["inline_notes"]; + } + uint inline_notes_star() { + return dochas["inline_notes_star"]; + } + uint codeblocks() { + return dochas["codeblock"]; + } + uint tables() { + return dochas["table"]; + } + uint blocks() { + return dochas["block"]; + } + uint groups() { + return dochas["group"]; + } + uint poems() { + return dochas["poem"]; + } + uint quotes() { + return dochas["quote"]; + } + ulong images() { // TODO not ideal rethink + return (image_list.to!string.strip("[","]").split(",").length); + } + auto imagelist() { + return image_list; + } + auto keys_seq() { + return docSectKeysSeq!()(document_section_keys_sequenced); + } + string[] segnames_lv4() { + return segnames_4; + } + string[] segnames_lv_0_to_4() { + return segnames_0_to_4; + } + string[string][string] tag_associations() { + return tag_assoc; + } + } + return DocHas_(); +} +#+END_SRC + *** _return document tuple_ [#A] :return:tuple: #+name: abs_return_tuple #+BEGIN_SRC d auto t = tuple( document_the, - sequenced_document_keys, - segnames_lv4, - segnames_lv0_to_4, - tag_assoc, - images, + doc_has, ); return t; #+END_SRC @@ -3203,9 +3267,10 @@ auto _doc_header_and_make_substitutions_fontface_(L,CMM)( #+name: abs_functions_block #+BEGIN_SRC d void flow_txt_block_start(L,T,N)( - L line, - return ref T obj_type_status, - return ref N object_number_poem + L line, + return ref T obj_type_status, + return ref uint[string] dochas, + return ref N object_number_poem ) { debug(asserts) { static assert(is(typeof(line) == char[])); @@ -3226,6 +3291,7 @@ void flow_txt_block_start(L,T,N)( #+name: abs_functions_block #+BEGIN_SRC d if (auto m = line.matchFirst(rgx.block_curly_code_open)) { + dochas["codeblock"]++; an_object["lang"] = ""; an_object["attrib"] = (m["attrib"]) ? m["attrib"].to!string : ""; an_object["syntax"] = (m["syntax"]) ? m["syntax"].to!string : ""; @@ -3245,6 +3311,7 @@ void flow_txt_block_start(L,T,N)( #+name: abs_functions_block #+BEGIN_SRC d } else if (auto m = line.matchFirst(rgx.block_curly_poem_open)) { + dochas["poem"]++; an_object["syntax"] = ""; an_object["attrib"] = (m["attrib"]) ? m["attrib"].to!string : ""; an_object["lang"] = (m["lang"]) ? m["lang"].to!string : ""; @@ -3266,6 +3333,7 @@ void flow_txt_block_start(L,T,N)( #+name: abs_functions_block #+BEGIN_SRC d } else if (auto m = line.matchFirst(rgx.block_curly_group_open)) { + dochas["group"]++; an_object["syntax"] = ""; an_object["attrib"] = (m["attrib"]) ? m["attrib"].to!string : ""; an_object["lang"] = (m["lang"]) ? m["lang"].to!string : ""; @@ -3285,6 +3353,7 @@ void flow_txt_block_start(L,T,N)( #+name: abs_functions_block #+BEGIN_SRC d } else if (auto m = line.matchFirst(rgx.block_curly_block_open)) { + dochas["block"]++; an_object["syntax"] = ""; an_object["attrib"] = (m["attrib"]) ? m["attrib"].to!string : ""; an_object["lang"] = (m["lang"]) ? m["lang"].to!string : ""; @@ -3304,6 +3373,7 @@ void flow_txt_block_start(L,T,N)( #+name: abs_functions_block #+BEGIN_SRC d } else if (auto m = line.matchFirst(rgx.block_curly_quote_open)) { + dochas["quote"]++; an_object["syntax"] = ""; an_object["attrib"] = m["attrib"].to!string; an_object["lang"] = m["lang"].to!string; @@ -3329,6 +3399,7 @@ void flow_txt_block_start(L,T,N)( line ); } + dochas["table"] ++; an_object["table_head"] = m["attrib"].to!string; an_object["block_type"] = "curly"; obj_type_status["blocks"] = TriState.on; @@ -3341,6 +3412,7 @@ void flow_txt_block_start(L,T,N)( #+name: abs_functions_block #+BEGIN_SRC d } else if (auto m = line.matchFirst(rgx.block_curly_table_special_markup)) { /+ table: special table block markup syntax! +/ + dochas["table"]++; an_object["table_head"] = m["attrib"].to!string; an_object["block_type"] = "special"; obj_type_status["blocks"] = TriState.on; @@ -3354,6 +3426,7 @@ void flow_txt_block_start(L,T,N)( #+name: abs_functions_block #+BEGIN_SRC d } else if (auto m = line.matchFirst(rgx.block_tic_code_open)) { + dochas["codeblock"]++; an_object["lang"] = ""; an_object["attrib"] = (m["attrib"]) ? m["attrib"].to!string : ""; an_object["syntax"] = (m["syntax"]) ? m["syntax"].to!string : ""; @@ -3373,6 +3446,7 @@ void flow_txt_block_start(L,T,N)( #+name: abs_functions_block #+BEGIN_SRC d } else if (auto m = line.matchFirst(rgx.block_tic_poem_open)) { + dochas["poem"]++; an_object["syntax"] = ""; an_object["attrib"] = (m["attrib"]) ? m["attrib"].to!string : ""; an_object["lang"] = (m["lang"]) ? m["lang"].to!string : ""; @@ -3394,6 +3468,7 @@ void flow_txt_block_start(L,T,N)( #+name: abs_functions_block #+BEGIN_SRC d } else if (auto m = line.matchFirst(rgx.block_tic_group_open)) { + dochas["group"]++; an_object["syntax"] = ""; an_object["attrib"] = (m["attrib"]) ? m["attrib"].to!string : ""; an_object["lang"] = (m["lang"]) ? m["lang"].to!string : ""; @@ -3413,6 +3488,7 @@ void flow_txt_block_start(L,T,N)( #+name: abs_functions_block #+BEGIN_SRC d } else if (auto m = line.matchFirst(rgx.block_tic_block_open)) { + dochas["block"]++; an_object["syntax"] = ""; an_object["attrib"] = (m["attrib"]) ? m["attrib"].to!string : ""; an_object["lang"] = (m["lang"]) ? m["lang"].to!string : ""; @@ -3432,6 +3508,7 @@ void flow_txt_block_start(L,T,N)( #+name: abs_functions_block #+BEGIN_SRC d } else if (auto m = line.matchFirst(rgx.block_tic_quote_open)) { + dochas["quote"]++; an_object["syntax"] = ""; an_object["attrib"] = m["attrib"].to!string; an_object["lang"] = m["lang"].to!string; @@ -3457,6 +3534,7 @@ void flow_txt_block_start(L,T,N)( line ); } + dochas["table"] ++; an_object["table_head"] = m["attrib"].to!string; an_object["block_type"] = "tic"; obj_type_status["blocks"] = TriState.on; @@ -7788,13 +7866,13 @@ pure void assertions_flag_types_block_status_none_or_closed(T)(T obj_type_status template docSectKeysSeq() { auto docSectKeysSeq(string[][string] document_section_keys_sequenced) { struct doc_sect_keys_seq { - auto scroll() { + string[] scroll() { return document_section_keys_sequenced["scroll"]; } - auto seg() { + string[] seg() { return document_section_keys_sequenced["seg"]; } - auto sql() { + string[] sql() { return document_section_keys_sequenced["sql"]; } } @@ -7933,10 +8011,11 @@ struct DocObj_TxtAttrib_ { #+name: meta_structs_init #+BEGIN_SRC d -struct DocObj_Has_ { // has +struct DocObj_Has_ { // doc object has bool inline_links = false; bool inline_notes_reg = false; bool inline_notes_star = false; + bool images = false; bool image_without_dimensions = false; } #+END_SRC diff --git a/org/meta_debugs.org b/org/meta_debugs.org index 7aa01ad..bd141cd 100644 --- a/org/meta_debugs.org +++ b/org/meta_debugs.org @@ -87,7 +87,7 @@ debug(parent) { __FILE__, __LINE__, ); - foreach (key; doc_matters.xml.keys_seq.seg) { + foreach (key; doc_matters.has.keys_seq.seg) { foreach (obj; contents[key]) { if (obj.metainfo.is_of_part != "empty") { if (obj.metainfo.is_a == "heading") { @@ -127,11 +127,11 @@ debug(checkdoc) { const S contents, T doc_matters, ) { - foreach (key; doc_matters.xml.keys_seq.seg) { + foreach (key; doc_matters.has.keys_seq.seg) { if (contents[key].length > 1) { foreach (obj; contents[key]) { if (obj.heading_lev_markup == 4) { - writeln(obj.ptr_html_segnames, ". (", doc_matters.xml.segnames[obj.ptr_html_segnames], ") -> ", obj.text); + writeln(obj.ptr_html_segnames, ". (", doc_matters.has.segnames_lv4[obj.ptr_html_segnames], ") -> ", obj.text); } } } @@ -286,7 +286,7 @@ debug(section_body) { #+BEGIN_SRC d debug(toc_nav_dom) { enum DomTags { none, open, close, close_and_open, open_still, } - foreach (sect; doc_matters.xml.keys_seq.seg) { + foreach (sect; doc_matters.has.keys_seq.seg) { foreach (obj; contents[sect]) { if (obj.metainfo.is_a == "heading") { foreach_reverse (k; 0 .. 7) { @@ -313,7 +313,7 @@ debug(toc_nav_dom) { } } writeln("--------------------"); - foreach (sect; doc_matters.xml.keys_seq.seg) { + foreach (sect; doc_matters.has.keys_seq.seg) { foreach (obj; contents[sect]) { if (obj.metainfo.is_a == "heading") { foreach_reverse (k; 0 .. 7) { @@ -347,7 +347,7 @@ debug(toc_nav_dom) { #+name: meta_output_debugs #+BEGIN_SRC d debug(decendants) { - foreach (sect; doc_matters.xml.keys_seq.scroll) { + foreach (sect; doc_matters.has.keys_seq.scroll) { foreach (obj; contents[sect]) { if (obj.metainfo.is_a == "heading") { writeln(obj.metainfo.ocn, " .. ", obj.metainfo.last_decendant_ocn); @@ -659,7 +659,7 @@ debug(anchor) { __FILE__, __LINE__, ); - foreach (k; doc_matters.xml.keys_seq.seg) { + foreach (k; doc_matters.has.keys_seq.seg) { foreach (obj; contents[k]) { if (obj.metainfo.is_a == "heading") { writefln( @@ -680,7 +680,7 @@ debug(anchor) { #+name: meta_output_debugs #+BEGIN_SRC d debug(heading) { // heading - foreach (k; doc_matters.xml.keys_seq.seg) { + foreach (k; doc_matters.has.keys_seq.seg) { foreach (o; contents[k]) { if (o.metainfo.is_a == "heading") { writefln( @@ -706,7 +706,7 @@ debug(headings) { __FILE__, __LINE__, ); - foreach (k; doc_matters.xml.keys_seq.seg) { + foreach (k; doc_matters.has.keys_seq.seg) { foreach (obj; contents[k]) { if (obj.metainfo.is_a == "heading") { writefln( diff --git a/org/output_sqlite.org b/org/output_sqlite.org index 6894c56..c9123d3 100644 --- a/org/output_sqlite.org +++ b/org/output_sqlite.org @@ -550,8 +550,8 @@ auto inline_links(M,O)( auto pth_html = DocReformPathsHTML!()(doc_matters.output_path, doc_matters.src.language); if (_xml_type == "seg") { foreach (m; _txt.match(rgx.inline_link_hash)) { - if (m.captures[3] in doc_matters.xml.tag_associations) { - if (m.captures[3] == doc_matters.xml.tag_associations[(m.captures[3])]["seg_lv4"]) { + if (m.captures[3] in doc_matters.has.tag_associations) { + if (m.captures[3] == doc_matters.has.tag_associations[(m.captures[3])]["seg_lv4"]) { _txt = _txt.replaceFirst( rgx.inline_link_hash, "┥$1┝┤" @@ -566,7 +566,7 @@ auto inline_links(M,O)( "┥$1┝┤" ~ doc_matters.conf_make_meta.conf.webserv_url_doc_root ~ "/" - ~ doc_matters.xml.tag_associations[(m.captures[3])]["seg_lv4"] + ~ doc_matters.has.tag_associations[(m.captures[3])]["seg_lv4"] ~ ".html" ~ "#" ~ "$3" ~ "├" @@ -1261,7 +1261,7 @@ auto format_and_sqlite_load = SQLiteFormatAndLoadObject!()(doc_matters); string[string] obj_txt; string doc_text; string[] _insert_doc_objects; -foreach (part; doc_matters.xml.keys_seq.sql) { +foreach (part; doc_matters.has.keys_seq.sql) { foreach (obj; doc_abstraction[part]) { switch (obj.metainfo.is_of_part) { case "frontmatter": assert(part == "head", part); diff --git a/org/output_xmls.org b/org/output_xmls.org index 21f4876..14d4f24 100644 --- a/org/output_xmls.org +++ b/org/output_xmls.org @@ -489,10 +489,10 @@ auto inline_links(O,M)( if (_xml_type == "seg" || _xml_type == "epub") { seg_lvs = (_xml_type == "epub") ? "seg_lv1_to_4" : "seg_lv4"; foreach (m; _txt.match(rgx.inline_link_hash)) { - if (m.captures[3] in doc_matters.xml.tag_associations) { + if (m.captures[3] in doc_matters.has.tag_associations) { if ( m.captures[3] - == doc_matters.xml.tag_associations[(m.captures[3])][seg_lvs] + == doc_matters.has.tag_associations[(m.captures[3])][seg_lvs] ) { _txt = _txt.replaceFirst( rgx.inline_link_hash, @@ -502,7 +502,7 @@ auto inline_links(O,M)( _txt = _txt.replaceFirst( rgx.inline_link_hash, "┥$1┝┤" - ~ doc_matters.xml.tag_associations[(m.captures[3])][seg_lvs] + ~ doc_matters.has.tag_associations[(m.captures[3])][seg_lvs] ~ _suffix ~ "#" ~ "$3" ~ "├" ); @@ -1486,7 +1486,7 @@ void scroll(D,M)( #+name: output_html_scroll #+BEGIN_SRC d - foreach (part; doc_matters.xml.keys_seq.scroll) { + foreach (part; doc_matters.has.keys_seq.scroll) { foreach (obj; doc_abstraction[part]) { delimit = xhtml_format.div_delimit(part, previous_part); string _txt = xhtml_format.special_characters(obj); @@ -1726,7 +1726,7 @@ void seg(D,M)( #+name: output_html_seg #+BEGIN_SRC d - foreach (part; doc_matters.xml.keys_seq.seg) { + foreach (part; doc_matters.has.keys_seq.seg) { foreach (obj; doc_abstraction[part]) { delimit = xhtml_format.div_delimit(part, previous_part); string _txt = xhtml_format.special_characters(obj); @@ -2022,7 +2022,7 @@ void seg_write_output(M,D,E)( if (!exists(pth_html.seg(doc_matters.src.filename))) { pth_html.seg(doc_matters.src.filename).mkdirRecurse; } - foreach (seg_filename; doc_matters.xml.segnames) { + foreach (seg_filename; doc_matters.has.segnames_lv4) { auto f = File(pth_html.fn_seg(doc_matters.src.filename, seg_filename), "w"); foreach (docseg; doc_html[seg_filename]) { f.writeln(docseg); @@ -2247,7 +2247,7 @@ string epub3_oebps_content(D,M,P)(D doc_abstraction, M doc_matters, P parts) { content ~= " " ~ "</guide>" ~ "\n "; content ~= "" ~ "</package>"; debug(epubmanifest) { - foreach (part; doc_matters.xml.keys_seq.seg) { // TODO + foreach (part; doc_matters.has.keys_seq.seg) { // TODO foreach (obj; doc_abstraction[part]) { if (obj.metainfo.is_a == "heading") { if (obj.metainfo.heading_lev_markup == 4) { @@ -2297,7 +2297,7 @@ string epub3_oebps_toc_nav_xhtml(D,I)(D doc_abstraction, I doc_matters) { <nav epub:type=\"toc\" id=\"toc\">\n", doc_matters.conf_make_meta.meta.title_full, ); - foreach (sect; doc_matters.xml.keys_seq.seg) { + foreach (sect; doc_matters.has.keys_seq.seg) { foreach (obj; doc_abstraction[sect]) { if (obj.metainfo.is_a == "heading") { string _txt = obj.text.replaceAll(rgx.inline_notes_al_gen, "").strip; @@ -2403,7 +2403,7 @@ string epub2_oebps_toc_ncx(D,I)(D doc_abstraction, I doc_matters) { (doc_matters.conf_make_meta.meta.creator_author.empty) ? "" : doc_matters.conf_make_meta.meta.creator_author, // author ); - foreach (sect; doc_matters.xml.keys_seq.seg) { + foreach (sect; doc_matters.has.keys_seq.seg) { foreach (obj; doc_abstraction[sect]) { if (obj.metainfo.is_a == "heading") { string _txt = obj.text.replaceAll(rgx.inline_notes_al_gen, "").strip; @@ -2489,14 +2489,13 @@ void outputEPub3(D,I)( string[] doc_parts; } auto epubWrite = writeOut(); - // writeln(doc_matters.xml.keys_seq.seg); #+END_SRC **** ↻ the loop (sections & objects) format output #+name: output_epub3_xhtml_seg #+BEGIN_SRC d - foreach (part; doc_matters.xml.keys_seq.seg) { + foreach (part; doc_matters.has.keys_seq.seg) { foreach (obj; doc_abstraction[part]) { string _txt = xhtml_format.special_characters(obj); #+END_SRC @@ -2874,7 +2873,7 @@ void epub3_write_output_files(W,I)( } } { /+ OEBPS/[segments].xhtml (the document contents) +/ - foreach (seg_filename; doc_matters.xml.segnames_lv_0_to_4) { + foreach (seg_filename; doc_matters.has.segnames_lv_0_to_4) { string fn = pth_epub3.fn_oebps_content_xhtml(doc_matters.src.filename, seg_filename); auto zip_arc_member_file = new ArchiveMember(); zip_arc_member_file.name = fn; diff --git a/src/doc_reform/doc_reform.d b/src/doc_reform/doc_reform.d index baffbc9..ae92a97 100755 --- a/src/doc_reform/doc_reform.d +++ b/src/doc_reform/doc_reform.d @@ -384,6 +384,7 @@ void main(string[] args) { || manifest || pod || source + || sqlite_discrete ) { _is = true; } else { _is = false; } diff --git a/src/doc_reform/meta/doc_debugs.d b/src/doc_reform/meta/doc_debugs.d index 5ca5c39..f96a942 100644 --- a/src/doc_reform/meta/doc_debugs.d +++ b/src/doc_reform/meta/doc_debugs.d @@ -37,7 +37,7 @@ template DocReformDebugs() { __FILE__, __LINE__, ); - foreach (key; doc_matters.xml.keys_seq.seg) { + foreach (key; doc_matters.has.keys_seq.seg) { foreach (obj; contents[key]) { if (obj.metainfo.is_of_part != "empty") { if (obj.metainfo.is_a == "heading") { @@ -100,7 +100,7 @@ template DocReformDebugs() { } debug(toc_nav_dom) { enum DomTags { none, open, close, close_and_open, open_still, } - foreach (sect; doc_matters.xml.keys_seq.seg) { + foreach (sect; doc_matters.has.keys_seq.seg) { foreach (obj; contents[sect]) { if (obj.metainfo.is_a == "heading") { foreach_reverse (k; 0 .. 7) { @@ -127,7 +127,7 @@ template DocReformDebugs() { } } writeln("--------------------"); - foreach (sect; doc_matters.xml.keys_seq.seg) { + foreach (sect; doc_matters.has.keys_seq.seg) { foreach (obj; contents[sect]) { if (obj.metainfo.is_a == "heading") { foreach_reverse (k; 0 .. 7) { @@ -155,7 +155,7 @@ template DocReformDebugs() { } } debug(decendants) { - foreach (sect; doc_matters.xml.keys_seq.scroll) { + foreach (sect; doc_matters.has.keys_seq.scroll) { foreach (obj; contents[sect]) { if (obj.metainfo.is_a == "heading") { writeln(obj.metainfo.ocn, " .. ", obj.metainfo.last_decendant_ocn); @@ -393,7 +393,7 @@ template DocReformDebugs() { __FILE__, __LINE__, ); - foreach (k; doc_matters.xml.keys_seq.seg) { + foreach (k; doc_matters.has.keys_seq.seg) { foreach (obj; contents[k]) { if (obj.metainfo.is_a == "heading") { writefln( @@ -408,7 +408,7 @@ template DocReformDebugs() { } } debug(heading) { // heading - foreach (k; doc_matters.xml.keys_seq.seg) { + foreach (k; doc_matters.has.keys_seq.seg) { foreach (o; contents[k]) { if (o.metainfo.is_a == "heading") { writefln( @@ -428,7 +428,7 @@ template DocReformDebugs() { __FILE__, __LINE__, ); - foreach (k; doc_matters.xml.keys_seq.seg) { + foreach (k; doc_matters.has.keys_seq.seg) { foreach (obj; contents[k]) { if (obj.metainfo.is_a == "heading") { writefln( @@ -580,11 +580,11 @@ template DocReformDebugs() { const S contents, T doc_matters, ) { - foreach (key; doc_matters.xml.keys_seq.seg) { + foreach (key; doc_matters.has.keys_seq.seg) { if (contents[key].length > 1) { foreach (obj; contents[key]) { if (obj.heading_lev_markup == 4) { - writeln(obj.ptr_html_segnames, ". (", doc_matters.xml.segnames[obj.ptr_html_segnames], ") -> ", obj.text); + writeln(obj.ptr_html_segnames, ". (", doc_matters.has.segnames_lv4[obj.ptr_html_segnames], ") -> ", obj.text); } } } diff --git a/src/doc_reform/meta/metadoc.d b/src/doc_reform/meta/metadoc.d index a57159d..d8cc19f 100644 --- a/src/doc_reform/meta/metadoc.d +++ b/src/doc_reform/meta/metadoc.d @@ -27,7 +27,7 @@ template DocReformAbstraction() { mixin outputHub; enum headBody { header, body_content, insert_file_list, image_list } enum makeMeta { make, meta } - enum docAbst { doc_abstraction, section_keys, segnames, segnames_0_4, tag_assoc, images } + enum docAbst { doc_abstract_obj, doc_has } static auto rgx = Rgx(); auto DocReformAbstraction(E,P,O,M)( E _env, @@ -92,17 +92,9 @@ template DocReformAbstraction() { true, ); static assert(!isTypeTuple!(da)); - static assert(da.length==6); - auto doc_abstraction = da[docAbst.doc_abstraction]; /+ head ~ toc ~ body ~ endnotes_seg ~ glossary ~ bibliography ~ bookindex ~ blurb; +/ - auto _document_section_keys_sequenced = da[docAbst.section_keys]; - string[] _doc_html_segnames = da[docAbst.segnames]; - string[] _doc_epub_segnames_0_4 = da[docAbst.segnames_0_4]; - debug(segnames) { - writeln("segnames lv4: ", _doc_html_segnames); - writeln("segnames lv0 to 4: ", _doc_epub_segnames_0_4); - } - auto _doc_tag_assoc = da[docAbst.tag_assoc]; - auto _images = da[docAbst.images]; + static assert(da.length==2); + auto doc_abstraction = da[docAbst.doc_abstract_obj]; /+ head ~ toc ~ body ~ endnotes_seg ~ glossary ~ bibliography ~ bookindex ~ blurb; +/ + auto _doc_has_struct = da[docAbst.doc_has]; if ((_opt_action.debug_do) || (_opt_action.very_verbose) ) { @@ -152,6 +144,9 @@ template DocReformAbstraction() { auto conf_make_meta() { // TODO meld with all make instructions return _make_and_meta_struct; } + auto has() { + return _doc_has_struct; + } auto env() { struct Env_ { auto pwd() { @@ -181,17 +176,6 @@ template DocReformAbstraction() { auto src_path_info() { return DocReformPathsSRC!()(_manifest.env.pwd, _manifest.src.file_with_absolute_path); // would like (to have and use) relative path } - auto srcs() { - struct SRC_ { - auto file_insert_list() { - return _header_body_insertfilelist_imagelist[headBody.insert_file_list]; - } - auto image_list() { - return _images; - } - } - return SRC_(); - } auto pod() { return _manifest.pod; } @@ -203,26 +187,19 @@ template DocReformAbstraction() { } return SQLite_(); } - auto xml() { - struct XML_ { - auto keys_seq() { - /+ contains .seg & .scroll sequences +/ - return _document_section_keys_sequenced; - } - string[] segnames() { - return _doc_html_segnames; - } - string[] segnames_lv_0_to_4() { - return _doc_epub_segnames_0_4; + auto output_path() { + return _manifest.output.path; + } + auto srcs() { + struct SRC_ { + auto file_insert_list() { + return _header_body_insertfilelist_imagelist[headBody.insert_file_list]; } - auto tag_associations() { - return _doc_tag_assoc; + auto image_list() { + return _doc_has_struct.imagelist; } } - return XML_(); - } - auto output_path() { - return _manifest.output.path; + return SRC_(); } } auto doc_matters = DocumentMatters(); diff --git a/src/doc_reform/meta/metadoc_from_src.d b/src/doc_reform/meta/metadoc_from_src.d index 3d6b441..6a10534 100644 --- a/src/doc_reform/meta/metadoc_from_src.d +++ b/src/doc_reform/meta/metadoc_from_src.d @@ -347,6 +347,18 @@ template DocReformDocAbstraction() { "glossary" : 0, "blurb" : 0, ]; + uint[string] dochas = [ + "inline_links" : 0, + "inline_notes" : 0, + "inline_notes_star" : 0, + "codeblock" : 0, + "table" : 0, + "block" : 0, + "group" : 0, + "poem" : 0, + "quote" : 0, + "images" : 0, + ]; auto obj_type_status = flags_type_init; string[string] object_number_poem = [ "start" : "", @@ -807,7 +819,7 @@ template DocReformDocAbstraction() { processing.remove("verse"); object_number_poem["start"] = obj_cite_digits.object_number.to!string; } - line.flow_txt_block_start(obj_type_status, object_number_poem); + line.flow_txt_block_start(obj_type_status, dochas, object_number_poem); continue; } else if (!line.empty) { /+ line not empty +/ /+ non blocks (headings, paragraphs) & closed blocks +/ @@ -1753,7 +1765,7 @@ template DocReformDocAbstraction() { } return images_; } - string[] segnames_lv0_to_4; + string[] segnames_0_to_4; auto _image_dimensions(O,M)(O obj, M manifest_matter) { if (obj.has.image_without_dimensions) { import std.math; @@ -1819,7 +1831,7 @@ template DocReformDocAbstraction() { writeln(obj.text); } if (obj.metainfo.heading_lev_markup <= 4) { - segnames_lv0_to_4 ~= obj.tags.segment_anchor_tag_epub; + segnames_0_to_4 ~= obj.tags.segment_anchor_tag_epub; } if (obj.metainfo.heading_lev_markup == 0) { /+ TODO second hit (of two) with same assertion failure, check, fix and reinstate @@ -1851,7 +1863,7 @@ template DocReformDocAbstraction() { foreach (ref obj; the_table_of_contents_section) { if (obj.metainfo.is_a == "heading") { if (obj.metainfo.heading_lev_markup <= 4) { - segnames_lv0_to_4 ~= obj.tags.segment_anchor_tag_epub; + segnames_0_to_4 ~= obj.tags.segment_anchor_tag_epub; if (obj.metainfo.heading_lev_markup == 4) { obj.tags.segname_next = segnames["html"][obj.ptr.html_segnames + 1]; assert(obj.tags.anchor_tag_html == segnames["html"][obj.ptr.html_segnames], @@ -1891,7 +1903,7 @@ template DocReformDocAbstraction() { writeln(obj.text); } if (obj.metainfo.heading_lev_markup <= 4) { - segnames_lv0_to_4 ~= obj.tags.segment_anchor_tag_epub; + segnames_0_to_4 ~= obj.tags.segment_anchor_tag_epub; if (obj.metainfo.heading_lev_markup == 4) { obj.tags.lev4_subtoc = lev4_subtoc[obj.tags.anchor_tag_html]; obj.tags.segname_prev = segnames["html"][obj.ptr.html_segnames - 1]; @@ -1920,7 +1932,7 @@ template DocReformDocAbstraction() { obj = _links(obj); } } - auto images=uniq(_images.sort()); + auto image_list = (_images.sort()).uniq; /+ optional only one 1~ level +/ if (the_endnotes_section.length > 1) { dom_structure_markedup_tags_status_buffer = dom_structure_markedup_tags_status.dup; @@ -1936,7 +1948,7 @@ template DocReformDocAbstraction() { obj.metainfo.ocn = obj_cite_digits.object_number; obj.metainfo.identifier = obj_cite_digits.identifier; if (obj.metainfo.heading_lev_markup <= 4) { - segnames_lv0_to_4 ~= obj.tags.segment_anchor_tag_epub; + segnames_0_to_4 ~= obj.tags.segment_anchor_tag_epub; if (obj.metainfo.heading_lev_markup == 4) { obj.tags.segname_prev = segnames["html"][obj.ptr.html_segnames - 1]; if (segnames["html"].length > obj.ptr.html_segnames + 1) { @@ -1972,7 +1984,7 @@ template DocReformDocAbstraction() { obj.metainfo.ocn = obj_cite_digits.object_number; obj.metainfo.identifier = obj_cite_digits.identifier; if (obj.metainfo.heading_lev_markup <= 4) { - segnames_lv0_to_4 ~= obj.tags.segment_anchor_tag_epub; + segnames_0_to_4 ~= obj.tags.segment_anchor_tag_epub; if (obj.metainfo.heading_lev_markup == 4) { obj.tags.segname_prev = segnames["html"][obj.ptr.html_segnames - 1]; if (segnames["html"].length > obj.ptr.html_segnames + 1) { @@ -2012,7 +2024,7 @@ template DocReformDocAbstraction() { obj.metainfo.ocn = obj_cite_digits.object_number; obj.metainfo.identifier = obj_cite_digits.identifier; if (obj.metainfo.heading_lev_markup <= 4) { - segnames_lv0_to_4 ~= obj.tags.segment_anchor_tag_epub; + segnames_0_to_4 ~= obj.tags.segment_anchor_tag_epub; if (obj.metainfo.heading_lev_markup == 4) { obj.tags.segname_prev = segnames["html"][obj.ptr.html_segnames - 1]; if (segnames["html"].length > obj.ptr.html_segnames + 1) { @@ -2053,7 +2065,7 @@ template DocReformDocAbstraction() { debug(dom) { } if (obj.metainfo.heading_lev_markup <= 4) { - segnames_lv0_to_4 ~= obj.tags.segment_anchor_tag_epub; + segnames_0_to_4 ~= obj.tags.segment_anchor_tag_epub; } obj_cite_digits = ocn_emit(OCNstatus.on); obj.metainfo.ocn = obj_cite_digits.object_number; @@ -2104,7 +2116,7 @@ template DocReformDocAbstraction() { obj.metainfo.ocn = obj_cite_digits.object_number; obj.metainfo.identifier = obj_cite_digits.identifier; if (obj.metainfo.heading_lev_markup <= 4) { - segnames_lv0_to_4 ~= obj.tags.segment_anchor_tag_epub; + segnames_0_to_4 ~= obj.tags.segment_anchor_tag_epub; if (obj.metainfo.heading_lev_markup == 4) { obj.tags.segname_prev = segnames["html"][obj.ptr.html_segnames - 1]; if (segnames["html"].length > obj.ptr.html_segnames + 1) { @@ -2306,11 +2318,10 @@ template DocReformDocAbstraction() { document_section_keys_sequenced["scroll"] ~= "tail"; document_section_keys_sequenced["seg"] ~= "tail"; } - auto sequenced_document_keys = docSectKeysSeq!()(document_section_keys_sequenced); - auto segnames_lv4 = segnames["html"].dup; + auto segnames_4 = segnames["html"].dup; auto segnames_lv1_to_4 = segnames["epub"].dup; debug(segnames) { - writeln("segnames_lv4: ", segnames_lv4); + writeln("segnames_lv4: ", segnames_4); writeln("segnames_lv1_to_4: ", segnames_lv1_to_4); } destroy(the_document_head_section); @@ -2335,13 +2346,59 @@ template DocReformDocAbstraction() { 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,]; + auto doc_has() { + struct DocHas_ { + uint inline_links() { + return dochas["inline_links"]; + } + uint inline_notes_reg() { + return dochas["inline_notes"]; + } + uint inline_notes_star() { + return dochas["inline_notes_star"]; + } + uint codeblocks() { + return dochas["codeblock"]; + } + uint tables() { + return dochas["table"]; + } + uint blocks() { + return dochas["block"]; + } + uint groups() { + return dochas["group"]; + } + uint poems() { + return dochas["poem"]; + } + uint quotes() { + return dochas["quote"]; + } + ulong images() { // TODO not ideal rethink + return (image_list.to!string.strip("[","]").split(",").length); + } + auto imagelist() { + return image_list; + } + auto keys_seq() { + return docSectKeysSeq!()(document_section_keys_sequenced); + } + string[] segnames_lv4() { + return segnames_4; + } + string[] segnames_lv_0_to_4() { + return segnames_0_to_4; + } + string[string][string] tag_associations() { + return tag_assoc; + } + } + return DocHas_(); + } auto t = tuple( document_the, - sequenced_document_keys, - segnames_lv4, - segnames_lv0_to_4, - tag_assoc, - images, + doc_has, ); return t; /+ post loop markup document/text ↑ +/ @@ -2484,9 +2541,10 @@ template DocReformDocAbstraction() { return line; } void flow_txt_block_start(L,T,N)( - L line, - return ref T obj_type_status, - return ref N object_number_poem + L line, + return ref T obj_type_status, + return ref uint[string] dochas, + return ref N object_number_poem ) { debug(asserts) { static assert(is(typeof(line) == char[])); @@ -2495,6 +2553,7 @@ template DocReformDocAbstraction() { } static auto rgx = Rgx(); if (auto m = line.matchFirst(rgx.block_curly_code_open)) { + dochas["codeblock"]++; an_object["lang"] = ""; an_object["attrib"] = (m["attrib"]) ? m["attrib"].to!string : ""; an_object["syntax"] = (m["syntax"]) ? m["syntax"].to!string : ""; @@ -2508,6 +2567,7 @@ template DocReformDocAbstraction() { obj_type_status["code"] = TriState.on; obj_type_status["curly_code"] = TriState.on; } else if (auto m = line.matchFirst(rgx.block_curly_poem_open)) { + dochas["poem"]++; an_object["syntax"] = ""; an_object["attrib"] = (m["attrib"]) ? m["attrib"].to!string : ""; an_object["lang"] = (m["lang"]) ? m["lang"].to!string : ""; @@ -2523,6 +2583,7 @@ template DocReformDocAbstraction() { obj_type_status["poem"] = TriState.on; obj_type_status["curly_poem"] = TriState.on; } else if (auto m = line.matchFirst(rgx.block_curly_group_open)) { + dochas["group"]++; an_object["syntax"] = ""; an_object["attrib"] = (m["attrib"]) ? m["attrib"].to!string : ""; an_object["lang"] = (m["lang"]) ? m["lang"].to!string : ""; @@ -2536,6 +2597,7 @@ template DocReformDocAbstraction() { obj_type_status["group"] = TriState.on; obj_type_status["curly_group"] = TriState.on; } else if (auto m = line.matchFirst(rgx.block_curly_block_open)) { + dochas["block"]++; an_object["syntax"] = ""; an_object["attrib"] = (m["attrib"]) ? m["attrib"].to!string : ""; an_object["lang"] = (m["lang"]) ? m["lang"].to!string : ""; @@ -2549,6 +2611,7 @@ template DocReformDocAbstraction() { obj_type_status["block"] = TriState.on; obj_type_status["curly_block"] = TriState.on; } else if (auto m = line.matchFirst(rgx.block_curly_quote_open)) { + dochas["quote"]++; an_object["syntax"] = ""; an_object["attrib"] = m["attrib"].to!string; an_object["lang"] = m["lang"].to!string; @@ -2568,18 +2631,21 @@ template DocReformDocAbstraction() { line ); } + dochas["table"] ++; an_object["table_head"] = m["attrib"].to!string; an_object["block_type"] = "curly"; obj_type_status["blocks"] = TriState.on; obj_type_status["table"] = TriState.on; obj_type_status["curly_table"] = TriState.on; } else if (auto m = line.matchFirst(rgx.block_curly_table_special_markup)) { /+ table: special table block markup syntax! +/ + dochas["table"]++; an_object["table_head"] = m["attrib"].to!string; an_object["block_type"] = "special"; obj_type_status["blocks"] = TriState.on; obj_type_status["table"] = TriState.on; obj_type_status["curly_table_special_markup"] = TriState.on; } else if (auto m = line.matchFirst(rgx.block_tic_code_open)) { + dochas["codeblock"]++; an_object["lang"] = ""; an_object["attrib"] = (m["attrib"]) ? m["attrib"].to!string : ""; an_object["syntax"] = (m["syntax"]) ? m["syntax"].to!string : ""; @@ -2593,6 +2659,7 @@ template DocReformDocAbstraction() { obj_type_status["code"] = TriState.on; obj_type_status["tic_code"] = TriState.on; } else if (auto m = line.matchFirst(rgx.block_tic_poem_open)) { + dochas["poem"]++; an_object["syntax"] = ""; an_object["attrib"] = (m["attrib"]) ? m["attrib"].to!string : ""; an_object["lang"] = (m["lang"]) ? m["lang"].to!string : ""; @@ -2608,6 +2675,7 @@ template DocReformDocAbstraction() { obj_type_status["poem"] = TriState.on; obj_type_status["tic_poem"] = TriState.on; } else if (auto m = line.matchFirst(rgx.block_tic_group_open)) { + dochas["group"]++; an_object["syntax"] = ""; an_object["attrib"] = (m["attrib"]) ? m["attrib"].to!string : ""; an_object["lang"] = (m["lang"]) ? m["lang"].to!string : ""; @@ -2621,6 +2689,7 @@ template DocReformDocAbstraction() { obj_type_status["group"] = TriState.on; obj_type_status["tic_group"] = TriState.on; } else if (auto m = line.matchFirst(rgx.block_tic_block_open)) { + dochas["block"]++; an_object["syntax"] = ""; an_object["attrib"] = (m["attrib"]) ? m["attrib"].to!string : ""; an_object["lang"] = (m["lang"]) ? m["lang"].to!string : ""; @@ -2634,6 +2703,7 @@ template DocReformDocAbstraction() { obj_type_status["block"] = TriState.on; obj_type_status["tic_block"] = TriState.on; } else if (auto m = line.matchFirst(rgx.block_tic_quote_open)) { + dochas["quote"]++; an_object["syntax"] = ""; an_object["attrib"] = m["attrib"].to!string; an_object["lang"] = m["lang"].to!string; @@ -2653,6 +2723,7 @@ template DocReformDocAbstraction() { line ); } + dochas["table"] ++; an_object["table_head"] = m["attrib"].to!string; an_object["block_type"] = "tic"; obj_type_status["blocks"] = TriState.on; @@ -6341,13 +6412,13 @@ template DocReformDocAbstraction() { template docSectKeysSeq() { auto docSectKeysSeq(string[][string] document_section_keys_sequenced) { struct doc_sect_keys_seq { - auto scroll() { + string[] scroll() { return document_section_keys_sequenced["scroll"]; } - auto seg() { + string[] seg() { return document_section_keys_sequenced["seg"]; } - auto sql() { + string[] sql() { return document_section_keys_sequenced["sql"]; } } diff --git a/src/doc_reform/meta/metadoc_summary.d b/src/doc_reform/meta/metadoc_summary.d index e44a12c..30f4a83 100644 --- a/src/doc_reform/meta/metadoc_summary.d +++ b/src/doc_reform/meta/metadoc_summary.d @@ -26,7 +26,7 @@ template DocReformAbstractionSummary() { "last_object_number_body" : "0", "last_object_number_book_index" : "0", ]; - foreach (k; doc_matters.xml.keys_seq.seg) { + foreach (k; doc_matters.has.keys_seq.seg) { foreach (obj; doc_abstraction[k]) { if (obj.metainfo.is_of_part != "empty") { if (!empty(obj.metainfo.object_number)) { @@ -52,48 +52,58 @@ template DocReformAbstractionSummary() { ? char_repeat_number : min_repeat_number; writefln( - "%s\n\"%s\", %s\n%s\n%s\n%30-s%10-d\n%30-s%10-d\n%30-s%10-d\n%30-s%10-d\n%30-s%10-d\n%30-s%10-d\n%30-s%10-d\n%30-s%10-d\n%30-s%10-d\n%30-s%10-d\n%30-s%10-d\n(%s: %s)\n%s", + "%s\n\"%s\", %s\n%s\n%s\n%30-s%10-d\n%30-s%10-d\n%30-s%10-d\n%30-s%10-d\n%30-s%10-d\n%30-s%10-d\n%30-s%10-d\n%30-s%10-d\n%30-s%10-d\n%30-s%10-d\n%30-s%10-d\n%30-s%10-d\n%30-s%10-d\n%30-s%10-d\n%30-s%10-d\n%30-s%10-d\n%30-s%10-d\n%s", markup.repeat_character_by_number_provided("-", char_repeat_number), doc_matters.conf_make_meta.meta.title_full, doc_matters.conf_make_meta.meta.creator_author, doc_matters.src.filename, markup.repeat_character_by_number_provided("-", char_repeat_number), - "length toc arr:", + "- toc arr length:", to!int(doc_abstraction["toc"].length), - "length doc_abstraction arr:", + "- doc_abstraction arr length:", to!int(doc_abstraction["body"].length), - "last doc body ocn:", + " doc body last obj on.#:", to!int(check["last_object_number_body"]), - "last object_number:", - to!int(check["last_object_number"]), - "length endnotes:", // subtract headings + " - number of tables:", + doc_matters.has.tables, + " - number of codeblocks:", + doc_matters.has.codeblocks, + " - number of poems:", + doc_matters.has.poems, + " - number of blocks:", + doc_matters.has.blocks, + " - number of groups:", + doc_matters.has.groups, + " - number of images:", + doc_matters.has.images, + "- endnotes length:", // subtract headings (doc_abstraction["endnotes"].length > 2) ? (to!int(doc_abstraction["endnotes"].length - 2)) : 0, - "length glossary:", + "- glossary length:", (doc_abstraction["glossary"].length > 1) ? (to!int(doc_abstraction["glossary"].length)) : 0, - "length biblio:", + "- biblio length:", (doc_abstraction["bibliography"].length > 1) ? (to!int(doc_abstraction["bibliography"].length)) : 0, - "length bookindex:", + "- bookindex length:", (doc_abstraction["bookindex"].length > 1) ? (to!int(doc_abstraction["bookindex"].length)) : 0, - " last book idx ocn:", + " book idx last obj on.#:", to!int(check["last_object_number_book_index"]), - "length blurb:", + "- blurb length:", (doc_abstraction["blurb"].length > 1) ? (to!int(doc_abstraction["blurb"].length)) : 0, + "* last obj on.#:", + to!int(check["last_object_number"]), "number of segments:", - (doc_matters.xml.segnames.length > 1) - ? (to!int(doc_matters.xml.segnames.length)) + (doc_matters.has.segnames_lv4.length > 1) + ? (to!int(doc_matters.has.segnames_lv4.length)) : 0, - __FILE__, - __LINE__, markup.repeat_character_by_number_provided("-", min_repeat_number), ); } diff --git a/src/doc_reform/meta/object_setter.d b/src/doc_reform/meta/object_setter.d index dac10da..264d439 100644 --- a/src/doc_reform/meta/object_setter.d +++ b/src/doc_reform/meta/object_setter.d @@ -86,10 +86,11 @@ template ObjectSetter() { bool bullet = false; string language = ""; // not implemented, consider } - struct DocObj_Has_ { // has + struct DocObj_Has_ { // doc object has bool inline_links = false; bool inline_notes_reg = false; bool inline_notes_star = false; + bool images = false; bool image_without_dimensions = false; } struct DocObj_Table_ { diff --git a/src/doc_reform/output/epub3.d b/src/doc_reform/output/epub3.d index a49bb5d..cdfd2a6 100644 --- a/src/doc_reform/output/epub3.d +++ b/src/doc_reform/output/epub3.d @@ -103,7 +103,7 @@ template outputEPub3() { content ~= " " ~ "</guide>" ~ "\n "; content ~= "" ~ "</package>"; debug(epubmanifest) { - foreach (part; doc_matters.xml.keys_seq.seg) { // TODO + foreach (part; doc_matters.has.keys_seq.seg) { // TODO foreach (obj; doc_abstraction[part]) { if (obj.metainfo.is_a == "heading") { if (obj.metainfo.heading_lev_markup == 4) { @@ -145,7 +145,7 @@ template outputEPub3() { <nav epub:type=\"toc\" id=\"toc\">\n", doc_matters.conf_make_meta.meta.title_full, ); - foreach (sect; doc_matters.xml.keys_seq.seg) { + foreach (sect; doc_matters.has.keys_seq.seg) { foreach (obj; doc_abstraction[sect]) { if (obj.metainfo.is_a == "heading") { string _txt = obj.text.replaceAll(rgx.inline_notes_al_gen, "").strip; @@ -242,7 +242,7 @@ template outputEPub3() { (doc_matters.conf_make_meta.meta.creator_author.empty) ? "" : doc_matters.conf_make_meta.meta.creator_author, // author ); - foreach (sect; doc_matters.xml.keys_seq.seg) { + foreach (sect; doc_matters.has.keys_seq.seg) { foreach (obj; doc_abstraction[sect]) { if (obj.metainfo.is_a == "heading") { string _txt = obj.text.replaceAll(rgx.inline_notes_al_gen, "").strip; @@ -322,8 +322,7 @@ template outputEPub3() { string[] doc_parts; } auto epubWrite = writeOut(); - // writeln(doc_matters.xml.keys_seq.seg); - foreach (part; doc_matters.xml.keys_seq.seg) { + foreach (part; doc_matters.has.keys_seq.seg) { foreach (obj; doc_abstraction[part]) { string _txt = xhtml_format.special_characters(obj); if (obj.metainfo.is_a == "heading") { @@ -659,7 +658,7 @@ template outputEPub3() { } } { /+ OEBPS/[segments].xhtml (the document contents) +/ - foreach (seg_filename; doc_matters.xml.segnames_lv_0_to_4) { + foreach (seg_filename; doc_matters.has.segnames_lv_0_to_4) { string fn = pth_epub3.fn_oebps_content_xhtml(doc_matters.src.filename, seg_filename); auto zip_arc_member_file = new ArchiveMember(); zip_arc_member_file.name = fn; diff --git a/src/doc_reform/output/html.d b/src/doc_reform/output/html.d index 45b95ce..c9032e5 100644 --- a/src/doc_reform/output/html.d +++ b/src/doc_reform/output/html.d @@ -25,7 +25,7 @@ template outputHTML() { string suffix = ".html"; string previous_part = ""; string delimit = ""; - foreach (part; doc_matters.xml.keys_seq.scroll) { + foreach (part; doc_matters.has.keys_seq.scroll) { foreach (obj; doc_abstraction[part]) { delimit = xhtml_format.div_delimit(part, previous_part); string _txt = xhtml_format.special_characters(obj); @@ -222,7 +222,7 @@ template outputHTML() { string suffix = ".html"; string previous_part = ""; string delimit = ""; - foreach (part; doc_matters.xml.keys_seq.seg) { + foreach (part; doc_matters.has.keys_seq.seg) { foreach (obj; doc_abstraction[part]) { delimit = xhtml_format.div_delimit(part, previous_part); string _txt = xhtml_format.special_characters(obj); @@ -476,7 +476,7 @@ template outputHTML() { if (!exists(pth_html.seg(doc_matters.src.filename))) { pth_html.seg(doc_matters.src.filename).mkdirRecurse; } - foreach (seg_filename; doc_matters.xml.segnames) { + foreach (seg_filename; doc_matters.has.segnames_lv4) { auto f = File(pth_html.fn_seg(doc_matters.src.filename, seg_filename), "w"); foreach (docseg; doc_html[seg_filename]) { f.writeln(docseg); diff --git a/src/doc_reform/output/sqlite.d b/src/doc_reform/output/sqlite.d index 0be198b..832e2e7 100644 --- a/src/doc_reform/output/sqlite.d +++ b/src/doc_reform/output/sqlite.d @@ -299,8 +299,8 @@ template SQLiteFormatAndLoadObject() { auto pth_html = DocReformPathsHTML!()(doc_matters.output_path, doc_matters.src.language); if (_xml_type == "seg") { foreach (m; _txt.match(rgx.inline_link_hash)) { - if (m.captures[3] in doc_matters.xml.tag_associations) { - if (m.captures[3] == doc_matters.xml.tag_associations[(m.captures[3])]["seg_lv4"]) { + if (m.captures[3] in doc_matters.has.tag_associations) { + if (m.captures[3] == doc_matters.has.tag_associations[(m.captures[3])]["seg_lv4"]) { _txt = _txt.replaceFirst( rgx.inline_link_hash, "┥$1┝┤" @@ -315,7 +315,7 @@ template SQLiteFormatAndLoadObject() { "┥$1┝┤" ~ doc_matters.conf_make_meta.conf.webserv_url_doc_root ~ "/" - ~ doc_matters.xml.tag_associations[(m.captures[3])]["seg_lv4"] + ~ doc_matters.has.tag_associations[(m.captures[3])]["seg_lv4"] ~ ".html" ~ "#" ~ "$3" ~ "├" @@ -1212,7 +1212,7 @@ template SQLiteInsertDocObjectsLoop() { string[string] obj_txt; string doc_text; string[] _insert_doc_objects; - foreach (part; doc_matters.xml.keys_seq.sql) { + foreach (part; doc_matters.has.keys_seq.sql) { foreach (obj; doc_abstraction[part]) { switch (obj.metainfo.is_of_part) { case "frontmatter": assert(part == "head", part); diff --git a/src/doc_reform/output/xmls.d b/src/doc_reform/output/xmls.d index f27b0f4..90f4e7d 100644 --- a/src/doc_reform/output/xmls.d +++ b/src/doc_reform/output/xmls.d @@ -372,10 +372,10 @@ template outputXHTMLs() { if (_xml_type == "seg" || _xml_type == "epub") { seg_lvs = (_xml_type == "epub") ? "seg_lv1_to_4" : "seg_lv4"; foreach (m; _txt.match(rgx.inline_link_hash)) { - if (m.captures[3] in doc_matters.xml.tag_associations) { + if (m.captures[3] in doc_matters.has.tag_associations) { if ( m.captures[3] - == doc_matters.xml.tag_associations[(m.captures[3])][seg_lvs] + == doc_matters.has.tag_associations[(m.captures[3])][seg_lvs] ) { _txt = _txt.replaceFirst( rgx.inline_link_hash, @@ -385,7 +385,7 @@ template outputXHTMLs() { _txt = _txt.replaceFirst( rgx.inline_link_hash, "┥$1┝┤" - ~ doc_matters.xml.tag_associations[(m.captures[3])][seg_lvs] + ~ doc_matters.has.tag_associations[(m.captures[3])][seg_lvs] ~ _suffix ~ "#" ~ "$3" ~ "├" ); diff --git a/views/version.txt b/views/version.txt index c5b26e9..f812b6e 100644 --- a/views/version.txt +++ b/views/version.txt @@ -4,7 +4,7 @@ struct Version { int minor; int patch; } -enum _ver = Version(0, 6, 0); +enum _ver = Version(0, 7, 0); version (Posix) { version (DigitalMars) { } else version (LDC) { |