From c37eb0768635a42686ea986343ff95ae03f08c1d Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Tue, 30 Oct 2018 11:46:44 -0400 Subject: 0.3.0 internal links, anchor tags & segment associations --- org/default_misc.org | 28 +- org/default_paths.org | 79 +- org/default_regex.org | 4 +- org/doc_reform.org | 80 +- org/meta_abstraction.org | 1268 ++++++++++++++------------------ org/meta_debugs.org | 24 +- org/output_sqlite.org | 245 +++--- org/output_xmls.org | 375 ++++++---- src/doc_reform/doc_reform.d | 68 +- src/doc_reform/meta/defaults.d | 28 +- src/doc_reform/meta/doc_debugs.d | 20 +- src/doc_reform/meta/metadoc.d | 32 +- src/doc_reform/meta/metadoc_from_src.d | 1262 ++++++++++++++----------------- src/doc_reform/meta/metadoc_summary.d | 8 +- src/doc_reform/meta/object_setter.d | 6 +- src/doc_reform/meta/rgx.d | 4 +- src/doc_reform/output/defaults.d | 28 +- src/doc_reform/output/epub3.d | 204 +++-- src/doc_reform/output/html.d | 148 ++-- src/doc_reform/output/paths_output.d | 79 +- src/doc_reform/output/sqlite.d | 245 +++--- src/doc_reform/output/xmls.d | 23 +- views/version.txt | 2 +- 23 files changed, 2186 insertions(+), 2074 deletions(-) diff --git a/org/default_misc.org b/org/default_misc.org index 59e7320..336f5ab 100644 --- a/org/default_misc.org +++ b/org/default_misc.org @@ -227,20 +227,20 @@ template InternalMarkup() { auto lnk_o = "┥"; auto lnk_c = "┝"; auto url_o = "┤"; auto url_c = "├"; auto mark_internal_site_lnk = "¤"; - auto nbsp = "░"; - auto br_line = "┘"; - auto br_nl = "┙"; - auto br_paragraph = "┚"; - auto br_obj = "break_obj"; - auto br_page_line = "┼"; - auto br_page = "┿"; - auto br_page_new = "╂"; - auto tc_s = "┊"; - auto tc_o = "┏"; - auto tc_c = "┚"; - auto tc_p = "┆"; - auto mono = "■"; - auto img = "☼"; + auto nbsp = "░"; + auto br_line = "┘"; + auto br_nl = "┙"; + auto br_paragraph = "┚"; + auto br_obj = "break_obj"; + auto br_page_line = "┼"; + auto br_page = "┿"; + auto br_page_new = "╂"; + auto tc_s = "┊"; + auto tc_o = "┏"; + auto tc_c = "┚"; + auto tc_p = "┆"; + auto mono = "■"; + auto img = "☼"; static string indent_by_spaces_provided(int indent, string _indent_spaces ="░░") { _indent_spaces = replicate(_indent_spaces, indent); return _indent_spaces; diff --git a/org/default_paths.org b/org/default_paths.org index 29f084f..3031a00 100644 --- a/org/default_paths.org +++ b/org/default_paths.org @@ -1128,46 +1128,45 @@ template DocReformPathsEPUB() { string fn_oebps_css(string fn_src) { return asNormalizedPath(doc_oebps_css(fn_src).chainPath("epub.css")).array; } - debug(epub_output) { - string dbg_docdir(string fn_src) { - return base.chainPath(base_filename(fn_src)).array; - } - string dbg_docdir_oebps(string fn_src) { - return dbg_docdir(fn_src).chainPath("OEBPS").array; - } - string dbg_doc_meta_inf(string fn_src) { - return dbg_docdir(fn_src).chainPath("META-INF").array; - } - string dbg_doc_oebps(string fn_src) { - return dbg_docdir(fn_src).chainPath("OEBPS").array; - } - string dbg_doc_oebps_css(string fn_src) { - return dbg_doc_oebps(fn_src).chainPath("css").array; - } - string dbg_doc_oebps_image(string fn_src) { - return dbg_doc_oebps(fn_src).chainPath("image").array; - } - string dbg_fn_mimetypes(string fn_src) { - return dbg_docdir(fn_src).chainPath("mimetypes").array; - } - string dbg_fn_dmi_container_xml(string fn_src) { - return dbg_doc_meta_inf(fn_src).chainPath("container.xml").array; - } - string dbg_fn_oebps_toc_nav_xhtml(string fn_src) { - return dbg_docdir_oebps(fn_src).chainPath("toc_nav.xhtml").array; - } - string dbg_fn_oebps_toc_ncx(string fn_src) { - return dbg_docdir_oebps(fn_src).chainPath("toc.ncx").array; - } - string dbg_fn_oebps_content_opf(string fn_src) { - return dbg_docdir_oebps(fn_src).chainPath("content.opf").array; - } - string dbg_fn_oebps_content_xhtml(string fn_src, string seg_filename) { - return dbg_docdir_oebps(fn_src).chainPath(seg_filename ~ ".xhtml").array; - } - string dbg_fn_oebps_css(string fn_src) { - return dbg_doc_oebps_css(fn_src).chainPath("epub.css").array; - } + /+ debug +/ + string dbg_docdir(string fn_src) { + return base.chainPath(base_filename(fn_src)).array; + } + string dbg_docdir_oebps(string fn_src) { + return dbg_docdir(fn_src).chainPath("OEBPS").array; + } + string dbg_doc_meta_inf(string fn_src) { + return dbg_docdir(fn_src).chainPath("META-INF").array; + } + string dbg_doc_oebps(string fn_src) { + return dbg_docdir(fn_src).chainPath("OEBPS").array; + } + string dbg_doc_oebps_css(string fn_src) { + return dbg_doc_oebps(fn_src).chainPath("css").array; + } + string dbg_doc_oebps_image(string fn_src) { + return dbg_doc_oebps(fn_src).chainPath("image").array; + } + string dbg_fn_mimetypes(string fn_src) { + return dbg_docdir(fn_src).chainPath("mimetypes").array; + } + string dbg_fn_dmi_container_xml(string fn_src) { + return dbg_doc_meta_inf(fn_src).chainPath("container.xml").array; + } + string dbg_fn_oebps_toc_nav_xhtml(string fn_src) { + return dbg_docdir_oebps(fn_src).chainPath("toc_nav.xhtml").array; + } + string dbg_fn_oebps_toc_ncx(string fn_src) { + return dbg_docdir_oebps(fn_src).chainPath("toc.ncx").array; + } + string dbg_fn_oebps_content_opf(string fn_src) { + return dbg_docdir_oebps(fn_src).chainPath("content.opf").array; + } + string dbg_fn_oebps_content_xhtml(string fn_src, string seg_filename) { + return dbg_docdir_oebps(fn_src).chainPath(seg_filename ~ ".xhtml").array; + } + string dbg_fn_oebps_css(string fn_src) { + return dbg_doc_oebps_css(fn_src).chainPath("epub.css").array; } } return _PathsStruct(); diff --git a/org/default_regex.org b/org/default_regex.org index 910be04..da2ff4d 100644 --- a/org/default_regex.org +++ b/org/default_regex.org @@ -355,8 +355,8 @@ static biblio_abbreviations = ctRegex!(`^(au|ed|ti|lng /+ bookindex split +/ static bi_main_terms_split = ctRegex!(`\s*;\s*`); static bi_main_term_plus_rest_split = ctRegex!(`\s*:\s*`); -static bi_sub_terms_plus_object_number_offset_split = ctRegex!(`\s*\|\s*`); -static bi_term_and_object_numbers_match = ctRegex!(`^(.+?)\+(\d+)`); +static bi_sub_terms_plus_object_number_offset_split = ctRegex!(`\s*\|\s*`); +static bi_term_and_object_numbers_match = ctRegex!(`^(.+?)\+(\d+)`); #+END_SRC ** language codes :language:codes: diff --git a/org/doc_reform.org b/org/doc_reform.org index a04f650..f8dcc63 100644 --- a/org/doc_reform.org +++ b/org/doc_reform.org @@ -24,7 +24,7 @@ struct Version { int minor; int patch; } -enum ver = Version(0, 2, 1); +enum ver = Version(0, 3, 0); #+END_SRC ** compilation restrictions (supported compilers) @@ -666,11 +666,15 @@ _make_and_meta_struct = configParseTOMLreturnDocReformStruct!()(_make_and_meta_s #+NAME: doc_reform_do_selected #+BEGIN_SRC d if (!(_opt_action.skip_output)) { - debug(steps) { + if ((_opt_action.debug_do) + || (_opt_action.very_verbose) + ) { writeln("step0 commence → (without processing files)"); } outputHubOp!()(_env, _opt_action); - debug(steps) { + if ((_opt_action.debug_do) + || (_opt_action.very_verbose) + ) { writeln("- step0 complete"); } } @@ -684,9 +688,8 @@ if (!(_opt_action.skip_output)) { scope(success) { if (!(_opt_action.quiet)) { writefln( - "%s\n%s", - "~ document complete, ok ~", - "------------------------------------------------------------------", + "%s", + "-- ~ document complete, ok ~ ------------------------------------", ); } } @@ -715,7 +718,9 @@ enforce( #+NAME: doc_reform_each_file_do_abstraction #+BEGIN_SRC d -debug(steps) { +if ((_opt_action.debug_do) +|| (_opt_action.very_verbose) +) { writeln("--->\nstepX commence → (document abstraction)"); } auto t = DocReformAbstraction!()(_env, _opt_action, manifest); @@ -723,7 +728,9 @@ static assert(!isTypeTuple!(t)); static assert(t.length==2); auto doc_abstraction = t[dAM.abstraction]; auto doc_matters = t[dAM.matters]; -debug(steps) { +if ((doc_matters.opt.action.debug_do) +|| (doc_matters.opt.action.very_verbose) +) { writeln("- stepX complete"); } #+END_SRC @@ -745,9 +752,7 @@ if (doc_matters.opt.action.verbose) { #+NAME: doc_reform_each_file_do_debugs_checkdoc #+BEGIN_SRC d /+ ↓ debugs +/ -if ((doc_matters.opt.action.debug_do) -|| (doc_matters.opt.action.verbose) -) { +if (doc_matters.opt.action.debug_do) { DocReformDebugs!()(doc_abstraction, doc_matters); } #+END_SRC @@ -759,11 +764,15 @@ if ((doc_matters.opt.action.debug_do) #+BEGIN_SRC d /+ ↓ output hub +/ if (!(doc_matters.opt.action.skip_output)) { - debug(steps) { + if ((_opt_action.debug_do) + || (_opt_action.very_verbose) + ) { writeln("step5 commence → (process outputs)"); } outputHub!()(doc_abstraction, doc_matters); - debug(steps) { + if ((_opt_action.debug_do) + || (_opt_action.very_verbose) + ) { writeln("- step5 complete"); } } @@ -776,8 +785,9 @@ if (!(doc_matters.opt.action.skip_output)) { scope(exit) { if (!(_opt_action.quiet)) { writefln( - "processed file: %s", - manifest.src.filename + "processed file: %s (%s)", + manifest.src.filename, + manifest.src.language ); } destroy(manifest); @@ -851,7 +861,9 @@ if build source pod requested all information needed to build it available at th #+BEGIN_SRC d /+ ↓ read file (filename with path) +/ /+ ↓ file tuple of header and content +/ -debug(steps) { +if ((_opt_action.debug_do) +|| (_opt_action.very_verbose) +) { writeln("step1 commence → (get document header & body & insert file list & if needed image list)" ); } @@ -859,7 +871,9 @@ auto _header_body_insertfilelist_imagelist = DocReformRawMarkupContent!()(_opt_action, _manifest.src.path_and_fn); static assert(!isTypeTuple!(_header_body_insertfilelist_imagelist)); static assert(_header_body_insertfilelist_imagelist.length==4); -debug(steps) { +if ((_opt_action.debug_do) +|| (_opt_action.very_verbose) +) { writeln("- step1 complete"); } debug(header_and_body) { @@ -885,7 +899,9 @@ debug(header_and_body) { #+NAME: doc_reform_each_file_do_split_sisu_markup_file_header_into_make_and_meta_structs #+BEGIN_SRC d /+ ↓ split header into make and meta +/ -debug(steps) { +if ((_opt_action.debug_do) +|| (_opt_action.very_verbose) +) { writeln("step2 commence → (read document header - toml, return struct)"); } _make_and_meta_struct = @@ -893,7 +909,9 @@ docHeaderMakeAndMetaTupTomlExtractAndConvertToStruct!()( _make_and_meta_struct, _header_body_insertfilelist_imagelist[headBody.header] ); -debug(steps) { +if ((_opt_action.debug_do) +|| (_opt_action.very_verbose) +) { writeln("- step2 complete"); } #+END_SRC @@ -915,7 +933,9 @@ debug(steps) { #+NAME: doc_reform_each_file_do_document_abstraction #+BEGIN_SRC d /+ ↓ document abstraction: process document, return abstraction as tuple +/ -debug(steps) { +if ((_opt_action.debug_do) +|| (_opt_action.very_verbose) +) { writeln("step3 commence → (document abstraction (da); da keys; segnames; doc_matters)"); } auto da = DocReformDocAbstraction!()( @@ -937,7 +957,9 @@ debug(segnames) { } auto _doc_tag_assoc = da[docAbst.tag_assoc]; auto _images = da[docAbst.images]; -debug(steps) { +if ((_opt_action.debug_do) +|| (_opt_action.very_verbose) +) { writeln("- step3 complete"); } #+END_SRC @@ -949,7 +971,9 @@ debug(steps) { #+NAME: doc_reform_each_file_do_document_matters #+BEGIN_SRC d -debug(steps) { +if ((_opt_action.debug_do) +|| (_opt_action.very_verbose) +) { writeln("step4 commence → (doc_matters)"); } struct DocumentMatters { @@ -1030,7 +1054,9 @@ struct DocumentMatters { } } auto doc_matters = DocumentMatters(); -debug(steps) { +if ((_opt_action.debug_do) +|| (_opt_action.very_verbose) +) { writeln("- step4 complete"); } #+END_SRC @@ -1103,7 +1129,7 @@ foreach (k; doc_matters.xml.keys_seq.seg) { check["last_object_number"] = obj.metainfo.object_number; } } - if (k == "bookindex_seg") { + if (k == "bookindex") { if (obj.metainfo.object_number_type == 2) { check["last_object_number_book_index"] = obj.metainfo.object_number_book_index; } @@ -1131,7 +1157,7 @@ writefln( doc_matters.src.filename, markup.repeat_character_by_number_provided("-", char_repeat_number), "length toc arr:", - to!int(doc_abstraction["toc_seg"].length), + to!int(doc_abstraction["toc"].length), "length doc_abstraction arr:", to!int(doc_abstraction["body"].length), "last doc body ocn:", @@ -1151,8 +1177,8 @@ writefln( ? (to!int(doc_abstraction["bibliography"].length)) : 0, "length bookindex:", - (doc_abstraction["bookindex_seg"].length > 1) - ? (to!int(doc_abstraction["bookindex_seg"].length)) + (doc_abstraction["bookindex"].length > 1) + ? (to!int(doc_abstraction["bookindex"].length)) : 0, " last book idx ocn:", to!int(check["last_object_number_book_index"]), diff --git a/org/meta_abstraction.org b/org/meta_abstraction.org index ee94ebc..4d2d85b 100644 --- a/org/meta_abstraction.org +++ b/org/meta_abstraction.org @@ -178,7 +178,7 @@ mixin DocReformRgxInit; #+name: abs_top_init_struct #+BEGIN_SRC d /+ initialize +/ -ObjGenericComposite[][string] the_table_of_contents_section; +ObjGenericComposite[] the_table_of_contents_section; ObjGenericComposite[] the_document_head_section, the_document_body_section, the_bibliography_section, the_glossary_section, the_blurb_section; ObjGenericComposite[] the_dom_tail_section; string[string] an_object, processing; @@ -186,11 +186,10 @@ string an_object_key; string[] anchor_tags; string anchor_tag; string anchor_tag_; -string[string] segment_anchor_tag_that_object_belongs_to; +string[string] tag_in_seg; string lev_anchor_tag; -string[][string] tag_assoc_html; -string[][string] tag_assoc_lv0_to_lv3_html; -string[][string] tag_assoc_lv0_to_lv3_epub; +string[string][string] tag_assoc; +string[] lv0_to_3_tags; /+ enum +/ enum State { off, on } enum TriState { off, on, closing } @@ -424,16 +423,21 @@ enum sObj { content, anchor_tag, notes_reg, notes_star, links, image_no_dimensio #+name: abs_inline_para_tag_associations #+BEGIN_SRC d -auto inline_para_link_anchor(O,St,TA)(O an_object, St segment_anchor_tag_that_object_belongs_to, TA tag_assoc_html) { +auto inline_para_link_anchor(O,St,TA)( + O an_object, + St tag_in_seg, + TA tag_assoc +) { static auto rgx = Rgx(); if (auto m = an_object["substantive"].match(rgx.inline_link_anchor)) { - if (m.captures[1] !in tag_assoc_html) { - tag_assoc_html[(m.captures[1])] = [segment_anchor_tag_that_object_belongs_to["html"]]; + if (m.captures[1] !in tag_assoc) { + tag_assoc[(m.captures[1])]["seg_lv4"] = tag_in_seg["seg_lv4"]; + tag_assoc[(m.captures[1])]["seg_lv1_to_4"] = tag_in_seg["seg_lv1_to_4"]; } else { writeln("a tag named already exists, check text line\n ", an_object["substantive"]); } } - return tag_assoc_html; + return tag_assoc; } #+END_SRC @@ -534,8 +538,9 @@ comp_obj_heading_.text = "Table of Conte 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_html = "toc"; -comp_obj_heading_.tags.segment_anchor_tag_epub = comp_obj_heading_.tags.segment_anchor_tag_html; +comp_obj_heading_.tags.segment_anchor_tag_epub = "toc"; +comp_obj_heading_.tags.anchor_tag_html = comp_obj_heading_.tags.segment_anchor_tag_epub; +comp_obj_heading_.tags.in_segment_html = comp_obj_heading_.tags.anchor_tag_html; comp_obj_heading_.metainfo.heading_lev_markup = 4; comp_obj_heading_.metainfo.heading_lev_collapsed = 1; comp_obj_heading_.metainfo.parent_ocn = 1; @@ -544,18 +549,17 @@ comp_obj_heading_.ptr.html_segnames = html_segnames_p 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]; +tag_assoc[comp_obj_heading_.tags.anchor_tag_html]["seg_lv4"] = comp_obj_heading_.tags.in_segment_html; +tag_assoc[comp_obj_heading_.tags.segment_anchor_tag_epub]["seg_lv1_to_4"] = comp_obj_heading_.tags.segment_anchor_tag_epub; auto toc_head = comp_obj_heading_; html_segnames_ptr_cntr++; -the_table_of_contents_section = [ - "seg": [toc_head], - "scroll": [toc_head], -]; +the_table_of_contents_section = [toc_head]; static auto mkup = InlineMarkup(); static auto munge = ObjInlineMarkupMunge(); auto note_section = NotesSection(); auto bookindex_extract_hash = BookIndexNuggetHash(); string[][string] lev4_subtoc; -string[] html_segnames=["toc"]; +string[][string] segnames = ["html": ["toc"], "epub": ["toc"]]; int cnt1 = 1; int cnt2 = 1; int cnt3 = 1; #+END_SRC @@ -710,8 +714,9 @@ if there is a glossary section you need to: 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_html = "_part_glossary"; - comp_obj_heading_.tags.segment_anchor_tag_epub = comp_obj_heading_.tags.segment_anchor_tag_html; + comp_obj_heading_.tags.segment_anchor_tag_epub = "_part_glossary"; + comp_obj_heading_.tags.anchor_tag_html = comp_obj_heading_.tags.segment_anchor_tag_epub; + comp_obj_heading_.tags.in_segment_html = "glossary"; comp_obj_heading_.metainfo.heading_lev_markup = 1; comp_obj_heading_.metainfo.heading_lev_collapsed = 1; comp_obj_heading_.metainfo.parent_ocn = 1; @@ -719,6 +724,8 @@ if there is a glossary section you need to: 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_; + tag_assoc[comp_obj_heading_.tags.anchor_tag_html]["seg_lv4"] = comp_obj_heading_.tags.in_segment_html; + tag_assoc[comp_obj_heading_.tags.segment_anchor_tag_epub]["seg_lv1_to_4"] = comp_obj_heading_.tags.segment_anchor_tag_epub; comp_obj_heading_ = comp_obj_heading_.init; comp_obj_heading_.metainfo.is_of_part = "backmatter"; comp_obj_heading_.metainfo.is_of_section = "glossary"; @@ -728,8 +735,9 @@ if there is a glossary section you need to: 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_html = "glossary"; - comp_obj_heading_.tags.segment_anchor_tag_epub = comp_obj_heading_.tags.segment_anchor_tag_html; + comp_obj_heading_.tags.segment_anchor_tag_epub = "glossary"; + comp_obj_heading_.tags.anchor_tag_html = comp_obj_heading_.tags.segment_anchor_tag_epub; + comp_obj_heading_.tags.in_segment_html = comp_obj_heading_.tags.anchor_tag_html; comp_obj_heading_.metainfo.heading_lev_markup = 4; comp_obj_heading_.metainfo.heading_lev_collapsed = 2; comp_obj_heading_.metainfo.parent_ocn = 1; @@ -738,6 +746,8 @@ if there is a glossary section you need to: 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_; + tag_assoc[comp_obj_heading_.tags.anchor_tag_html]["seg_lv4"] = comp_obj_heading_.tags.in_segment_html; + tag_assoc[comp_obj_heading_.tags.segment_anchor_tag_epub]["seg_lv1_to_4"] = comp_obj_heading_.tags.segment_anchor_tag_epub; } else { _para_match_(line, an_object, an_object_key, indent, bullet, obj_type_status, line_occur); comp_obj_para = comp_obj_para.init; @@ -831,8 +841,9 @@ if there is a blurb section you need to: 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_html = "_part_blurb"; - comp_obj_heading_.tags.segment_anchor_tag_epub = comp_obj_heading_.tags.segment_anchor_tag_html; + comp_obj_heading_.tags.segment_anchor_tag_epub = "_part_blurb"; + comp_obj_heading_.tags.anchor_tag_html = comp_obj_heading_.tags.segment_anchor_tag_epub; + comp_obj_heading_.tags.in_segment_html = "blurb"; comp_obj_heading_.metainfo.heading_lev_markup = 1; comp_obj_heading_.metainfo.heading_lev_collapsed = 1; comp_obj_heading_.metainfo.parent_ocn = 1; @@ -840,6 +851,8 @@ if there is a blurb section you need to: 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_; + tag_assoc[comp_obj_heading_.tags.anchor_tag_html]["seg_lv4"] = comp_obj_heading_.tags.in_segment_html; + tag_assoc[comp_obj_heading_.tags.segment_anchor_tag_epub]["seg_lv1_to_4"] = comp_obj_heading_.tags.segment_anchor_tag_epub; comp_obj_heading_ = comp_obj_heading_.init; comp_obj_heading_.metainfo.is_of_part = "backmatter"; comp_obj_heading_.metainfo.is_of_section = "blurb"; @@ -849,8 +862,9 @@ if there is a blurb section you need to: 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_html = "blurb"; - comp_obj_heading_.tags.segment_anchor_tag_epub = comp_obj_heading_.tags.segment_anchor_tag_html; + comp_obj_heading_.tags.segment_anchor_tag_epub = "blurb"; + comp_obj_heading_.tags.anchor_tag_html = comp_obj_heading_.tags.segment_anchor_tag_epub; + comp_obj_heading_.tags.in_segment_html = comp_obj_heading_.tags.anchor_tag_html; comp_obj_heading_.metainfo.heading_lev_markup = 4; comp_obj_heading_.metainfo.heading_lev_collapsed = 2; comp_obj_heading_.metainfo.parent_ocn = 1; @@ -859,6 +873,8 @@ if there is a blurb section you need to: 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_; + tag_assoc[comp_obj_heading_.tags.anchor_tag_html]["seg_lv4"] = comp_obj_heading_.tags.in_segment_html; + tag_assoc[comp_obj_heading_.tags.segment_anchor_tag_epub]["seg_lv1_to_4"] = comp_obj_heading_.tags.segment_anchor_tag_epub; } else if (line.matchFirst(rgx.heading) && (opt_action.backmatter && opt_action.section_blurb)) { comp_obj_heading_ = comp_obj_heading_.init; @@ -870,13 +886,16 @@ if there is a blurb section you need to: 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_html = "blurb"; - comp_obj_heading_.tags.segment_anchor_tag_epub = comp_obj_heading_.tags.segment_anchor_tag_html; + comp_obj_heading_.tags.segment_anchor_tag_epub = "blurb"; + comp_obj_heading_.tags.anchor_tag_html = comp_obj_heading_.tags.segment_anchor_tag_epub; + comp_obj_heading_.tags.in_segment_html = comp_obj_heading_.tags.anchor_tag_html; comp_obj_heading_.metainfo.heading_lev_markup = an_object["lev_markup_number"].to!int; // make int, remove need to conv 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_; + tag_assoc[comp_obj_heading_.tags.anchor_tag_html]["seg_lv4"] = comp_obj_heading_.tags.in_segment_html; + tag_assoc[comp_obj_heading_.tags.segment_anchor_tag_epub]["seg_lv1_to_4"] = comp_obj_heading_.tags.segment_anchor_tag_epub; } else { _para_match_(line, an_object, an_object_key, indent, bullet, obj_type_status, line_occur); comp_obj_para = comp_obj_para.init; @@ -953,7 +972,7 @@ if there is a blurb section you need to: #+BEGIN_SRC d } else if (obj_type_status["poem"] == TriState.on) { /+ within block object: poem +/ - _poem_block_(line, an_object, obj_type_status, cntr, object_number_poem, conf_make_meta, segment_anchor_tag_that_object_belongs_to); + _poem_block_(line, an_object, obj_type_status, cntr, object_number_poem, conf_make_meta, tag_in_seg); continue; #+END_SRC @@ -1152,7 +1171,7 @@ _block_flag_line_empty_( obj_type_status, object_number_poem, conf_make_meta, - segment_anchor_tag_that_object_belongs_to, + tag_in_seg, ); #+END_SRC @@ -1176,6 +1195,11 @@ assert( #+name: abs_in_loop_body_not_block_obj_line_empty #+BEGIN_SRC d +if (_new_doc) { + tag_assoc = tag_assoc.init; + lv0_to_3_tags = lv0_to_3_tags.init; + tag_in_seg = tag_in_seg.init; +} if ((obj_type_status["heading"] == State.on) && (line_occur["heading"] > State.off)) { /+ heading object (current line empty) +/ @@ -1197,27 +1221,29 @@ if ((obj_type_status["heading"] == State.on) if ( an_object["lev_markup_number"].to!int == 4 && (!(anchor_tag.empty) - || (tag_assoc_lv0_to_lv3_html.length > 1)) + || (lv0_to_3_tags.length > 0)) ) { - segment_anchor_tag_that_object_belongs_to["html"] = anchor_tag; + tag_in_seg["seg_lv4"] = anchor_tag; + tag_in_seg["seg_lv1_to_4"] = anchor_tag; lev_anchor_tag = anchor_tag; - tag_assoc_html[anchor_tag] = [segment_anchor_tag_that_object_belongs_to["html"]]; - if (tag_assoc_lv0_to_lv3_html.length > 1) { /+ names used for html markup segments 1 to 4 (rather than epub which has separate segments for A to D) +/ - foreach (lv0_to_lv3_html_tag; tag_assoc_lv0_to_lv3_html) { - tag_assoc_html[lv0_to_lv3_html_tag[0]] = [segment_anchor_tag_that_object_belongs_to["html"]]; + tag_assoc[anchor_tag]["seg_lv4"] = tag_in_seg["seg_lv4"]; + tag_assoc[anchor_tag]["seg_lv1_to_4"] = tag_in_seg["seg_lv1_to_4"]; + if (lv0_to_3_tags.length > 0) { /+ names used for html markup segments 1 to 4 (rather than epub which has separate segments for A to D) +/ + foreach (lv0_to_lv3_html_tag; lv0_to_3_tags) { + tag_assoc[lv0_to_lv3_html_tag]["seg_lv4"] = anchor_tag; } } - segment_anchor_tag_that_object_belongs_to["html_uri"] = anchor_tag ~ ".fnSuffix"; anchor_tag_ = anchor_tag; - tag_assoc_lv0_to_lv3_html = tag_assoc_lv0_to_lv3_html.init; + lv0_to_3_tags = lv0_to_3_tags.init; } else if (an_object["lev_markup_number"].to!int > 4) { - segment_anchor_tag_that_object_belongs_to["html"] = anchor_tag_; + tag_in_seg["seg_lv4"] = anchor_tag_; + tag_in_seg["seg_lv1_to_4"] = anchor_tag_; lev_anchor_tag = anchor_tag; - tag_assoc_html[anchor_tag] = [segment_anchor_tag_that_object_belongs_to["html"]]; - segment_anchor_tag_that_object_belongs_to["html_uri"] = anchor_tag_ ~ ".fnSuffix#" ~ obj_cite_digits.on.to!string; + tag_assoc[anchor_tag]["seg_lv4"] = tag_in_seg["seg_lv4"]; + tag_assoc[anchor_tag]["seg_lv1_to_4"] = tag_in_seg["seg_lv1_to_4"]; } else if (an_object["lev_markup_number"].to!int < 4) { string segn; - switch (an_object["lev_markup_number"].to!int) { + switch (an_object["lev_markup_number"].to!int) { /+ names used for epub markup segments A to D +/ case 0: segn = "_the_title"; goto default; @@ -1226,50 +1252,51 @@ if ((obj_type_status["heading"] == State.on) ++cnt1; goto default; case 2: - segn = "_part_" ~ cnt1.to!string ~ "_" ~ cnt2.to!string; + segn = "_part_" ~ cnt1.to!string ~ "_" ~ cnt2.to!string; ++cnt2; goto default; case 3: - segn = "_part_" ~ cnt1.to!string ~ "_" ~ cnt2.to!string ~ "_" ~ cnt3.to!string; + segn = "_part_" ~ cnt1.to!string ~ "_" ~ cnt2.to!string ~ "_" ~ cnt3.to!string; ++cnt3; goto default; default: - segment_anchor_tag_that_object_belongs_to["html"] = segn; - segment_anchor_tag_that_object_belongs_to["html_uri"] = segn ~ ".fnSuffix"; - segment_anchor_tag_that_object_belongs_to["epub"] = segn; - segment_anchor_tag_that_object_belongs_to["epub_uri"] = segn ~ ".fnSuffix"; - tag_assoc_lv0_to_lv3_html[segn] = [""]; - tag_assoc_lv0_to_lv3_epub[segn] = ["segn"]; + lv0_to_3_tags ~= obj_cite_digits.on.to!string; + lv0_to_3_tags ~= segn; + tag_in_seg["seg_lv4"] = segn; // for html segname need following lv4 not yet known + tag_in_seg["seg_lv1_to_4"] = segn; break; } } an_object["bookindex_nugget"] = ("bookindex_nugget" in an_object) ? an_object["bookindex_nugget"] : ""; bookindex_unordered_hashes - = bookindex_extract_hash.bookindex_nugget_hash(an_object["bookindex_nugget"], obj_cite_digits, segment_anchor_tag_that_object_belongs_to); + = bookindex_extract_hash.bookindex_nugget_hash(an_object["bookindex_nugget"], obj_cite_digits, tag_in_seg); /+ (incrementally build toc) table of contents here! +/ _anchor_tag=obj_cite_digits.on.to!string; the_table_of_contents_section = obj_im.table_of_contents_gather_headings( an_object, conf_make_meta, - segment_anchor_tag_that_object_belongs_to, + tag_in_seg, _anchor_tag, lev4_subtoc, the_table_of_contents_section, ); if (an_object["lev_markup_number"] == "4") { - html_segnames ~= segment_anchor_tag_that_object_belongs_to["html"]; + segnames["html"] ~= tag_in_seg["seg_lv4"]; html_segnames_ptr = html_segnames_ptr_cntr; html_segnames_ptr_cntr++; } + if (an_object["lev_markup_number"].to!int <= 4) { + segnames["epub"] ~= tag_in_seg["seg_lv1_to_4"]; + } auto comp_obj_heading = node_construct.node_emitter_heading( - an_object["substantive"], // string - an_object["lev_markup_number"], // string - an_object["lev_collapsed_number"], // string - segment_anchor_tag_that_object_belongs_to, // string - lev_anchor_tag, // string - tag_assoc_html, + an_object["substantive"], + an_object["lev_markup_number"], + an_object["lev_collapsed_number"], + tag_in_seg, + lev_anchor_tag, + tag_assoc, obj_cite_digits, // OCNset cntr, // int heading_ptr, // int @@ -1283,7 +1310,8 @@ if ((obj_type_status["heading"] == State.on) ++heading_ptr; debug(segments) { writeln(an_object["lev_markup_number"]); - writeln(segment_anchor_tag_that_object_belongs_to["html"]); + writeln(tag_in_seg["seg_lv4"]); + writeln(tag_in_seg["seg_lv1_to_4"]); } the_document_body_section ~= comp_obj_heading; debug(objectrelated1) { // check @@ -1307,14 +1335,14 @@ if ((obj_type_status["heading"] == State.on) an_object["bookindex_nugget"] = ("bookindex_nugget" in an_object) ? an_object["bookindex_nugget"] : ""; bookindex_unordered_hashes - = bookindex_extract_hash.bookindex_nugget_hash(an_object["bookindex_nugget"], obj_cite_digits, segment_anchor_tag_that_object_belongs_to); + = bookindex_extract_hash.bookindex_nugget_hash(an_object["bookindex_nugget"], obj_cite_digits, tag_in_seg); an_object["is"] = "para"; auto comp_obj_heading = node_construct.node_location_emitter( content_non_header, - segment_anchor_tag_that_object_belongs_to, + tag_in_seg, lev_anchor_tag, - tag_assoc_html, + tag_assoc, obj_cite_digits, cntr, heading_ptr-1, @@ -1324,14 +1352,14 @@ if ((obj_type_status["heading"] == State.on) = obj_im.obj_inline_markup_and_anchor_tags_and_misc(an_object, an_object_key, conf_make_meta, false); an_object["substantive"] = substantive_obj_misc_tuple[sObj.content]; anchor_tag = substantive_obj_misc_tuple[sObj.anchor_tag]; - tag_assoc_html = inline_para_link_anchor(an_object, segment_anchor_tag_that_object_belongs_to, tag_assoc_html); comp_obj_para = comp_obj_para.init; comp_obj_para.metainfo.is_of_part = "body"; comp_obj_para.metainfo.is_of_section = "body"; comp_obj_para.metainfo.is_of_type = "para"; comp_obj_para.metainfo.is_a = "para"; comp_obj_para.text = an_object["substantive"].to!string.strip; - comp_obj_para.tags.segment_anchor_tag_is = segment_anchor_tag_that_object_belongs_to["html"]; + comp_obj_para.tags.html_segment_anchor_tag_is = tag_in_seg["seg_lv4"]; + comp_obj_para.tags.epub_segment_anchor_tag_is = tag_in_seg["seg_lv1_to_4"]; comp_obj_para.metainfo.ocn = obj_cite_digits.digit; comp_obj_para.metainfo.object_number_off = (obj_cite_digits.off==0) ? "" : obj_cite_digits.off.to!string; comp_obj_para.metainfo.o_n_book_index = obj_cite_digits.bkidx; @@ -1345,6 +1373,7 @@ if ((obj_type_status["heading"] == State.on) comp_obj_para.has.inline_links = substantive_obj_misc_tuple[sObj.links]; comp_obj_para.has.contains_image_without_dimensions = substantive_obj_misc_tuple[sObj.image_no_dimensions]; the_document_body_section ~= comp_obj_para; + tag_assoc = inline_para_link_anchor(an_object, tag_in_seg, tag_assoc); _common_reset_(line_occur, an_object, obj_type_status); indent=[ "hang_position" : 0, @@ -1386,7 +1415,7 @@ if (the_document_body_section.length > 0) { )) { note_section.gather_notes_for_endnote_section( the_document_body_section, - segment_anchor_tag_that_object_belongs_to, + tag_in_seg, (i).to!int, ); } @@ -1401,7 +1430,7 @@ if (the_document_body_section.length > 0) { previous_count=(the_document_body_section.length -1).to!int; note_section.gather_notes_for_endnote_section( the_document_body_section, - segment_anchor_tag_that_object_belongs_to, + tag_in_seg, (the_document_body_section.length-1).to!int, ); } @@ -1450,20 +1479,20 @@ debug(endnotes) { #+name: abs_post #+BEGIN_SRC d if (an_object["glossary_nugget"].length == 0) { - comp_obj_heading_ = comp_obj_heading_.init; - comp_obj_heading_.metainfo.is_of_part = "empty"; - comp_obj_heading_.metainfo.is_of_section = "empty"; - comp_obj_heading_.metainfo.is_of_type = "para"; - comp_obj_heading_.metainfo.is_a = "heading"; - comp_obj_heading_.text = "(skip) there is no Glossary section"; - comp_obj_heading_.metainfo.ocn = 0; - comp_obj_heading_.metainfo.object_number_off = ""; - comp_obj_heading_.metainfo.object_number_type = 0; - 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; - the_glossary_section ~= comp_obj_heading_; + comp_obj_heading_ = comp_obj_heading_.init; + comp_obj_heading_.metainfo.is_of_part = "empty"; + comp_obj_heading_.metainfo.is_of_section = "empty"; + comp_obj_heading_.metainfo.is_of_type = "para"; + comp_obj_heading_.metainfo.is_a = "heading"; + comp_obj_heading_.text = "(skip) there is no Glossary section"; + comp_obj_heading_.metainfo.ocn = 0; + comp_obj_heading_.metainfo.object_number_off = ""; + comp_obj_heading_.metainfo.object_number_type = 0; + 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; + the_glossary_section ~= comp_obj_heading_; } debug(glossary) { foreach (gloss; the_glossary_section) { @@ -1485,54 +1514,60 @@ auto biblio_ordered #+name: abs_post #+BEGIN_SRC d if (biblio_ordered.length > 0) { - comp_obj_heading_ = comp_obj_heading_.init; - comp_obj_heading_.metainfo.is_of_part = "backmatter"; - comp_obj_heading_.metainfo.is_of_section = "bibliography"; - comp_obj_heading_.metainfo.is_of_type = "para"; - comp_obj_heading_.metainfo.is_a = "heading"; - comp_obj_heading_.text = "Bibliography"; - 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_html = "_part_bibliography"; - comp_obj_heading_.tags.segment_anchor_tag_epub = comp_obj_heading_.tags.segment_anchor_tag_html; - 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; - the_bibliography_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 = "bibliography"; - comp_obj_heading_.metainfo.is_of_type = "para"; - comp_obj_heading_.metainfo.is_a = "heading"; - comp_obj_heading_.text = "Bibliography"; - 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_html = "bibliography"; - comp_obj_heading_.tags.segment_anchor_tag_epub = comp_obj_heading_.tags.segment_anchor_tag_html; - 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 = ["bibliography"]; - the_bibliography_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 = "bibliography"; + comp_obj_heading_.metainfo.is_of_type = "para"; + comp_obj_heading_.metainfo.is_a = "heading"; + comp_obj_heading_.text = "Bibliography"; + 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_epub = "_part_bibliography"; + comp_obj_heading_.tags.anchor_tag_html = comp_obj_heading_.tags.segment_anchor_tag_epub; + comp_obj_heading_.tags.in_segment_html = "bibliography"; + 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; + the_bibliography_section ~= comp_obj_heading_; + tag_assoc[comp_obj_heading_.tags.anchor_tag_html]["seg_lv4"] = comp_obj_heading_.tags.in_segment_html; + tag_assoc[comp_obj_heading_.tags.segment_anchor_tag_epub]["seg_lv1_to_4"] = comp_obj_heading_.tags.segment_anchor_tag_epub; + comp_obj_heading_ = comp_obj_heading_.init; + comp_obj_heading_.metainfo.is_of_part = "backmatter"; + comp_obj_heading_.metainfo.is_of_section = "bibliography"; + comp_obj_heading_.metainfo.is_of_type = "para"; + comp_obj_heading_.metainfo.is_a = "heading"; + comp_obj_heading_.text = "Bibliography"; + 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_epub = "bibliography"; + comp_obj_heading_.tags.anchor_tag_html = comp_obj_heading_.tags.segment_anchor_tag_epub; + comp_obj_heading_.tags.in_segment_html = comp_obj_heading_.tags.anchor_tag_html; + 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 = ["bibliography"]; + the_bibliography_section ~= comp_obj_heading_; + tag_assoc[comp_obj_heading_.tags.anchor_tag_html]["seg_lv4"] = comp_obj_heading_.tags.in_segment_html; + tag_assoc[comp_obj_heading_.tags.segment_anchor_tag_epub]["seg_lv1_to_4"] = comp_obj_heading_.tags.segment_anchor_tag_epub; } else { - comp_obj_heading_ = comp_obj_heading_.init; - comp_obj_heading_.metainfo.is_of_part = "empty"; - comp_obj_heading_.metainfo.is_of_section = "empty"; - comp_obj_heading_.metainfo.is_of_type = "para"; - comp_obj_heading_.metainfo.is_a = "heading"; - comp_obj_heading_.text = "(skip) there is no Bibliography"; - comp_obj_heading_.metainfo.ocn = 0; - comp_obj_heading_.metainfo.object_number_off = ""; - comp_obj_heading_.metainfo.object_number_type = 0; - 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; - the_bibliography_section ~= comp_obj_heading_; + comp_obj_heading_ = comp_obj_heading_.init; + comp_obj_heading_.metainfo.is_of_part = "empty"; + comp_obj_heading_.metainfo.is_of_section = "empty"; + comp_obj_heading_.metainfo.is_of_type = "para"; + comp_obj_heading_.metainfo.is_a = "heading"; + comp_obj_heading_.text = "(skip) there is no Bibliography"; + comp_obj_heading_.metainfo.ocn = 0; + comp_obj_heading_.metainfo.object_number_off = ""; + comp_obj_heading_.metainfo.object_number_type = 0; + 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; + the_bibliography_section ~= comp_obj_heading_; } #+END_SRC @@ -1630,7 +1665,7 @@ static assert(!isTypeTuple!(bi_tuple)); auto the_bookindex_section = bi_tuple[0]; obj_cite_digits = bi_tuple[1]; debug(bookindex) { - foreach (bi_entry; the_bookindex_section["seg"]) { + foreach (bi_entry; the_bookindex_section) { writeln(bi_entry); } } @@ -1650,8 +1685,9 @@ if (an_object["blurb_nugget"].length == 0) { comp_obj_heading_.metainfo.ocn = 0; comp_obj_para.metainfo.object_number_off = ""; comp_obj_para.metainfo.object_number_type = 0; - comp_obj_heading_.tags.segment_anchor_tag_html = ""; comp_obj_heading_.tags.segment_anchor_tag_epub = ""; + comp_obj_heading_.tags.anchor_tag_html = ""; + comp_obj_heading_.tags.in_segment_html = ""; comp_obj_heading_.metainfo.heading_lev_markup = 1; comp_obj_heading_.metainfo.heading_lev_collapsed = 1; comp_obj_heading_.metainfo.parent_ocn = 1; @@ -1686,29 +1722,16 @@ comp_obj_toc.attrib.indent_base = indent["base_position"]; comp_obj_toc.attrib.bullet = false; if (the_endnotes_section.length > 1) { toc_txt_ = format( - "{ %s }%s%s%s", + "{ %s }#%s", "Endnotes", - mkup.mark_internal_site_lnk, "endnotes", - ".fnSuffix", ); toc_txt_= munge.url_links(toc_txt_); comp_obj_toc.text = toc_txt_.to!string.strip; comp_obj_toc.has.inline_links = true; - the_table_of_contents_section["seg"] ~= comp_obj_toc; + the_table_of_contents_section ~= comp_obj_toc; } if (the_glossary_section.length > 1) { - toc_txt_ = format( - "{ %s }%s%s%s", - "Glossary", - mkup.mark_internal_site_lnk, - "glossary", - ".fnSuffix", - ); - toc_txt_= munge.url_links(toc_txt_); - comp_obj_toc.text = toc_txt_.to!string.strip; - comp_obj_toc.has.inline_links = true; - the_table_of_contents_section["seg"] ~= comp_obj_toc; toc_txt_ = format( "{ %s }#%s", "Glossary", @@ -1717,21 +1740,9 @@ if (the_glossary_section.length > 1) { toc_txt_= munge.url_links(toc_txt_); comp_obj_toc.text = toc_txt_.to!string.strip; comp_obj_toc.has.inline_links = true; - the_table_of_contents_section["scroll"] ~= comp_obj_toc; + the_table_of_contents_section ~= comp_obj_toc; } if (the_bibliography_section.length > 1){ - toc_txt_ = format( - "{ %s }%s%s%s", - "Bibliography", - mkup.mark_internal_site_lnk, - "bibliography", - ".fnSuffix", - ); - toc_txt_= munge.url_links(toc_txt_); - comp_obj_toc.text = toc_txt_.to!string.strip; - comp_obj_toc.has.inline_links = true; - the_table_of_contents_section["seg"] ~= comp_obj_toc; - toc_txt_ = format( "{ %s }#%s", "Bibliography", @@ -1740,22 +1751,9 @@ if (the_bibliography_section.length > 1){ toc_txt_= munge.url_links(toc_txt_); comp_obj_toc.text = toc_txt_.to!string.strip; comp_obj_toc.has.inline_links = true; - the_table_of_contents_section["scroll"] ~= comp_obj_toc; -} -if (the_bookindex_section["seg"].length > 1) { - toc_txt_ = format( - "{ %s }%s%s%s", - "Book Index", - mkup.mark_internal_site_lnk, - "bookindex", - ".fnSuffix", - ); - toc_txt_= munge.url_links(toc_txt_); - comp_obj_toc.text = toc_txt_.to!string.strip; - comp_obj_toc.has.inline_links = true; - the_table_of_contents_section["seg"] ~= comp_obj_toc; + the_table_of_contents_section ~= comp_obj_toc; } -if (the_bookindex_section["scroll"].length > 1) { +if (the_bookindex_section.length > 1) { toc_txt_ = format( "{ %s }#%s", "Book Index", @@ -1764,20 +1762,9 @@ if (the_bookindex_section["scroll"].length > 1) { toc_txt_= munge.url_links(toc_txt_); comp_obj_toc.text = toc_txt_.to!string.strip; comp_obj_toc.has.inline_links = true; - the_table_of_contents_section["scroll"] ~= comp_obj_toc; + the_table_of_contents_section ~= comp_obj_toc; } if (the_blurb_section.length > 1) { - toc_txt_ = format( - "{ %s }%s%s%s", - "Blurb", - mkup.mark_internal_site_lnk, - "blurb", - ".fnSuffix", - ); - toc_txt_= munge.url_links(toc_txt_); - comp_obj_toc.text = toc_txt_.to!string.strip; - comp_obj_toc.has.inline_links = true; - the_table_of_contents_section["seg"] ~= comp_obj_toc; toc_txt_ = format( "{ %s }#%s", "Blurb", @@ -1786,25 +1773,14 @@ if (the_blurb_section.length > 1) { toc_txt_= munge.url_links(toc_txt_); comp_obj_toc.has.inline_links = true; comp_obj_toc.text = toc_txt_.to!string.strip; - the_table_of_contents_section["scroll"] ~= comp_obj_toc; + the_table_of_contents_section ~= comp_obj_toc; } debug(toc) { writefln( "%s %s", __LINE__, - the_table_of_contents_section["seg"].length ); - foreach (toc_linked_heading; the_table_of_contents_section["seg"]) { - writeln(mkup.indent_by_spaces_provided(toc_linked_heading.attrib.indent_hang), toc_linked_heading.text); - } -} -debug(tocscroll) { - writefln( - "%s %s", - __LINE__, - the_table_of_contents_section["seg"].length - ); - foreach (toc_linked_heading; the_table_of_contents_section["scroll"]) { + foreach (toc_linked_heading; the_table_of_contents_section) { writeln(mkup.indent_by_spaces_provided(toc_linked_heading.attrib.indent_hang), toc_linked_heading.text); } } @@ -2053,7 +2029,8 @@ if (the_document_body_section.length > 1) { #+name: abs_post #+BEGIN_SRC d if (the_endnotes_section.length > 1) { - html_segnames ~= "endnotes"; + segnames["html"] ~= "endnotes"; + segnames["epub"] ~= "endnotes"; html_segnames_ptr = html_segnames_ptr_cntr; foreach (ref obj; the_endnotes_section) { if (obj.metainfo.is_a == "heading") { @@ -2073,7 +2050,8 @@ if (the_endnotes_section.length > 1) { #+name: abs_post #+BEGIN_SRC d if (the_glossary_section.length > 1) { - html_segnames ~= "glossary"; + segnames["html"] ~= "glossary"; + segnames["epub"] ~= "glossary"; html_segnames_ptr = html_segnames_ptr_cntr; foreach (ref obj; the_glossary_section) { if (obj.metainfo.is_a == "heading") { @@ -2093,7 +2071,8 @@ if (the_glossary_section.length > 1) { #+name: abs_post #+BEGIN_SRC d if (the_bibliography_section.length > 1) { - html_segnames ~= "bibliography"; + segnames["html"] ~= "bibliography"; + segnames["epub"] ~= "bibliography"; html_segnames_ptr = html_segnames_ptr_cntr; foreach (ref obj; the_bibliography_section) { if (obj.metainfo.is_a == "heading") { @@ -2112,10 +2091,11 @@ if (the_bibliography_section.length > 1) { #+name: abs_post #+BEGIN_SRC d -if (the_bookindex_section["scroll"].length > 1) { - html_segnames ~= "bookindex"; +if (the_bookindex_section.length > 1) { + segnames["html"] ~= "bookindex"; + segnames["epub"] ~= "bookindex"; html_segnames_ptr = html_segnames_ptr_cntr; - foreach (ref obj; the_bookindex_section["scroll"]) { + foreach (ref obj; the_bookindex_section) { if (obj.metainfo.is_a == "heading") { obj.metainfo.parent_ocn = obj.metainfo.markedup_ancestors[obj.metainfo.parent_lev_markup]; } @@ -2124,12 +2104,6 @@ if (the_bookindex_section["scroll"].length > 1) { break; } } - foreach (ref obj; the_bookindex_section["seg"]) { - if (obj.metainfo.heading_lev_markup == 4) { - obj.ptr.html_segnames = html_segnames_ptr; - break; - } - } html_segnames_ptr_cntr++; } #+END_SRC @@ -2139,7 +2113,8 @@ if (the_bookindex_section["scroll"].length > 1) { #+name: abs_post #+BEGIN_SRC d if (the_blurb_section.length > 1) { - html_segnames ~= "blurb"; + segnames["html"] ~= "blurb"; + segnames["epub"] ~= "blurb"; html_segnames_ptr = html_segnames_ptr_cntr; foreach (ref obj; the_blurb_section) { if (obj.metainfo.is_a == "heading") { @@ -2340,17 +2315,18 @@ foreach (ref obj; the_document_head_section) { #+name: abs_post #+BEGIN_SRC d -if (the_table_of_contents_section["scroll"].length > 1) { +if (the_table_of_contents_section.length > 1) { /+ scroll +/ 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"]) { + 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; if (obj.metainfo.heading_lev_markup == 4) { - obj.tags.segname_next = html_segnames[obj.ptr.html_segnames + 1]; - assert(obj.tags.segment_anchor_tag_html == html_segnames[obj.ptr.html_segnames], - obj.tags.segment_anchor_tag_html ~ "!=" ~ html_segnames[obj.ptr.html_segnames]); + obj.tags.segname_next = segnames["html"][obj.ptr.html_segnames + 1]; + assert(obj.tags.anchor_tag_html == segnames["html"][obj.ptr.html_segnames], + obj.tags.anchor_tag_html ~ "!=" ~ segnames["html"][obj.ptr.html_segnames]); } } /+ dom structure (marked up & collapsed) +/ @@ -2366,32 +2342,6 @@ if (the_table_of_contents_section["scroll"].length > 1) { obj = obj_heading_ancestors(obj, lv_ancestors_txt); } } - /+ seg +/ - 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) { - writeln(obj.text); - } - if (obj.metainfo.heading_lev_markup <= 4) { - segnames_lv0_to_4 ~= obj.tags.segment_anchor_tag_epub; - if (obj.metainfo.heading_lev_markup == 4) { - obj.tags.segname_next = html_segnames[obj.ptr.html_segnames + 1]; - assert(obj.tags.segment_anchor_tag_html == html_segnames[obj.ptr.html_segnames], - obj.tags.segment_anchor_tag_html ~ "!=" ~ html_segnames[obj.ptr.html_segnames]); - } - } - if ((opt_action.html) - || (opt_action.html_scroll) - || (opt_action.html_seg) - || (opt_action.epub)) { - 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); - } - } } #+END_SRC @@ -2402,6 +2352,14 @@ if (the_table_of_contents_section["scroll"].length > 1) { /+ multiple 1~ levels, loop through document body +/ if (the_document_body_section.length > 1) { foreach (ref obj; the_document_body_section) { + if (!(((obj.metainfo.ocn.to!string) in tag_assoc) + && ("seg_lv4" in tag_assoc[(obj.metainfo.ocn.to!string)])) + ) { + tag_assoc[(obj.metainfo.ocn.to!string)]["seg_lv4"] + = obj.tags.html_segment_anchor_tag_is; + } + tag_assoc[(obj.metainfo.ocn.to!string)]["seg_lv1_to_4"] + = obj.tags.epub_segment_anchor_tag_is; if (obj.metainfo.is_a == "heading") { debug(dom) { writeln(obj.text); @@ -2409,13 +2367,13 @@ if (the_document_body_section.length > 1) { if (obj.metainfo.heading_lev_markup <= 4) { segnames_lv0_to_4 ~= obj.tags.segment_anchor_tag_epub; if (obj.metainfo.heading_lev_markup == 4) { - obj.tags.lev4_subtoc = lev4_subtoc[obj.tags.segment_anchor_tag_html]; - obj.tags.segname_prev = html_segnames[obj.ptr.html_segnames - 1]; - if (html_segnames.length > obj.ptr.html_segnames + 1) { - obj.tags.segname_next = html_segnames[obj.ptr.html_segnames + 1]; + obj.tags.lev4_subtoc = lev4_subtoc[obj.tags.anchor_tag_html]; + obj.tags.segname_prev = segnames["html"][obj.ptr.html_segnames - 1]; + if (segnames["html"].length > obj.ptr.html_segnames + 1) { + obj.tags.segname_next = segnames["html"][obj.ptr.html_segnames + 1]; } - assert(obj.tags.segment_anchor_tag_html == html_segnames[obj.ptr.html_segnames], - obj.tags.segment_anchor_tag_html ~ "!=" ~ html_segnames[obj.ptr.html_segnames]); + assert(obj.tags.anchor_tag_html == segnames["html"][obj.ptr.html_segnames], + obj.tags.anchor_tag_html ~ "!=" ~ segnames["html"][obj.ptr.html_segnames]); } } /+ dom structure (marked up & collapsed) +/ @@ -2446,10 +2404,10 @@ auto images=uniq(_images.sort()); #+BEGIN_SRC d /+ optional only one 1~ level +/ if (the_endnotes_section.length > 1) { - dom_structure_markedup_tags_status_buffer = dom_structure_markedup_tags_status.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; + 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) { @@ -2460,12 +2418,12 @@ if (the_endnotes_section.length > 1) { if (obj.metainfo.heading_lev_markup <= 4) { segnames_lv0_to_4 ~= obj.tags.segment_anchor_tag_epub; if (obj.metainfo.heading_lev_markup == 4) { - obj.tags.segname_prev = html_segnames[obj.ptr.html_segnames - 1]; - if (html_segnames.length > obj.ptr.html_segnames + 1) { - obj.tags.segname_next = html_segnames[obj.ptr.html_segnames + 1]; + obj.tags.segname_prev = segnames["html"][obj.ptr.html_segnames - 1]; + if (segnames["html"].length > obj.ptr.html_segnames + 1) { + obj.tags.segname_next = segnames["html"][obj.ptr.html_segnames + 1]; } - assert(obj.tags.segment_anchor_tag_html == html_segnames[obj.ptr.html_segnames], - obj.tags.segment_anchor_tag_html ~ "!=" ~ html_segnames[obj.ptr.html_segnames]); + assert(obj.tags.anchor_tag_html == segnames["html"][obj.ptr.html_segnames], + obj.tags.anchor_tag_html ~ "!=" ~ segnames["html"][obj.ptr.html_segnames]); } } /+ dom structure (marked up & collapsed) +/ @@ -2502,12 +2460,12 @@ if (the_glossary_section.length > 1) { if (obj.metainfo.heading_lev_markup <= 4) { segnames_lv0_to_4 ~= obj.tags.segment_anchor_tag_epub; if (obj.metainfo.heading_lev_markup == 4) { - obj.tags.segname_prev = html_segnames[obj.ptr.html_segnames - 1]; - if (html_segnames.length > obj.ptr.html_segnames + 1) { - obj.tags.segname_next = html_segnames[obj.ptr.html_segnames + 1]; + obj.tags.segname_prev = segnames["html"][obj.ptr.html_segnames - 1]; + if (segnames["html"].length > obj.ptr.html_segnames + 1) { + obj.tags.segname_next = segnames["html"][obj.ptr.html_segnames + 1]; } - assert(obj.tags.segment_anchor_tag_html == html_segnames[obj.ptr.html_segnames], - obj.tags.segment_anchor_tag_html ~ "!=" ~ html_segnames[obj.ptr.html_segnames]); + assert(obj.tags.anchor_tag_html == segnames["html"][obj.ptr.html_segnames], + obj.tags.anchor_tag_html ~ "!=" ~ segnames["html"][obj.ptr.html_segnames]); } } /+ dom structure (marked up & collapsed) +/ @@ -2547,12 +2505,12 @@ if (the_bibliography_section.length > 1) { if (obj.metainfo.heading_lev_markup <= 4) { segnames_lv0_to_4 ~= obj.tags.segment_anchor_tag_epub; if (obj.metainfo.heading_lev_markup == 4) { - obj.tags.segname_prev = html_segnames[obj.ptr.html_segnames - 1]; - if (html_segnames.length > obj.ptr.html_segnames + 1) { - obj.tags.segname_next = html_segnames[obj.ptr.html_segnames + 1]; + obj.tags.segname_prev = segnames["html"][obj.ptr.html_segnames - 1]; + if (segnames["html"].length > obj.ptr.html_segnames + 1) { + obj.tags.segname_next = segnames["html"][obj.ptr.html_segnames + 1]; } - assert(obj.tags.segment_anchor_tag_html == html_segnames[obj.ptr.html_segnames], - obj.tags.segment_anchor_tag_html ~ "!=" ~ html_segnames[obj.ptr.html_segnames]); + assert(obj.tags.anchor_tag_html == segnames["html"][obj.ptr.html_segnames], + obj.tags.anchor_tag_html ~ "!=" ~ segnames["html"][obj.ptr.html_segnames]); } } /+ dom structure (marked up & collapsed) +/ @@ -2584,24 +2542,27 @@ if (the_bibliography_section.length > 1) { int ocn_ = obj_cite_digits.on; int ocn_bkidx_ = 0; int ocn_bidx_; -if (the_bookindex_section["scroll"].length > 1) { +if (the_bookindex_section.length > 1) { /+ scroll +/ 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"]) { + foreach (ref obj; the_bookindex_section) { if (obj.metainfo.is_a == "heading") { debug(dom) { } + if (obj.metainfo.heading_lev_markup <= 4) { + segnames_lv0_to_4 ~= obj.tags.segment_anchor_tag_epub; + } obj_cite_digits = ocn_emit(OCNstatus.on); obj.metainfo.ocn = obj_cite_digits.on; if (obj.metainfo.heading_lev_markup <= 4) { if (obj.metainfo.heading_lev_markup == 4) { - obj.tags.segname_prev = html_segnames[obj.ptr.html_segnames - 1]; - if (html_segnames.length > obj.ptr.html_segnames + 1) { - obj.tags.segname_next = html_segnames[obj.ptr.html_segnames + 1]; + obj.tags.segname_prev = segnames["html"][obj.ptr.html_segnames - 1]; + if (segnames["html"].length > obj.ptr.html_segnames + 1) { + obj.tags.segname_next = segnames["html"][obj.ptr.html_segnames + 1]; } - assert(obj.tags.segment_anchor_tag_html == html_segnames[obj.ptr.html_segnames], - obj.tags.segment_anchor_tag_html ~ "!=" ~ html_segnames[obj.ptr.html_segnames]); + assert(obj.tags.anchor_tag_html == segnames["html"][obj.ptr.html_segnames], + obj.tags.anchor_tag_html ~ "!=" ~ segnames["html"][obj.ptr.html_segnames]); } } /+ dom structure (marked up & collapsed) +/ @@ -2622,43 +2583,6 @@ if (the_bookindex_section["scroll"].length > 1) { obj.metainfo.object_number_type = OCNtype.bkidx; } } - /+ seg +/ - 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) { - writeln(obj.text); - } - obj.metainfo.ocn = ++ocn_; - if (obj.metainfo.heading_lev_markup <= 4) { - segnames_lv0_to_4 ~= obj.tags.segment_anchor_tag_epub; - if (obj.metainfo.heading_lev_markup == 4) { - obj.tags.segname_prev = html_segnames[obj.ptr.html_segnames - 1]; - if (html_segnames.length > obj.ptr.html_segnames + 1) { - obj.tags.segname_next = html_segnames[obj.ptr.html_segnames + 1]; - } - assert(obj.tags.segment_anchor_tag_html == html_segnames[obj.ptr.html_segnames], - obj.tags.segment_anchor_tag_html ~ "!=" ~ html_segnames[obj.ptr.html_segnames]); - } - } - /+ dom structure (marked up & collapsed) +/ - if ((opt_action.html) - || (opt_action.html_scroll) - || (opt_action.html_seg) - || (opt_action.epub) - || (opt_action.sqlite_discrete) - || (opt_action.sqlite_update)) { - 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_; - obj.metainfo.o_n_book_index = ocn_bidx_; // FIX need to distinguish from regular ocn - obj.metainfo.object_number_type = OCNtype.bkidx; - } - } /+ TODO assert failure, reinstate assert(obj_cite_digit_bkidx == ocn_bidx_ obj_cite_digit_bkidx ~ " == ocn_" ~ ocn_ ~ "?"); @@ -2682,12 +2606,12 @@ if (the_blurb_section.length > 1) { if (obj.metainfo.heading_lev_markup <= 4) { segnames_lv0_to_4 ~= obj.tags.segment_anchor_tag_epub; if (obj.metainfo.heading_lev_markup == 4) { - obj.tags.segname_prev = html_segnames[obj.ptr.html_segnames - 1]; - if (html_segnames.length > obj.ptr.html_segnames + 1) { - obj.tags.segname_next = html_segnames[obj.ptr.html_segnames + 1]; + obj.tags.segname_prev = segnames["html"][obj.ptr.html_segnames - 1]; + if (segnames["html"].length > obj.ptr.html_segnames + 1) { + obj.tags.segname_next = segnames["html"][obj.ptr.html_segnames + 1]; } - assert(obj.tags.segment_anchor_tag_html == html_segnames[obj.ptr.html_segnames], - obj.tags.segment_anchor_tag_html ~ "!=" ~ html_segnames[obj.ptr.html_segnames]); + assert(obj.tags.anchor_tag_html == segnames["html"][obj.ptr.html_segnames], + obj.tags.anchor_tag_html ~ "!=" ~ segnames["html"][obj.ptr.html_segnames]); } } /+ dom structure (marked up & collapsed) +/ @@ -2721,7 +2645,7 @@ if (the_document_body_section.length > 1) { the_endnotes_section ~ the_glossary_section ~ the_bibliography_section ~ - the_bookindex_section["scroll"] ~ + the_bookindex_section ~ the_blurb_section ); debug(decendants_tuple) { @@ -2783,8 +2707,8 @@ if (the_document_body_section.length > 1) { } } } - if (the_bookindex_section["scroll"].length > 1) { - foreach (ref obj; the_bookindex_section["scroll"]) { + if (the_bookindex_section.length > 1) { + foreach (ref obj; the_bookindex_section) { if (obj.metainfo.is_a == "heading") { foreach (pair; pairs) { if (obj.metainfo.ocn == pair[0]) { @@ -2818,21 +2742,23 @@ if (the_document_body_section.length > 1) { - 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"; -comp_obj_heading_.metainfo.is_of_section = "empty"; -comp_obj_heading_.metainfo.is_of_type = "para"; -comp_obj_heading_.metainfo.is_a = "heading"; -comp_obj_heading_.metainfo.ocn = 0; -comp_obj_para.metainfo.object_number_off = ""; -comp_obj_para.metainfo.object_number_type = 0; -comp_obj_heading_.tags.segment_anchor_tag_html = ""; -comp_obj_heading_.tags.segment_anchor_tag_epub = ""; -comp_obj_heading_.tags.segment_anchor_tag_is = ""; -comp_obj_heading_.metainfo.heading_lev_markup = 9; -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_ = comp_obj_heading_.init; +comp_obj_heading_.metainfo.is_of_part = "empty"; +comp_obj_heading_.metainfo.is_of_section = "empty"; +comp_obj_heading_.metainfo.is_of_type = "para"; +comp_obj_heading_.metainfo.is_a = "heading"; +comp_obj_heading_.metainfo.ocn = 0; +comp_obj_para.metainfo.object_number_off = ""; +comp_obj_para.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 = ""; +comp_obj_heading_.tags.html_segment_anchor_tag_is = ""; +comp_obj_heading_.tags.epub_segment_anchor_tag_is = ""; +comp_obj_heading_.metainfo.heading_lev_markup = 9; +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_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); @@ -2848,16 +2774,14 @@ comp_obj_heading_ = obj_heading_ancestors(comp_obj_heading_, lv_ancestors_txt); #+BEGIN_SRC d auto document_the = [ "head": the_document_head_section, - "toc_seg": the_table_of_contents_section["seg"], - "toc_scroll": the_table_of_contents_section["scroll"], + "toc": the_table_of_contents_section, /+ substantive/body: +/ "body": the_document_body_section, /+ backmatter: +/ "endnotes": the_endnotes_section, "glossary": the_glossary_section, "bibliography": the_bibliography_section, - "bookindex_scroll": the_bookindex_section["scroll"], - "bookindex_seg": the_bookindex_section["seg"], + "bookindex": the_bookindex_section, "blurb": the_blurb_section, /+ dom tail only +/ "tail": the_dom_tail_section, @@ -2869,8 +2793,8 @@ auto document_the = [ #+name: abs_post #+BEGIN_SRC d string[][string] document_section_keys_sequenced = [ - "seg": ["head", "toc_seg", "body",], - "scroll": ["head", "toc_scroll", "body",], + "seg": ["head", "toc", "body",], + "scroll": ["head", "toc", "body",], "sql": ["head", "body",] ]; if (document_the["endnotes"].length > 1) { @@ -2887,12 +2811,10 @@ if (document_the["bibliography"].length > 1) { document_section_keys_sequenced["scroll"] ~= "bibliography"; document_section_keys_sequenced["sql"] ~= "bibliography"; } -if (document_the["bookindex_seg"].length > 1) { - document_section_keys_sequenced["seg"] ~= "bookindex_seg"; - document_section_keys_sequenced["sql"] ~= "bookindex_seg"; -} -if (document_the["bookindex_scroll"].length > 1) { - document_section_keys_sequenced["scroll"] ~= "bookindex_scroll"; +if (document_the["bookindex"].length > 1) { + document_section_keys_sequenced["seg"] ~= "bookindex"; + document_section_keys_sequenced["scroll"] ~= "bookindex"; + document_section_keys_sequenced["sql"] ~= "bookindex"; } if (document_the["blurb"].length > 1) { document_section_keys_sequenced["seg"] ~= "blurb"; @@ -2913,7 +2835,12 @@ auto sequenced_document_keys = docSectKeysSeq!()(document_section_keys_sequenced #+name: abs_post #+BEGIN_SRC d -auto segnames_lv4 = html_segnames.dup; +auto segnames_lv4 = segnames["html"].dup; +auto segnames_lv1_to_4 = segnames["epub"].dup; +debug(segnames) { + writeln("segnames_lv4: ", segnames_lv4); + writeln("segnames_lv1_to_4: ", segnames_lv1_to_4); +} #+END_SRC *** clean out structure @@ -2928,7 +2855,7 @@ destroy(the_glossary_section); destroy(the_bibliography_section); destroy(the_bookindex_section); destroy(the_blurb_section); -destroy(html_segnames); +destroy(segnames); destroy(bookindex_unordered_hashes); destroy(an_object); obj_cite_digits = ocn_emit(OCNstatus.reset); @@ -3004,7 +2931,7 @@ auto t = tuple( sequenced_document_keys, segnames_lv4, segnames_lv0_to_4, - tag_assoc_html, + tag_assoc, images, ); return t; @@ -3215,7 +3142,7 @@ void _start_block_(L,T,N)( line ); } - object_number_poem["start"] = obj_cite_digits.on.to!string; + object_number_poem["start"] = obj_cite_digits.on.to!string; obj_type_status["blocks"] = TriState.on; obj_type_status["verse_new"] = State.on; obj_type_status["poem"] = TriState.on; @@ -3300,7 +3227,7 @@ void _start_block_(L,T,N)( line ); } - object_number_poem["start"] = obj_cite_digits.on.to!string; + object_number_poem["start"] = obj_cite_digits.on.to!string; obj_type_status["blocks"] = TriState.on; obj_type_status["verse_new"] = State.on; obj_type_status["poem"] = TriState.on; @@ -3674,7 +3601,7 @@ void _group_block_(L,O,T)( debug(group) { writeln(line); } - an_object[an_object_key] = an_object[an_object_key].stripRight; + an_object[an_object_key] = an_object[an_object_key].stripRight; obj_type_status["blocks"] = TriState.closing; obj_type_status["group"] = TriState.closing; obj_type_status["curly_group"] = TriState.off; @@ -3689,7 +3616,7 @@ void _group_block_(L,O,T)( debug(group) { writeln(line); } - an_object[an_object_key] = an_object[an_object_key].stripRight; + an_object[an_object_key] = an_object[an_object_key].stripRight; obj_type_status["blocks"] = TriState.closing; obj_type_status["group"] = TriState.closing; obj_type_status["tic_group"] = TriState.off; @@ -3727,7 +3654,7 @@ void _block_block_(L,O,T)( debug(block) { // block (curly) close writeln(line); } - an_object[an_object_key] = an_object[an_object_key].stripRight; + an_object[an_object_key] = an_object[an_object_key].stripRight; obj_type_status["blocks"] = TriState.closing; obj_type_status["block"] = TriState.closing; obj_type_status["curly_block"] = TriState.off; @@ -3742,7 +3669,7 @@ void _block_block_(L,O,T)( debug(block) { writeln(line); } - an_object[an_object_key] = an_object[an_object_key].stripRight; + an_object[an_object_key] = an_object[an_object_key].stripRight; obj_type_status["blocks"] = TriState.closing; obj_type_status["block"] = TriState.closing; obj_type_status["tic_block"] = TriState.off; @@ -3769,7 +3696,7 @@ void _poem_block_(L,O,T,C,N,CMM,Ts)( return ref C cntr, N object_number_poem, CMM conf_make_meta, - Ts segment_anchor_tag_that_object_belongs_to, + Ts tag_in_seg, ) { debug(asserts) { static assert(is(typeof(line) == char[])); @@ -3813,22 +3740,23 @@ void _poem_block_(L,O,T,C,N,CMM,Ts)( = obj_im.obj_inline_markup_and_anchor_tags_and_misc(an_object, an_object_key, conf_make_meta, false); an_object["substantive"] = substantive_obj_misc_tuple[sObj.content]; anchor_tag = substantive_obj_misc_tuple[sObj.anchor_tag]; - tag_assoc_html = inline_para_link_anchor(an_object, segment_anchor_tag_that_object_belongs_to, tag_assoc_html); - comp_obj_block = comp_obj_block.init; - comp_obj_block.metainfo.is_of_part = "body"; - comp_obj_block.metainfo.is_of_section = "body"; - comp_obj_block.metainfo.is_of_type = "block"; - comp_obj_block.metainfo.is_a = "verse"; - comp_obj_block.metainfo.ocn = obj_cite_digits.on; - comp_obj_block.metainfo.object_number_off = (obj_cite_digits.off==0) ? "" : obj_cite_digits.off.to!string; - comp_obj_block.tags.segment_anchor_tag_is = segment_anchor_tag_that_object_belongs_to["html"]; - comp_obj_block.metainfo.o_n_book_index = obj_cite_digits.bkidx; - comp_obj_block.metainfo.object_number_type = obj_cite_digits.type; - comp_obj_block.text = an_object["substantive"]; - comp_obj_block.has.inline_notes_reg = substantive_obj_misc_tuple[sObj.notes_reg]; - comp_obj_block.has.inline_notes_star = substantive_obj_misc_tuple[sObj.notes_star]; - comp_obj_block.has.inline_links = substantive_obj_misc_tuple[sObj.links]; - the_document_body_section ~= comp_obj_block; + comp_obj_block = comp_obj_block.init; + comp_obj_block.metainfo.is_of_part = "body"; + comp_obj_block.metainfo.is_of_section = "body"; + comp_obj_block.metainfo.is_of_type = "block"; + comp_obj_block.metainfo.is_a = "verse"; + comp_obj_block.metainfo.ocn = obj_cite_digits.on; + comp_obj_block.metainfo.object_number_off = (obj_cite_digits.off==0) ? "" : obj_cite_digits.off.to!string; + comp_obj_block.tags.html_segment_anchor_tag_is = tag_in_seg["seg_lv4"]; + comp_obj_block.tags.epub_segment_anchor_tag_is = tag_in_seg["seg_lv1_to_4"]; + comp_obj_block.metainfo.o_n_book_index = obj_cite_digits.bkidx; + comp_obj_block.metainfo.object_number_type = obj_cite_digits.type; + comp_obj_block.text = an_object["substantive"]; + comp_obj_block.has.inline_notes_reg = substantive_obj_misc_tuple[sObj.notes_reg]; + comp_obj_block.has.inline_notes_star = substantive_obj_misc_tuple[sObj.notes_star]; + comp_obj_block.has.inline_links = substantive_obj_misc_tuple[sObj.links]; + the_document_body_section ~= comp_obj_block; + tag_assoc = inline_para_link_anchor(an_object, tag_in_seg, tag_assoc); } object_reset(an_object); processing.remove("verse"); @@ -3862,9 +3790,9 @@ void _poem_block_(L,O,T,C,N,CMM,Ts)( an_object["is"] = "verse"; auto comp_obj_location = node_construct.node_location_emitter( content_non_header, - segment_anchor_tag_that_object_belongs_to, + tag_in_seg, lev_anchor_tag, - tag_assoc_html, + tag_assoc, obj_cite_digits, cntr, heading_ptr-1, @@ -3874,22 +3802,23 @@ void _poem_block_(L,O,T,C,N,CMM,Ts)( = obj_im.obj_inline_markup_and_anchor_tags_and_misc(an_object, an_object_key, conf_make_meta, false); an_object["substantive"] = substantive_obj_misc_tuple[sObj.content]; anchor_tag = substantive_obj_misc_tuple[sObj.anchor_tag]; - tag_assoc_html = inline_para_link_anchor(an_object, segment_anchor_tag_that_object_belongs_to, tag_assoc_html); - comp_obj_block = comp_obj_block.init; - comp_obj_block.metainfo.is_of_part = "body"; - comp_obj_block.metainfo.is_of_section = "body"; - comp_obj_block.metainfo.is_of_type = "block"; - comp_obj_block.metainfo.is_a = "verse"; - comp_obj_block.metainfo.ocn = obj_cite_digits.on; - comp_obj_block.metainfo.object_number_off = (obj_cite_digits.off==0) ? "" : obj_cite_digits.off.to!string; - comp_obj_block.tags.segment_anchor_tag_is = segment_anchor_tag_that_object_belongs_to["html"]; - comp_obj_block.metainfo.o_n_book_index = obj_cite_digits.bkidx; - comp_obj_block.metainfo.object_number_type = obj_cite_digits.type; - comp_obj_block.text = an_object["substantive"]; - comp_obj_block.has.inline_notes_reg = substantive_obj_misc_tuple[sObj.notes_reg]; - comp_obj_block.has.inline_notes_star = substantive_obj_misc_tuple[sObj.notes_star]; - comp_obj_block.has.inline_links = substantive_obj_misc_tuple[sObj.links]; - the_document_body_section ~= comp_obj_block; + comp_obj_block = comp_obj_block.init; + comp_obj_block.metainfo.is_of_part = "body"; + comp_obj_block.metainfo.is_of_section = "body"; + comp_obj_block.metainfo.is_of_type = "block"; + comp_obj_block.metainfo.is_a = "verse"; + comp_obj_block.metainfo.ocn = obj_cite_digits.on; + comp_obj_block.metainfo.object_number_off = (obj_cite_digits.off==0) ? "" : obj_cite_digits.off.to!string; + comp_obj_block.tags.html_segment_anchor_tag_is = tag_in_seg["seg_lv4"]; + comp_obj_block.tags.epub_segment_anchor_tag_is = tag_in_seg["seg_lv1_to_4"]; + comp_obj_block.metainfo.o_n_book_index = obj_cite_digits.bkidx; + comp_obj_block.metainfo.object_number_type = obj_cite_digits.type; + comp_obj_block.text = an_object["substantive"]; + comp_obj_block.has.inline_notes_reg = substantive_obj_misc_tuple[sObj.notes_reg]; + comp_obj_block.has.inline_notes_star = substantive_obj_misc_tuple[sObj.notes_star]; + comp_obj_block.has.inline_links = substantive_obj_misc_tuple[sObj.links]; + the_document_body_section ~= comp_obj_block; + tag_assoc = inline_para_link_anchor(an_object, tag_in_seg, tag_assoc); object_reset(an_object); processing.remove("verse"); ++cntr; @@ -3913,28 +3842,29 @@ void _poem_block_(L,O,T,C,N,CMM,Ts)( writeln(obj_cite_digits.on, line); } processing.remove("verse"); - an_object["is"] = "verse"; + an_object["is"] = "verse"; auto substantive_obj_misc_tuple = obj_im.obj_inline_markup_and_anchor_tags_and_misc(an_object, an_object_key, conf_make_meta, false); an_object["substantive"] = substantive_obj_misc_tuple[sObj.content]; anchor_tag = substantive_obj_misc_tuple[sObj.anchor_tag]; - tag_assoc_html = inline_para_link_anchor(an_object, segment_anchor_tag_that_object_belongs_to, tag_assoc_html); - comp_obj_block = comp_obj_block.init; - comp_obj_block.metainfo.is_of_part = "body"; - comp_obj_block.metainfo.is_of_section = "body"; - comp_obj_block.metainfo.is_of_type = "block"; - comp_obj_block.metainfo.is_a = "verse"; - comp_obj_block.metainfo.ocn = obj_cite_digits.on; - comp_obj_block.metainfo.object_number_off = (obj_cite_digits.off==0) ? "" : obj_cite_digits.off.to!string; - comp_obj_block.tags.segment_anchor_tag_is = segment_anchor_tag_that_object_belongs_to["html"]; - comp_obj_block.metainfo.o_n_book_index = obj_cite_digits.bkidx; - comp_obj_block.metainfo.object_number_type = obj_cite_digits.type; - comp_obj_block.text = an_object["substantive"]; - comp_obj_block.has.inline_notes_reg = substantive_obj_misc_tuple[sObj.notes_reg]; - comp_obj_block.has.inline_notes_star = substantive_obj_misc_tuple[sObj.notes_star]; - comp_obj_block.has.inline_links = substantive_obj_misc_tuple[sObj.links]; - the_document_body_section ~= comp_obj_block; - object_number_poem["end"] = obj_cite_digits.on.to!string; + comp_obj_block = comp_obj_block.init; + comp_obj_block.metainfo.is_of_part = "body"; + comp_obj_block.metainfo.is_of_section = "body"; + comp_obj_block.metainfo.is_of_type = "block"; + comp_obj_block.metainfo.is_a = "verse"; + comp_obj_block.metainfo.ocn = obj_cite_digits.on; + comp_obj_block.metainfo.object_number_off = (obj_cite_digits.off==0) ? "" : obj_cite_digits.off.to!string; + comp_obj_block.tags.html_segment_anchor_tag_is = tag_in_seg["seg_lv4"]; + comp_obj_block.tags.epub_segment_anchor_tag_is = tag_in_seg["seg_lv1_to_4"]; + comp_obj_block.metainfo.o_n_book_index = obj_cite_digits.bkidx; + comp_obj_block.metainfo.object_number_type = obj_cite_digits.type; + comp_obj_block.text = an_object["substantive"]; + comp_obj_block.has.inline_notes_reg = substantive_obj_misc_tuple[sObj.notes_reg]; + comp_obj_block.has.inline_notes_star = substantive_obj_misc_tuple[sObj.notes_star]; + comp_obj_block.has.inline_links = substantive_obj_misc_tuple[sObj.links]; + the_document_body_section ~= comp_obj_block; + tag_assoc = inline_para_link_anchor(an_object, tag_in_seg, tag_assoc); + object_number_poem["end"] = obj_cite_digits.on.to!string; object_reset(an_object); processing.remove("verse"); ++cntr; @@ -3967,9 +3897,9 @@ void _poem_block_(L,O,T,C,N,CMM,Ts)( auto comp_obj_location = node_construct.node_location_emitter( content_non_header, - segment_anchor_tag_that_object_belongs_to, + tag_in_seg, lev_anchor_tag, - tag_assoc_html, + tag_assoc, obj_cite_digits, cntr, heading_ptr-1, @@ -3979,22 +3909,23 @@ void _poem_block_(L,O,T,C,N,CMM,Ts)( = obj_im.obj_inline_markup_and_anchor_tags_and_misc(an_object, an_object_key, conf_make_meta, false); an_object["substantive"] = substantive_obj_misc_tuple[sObj.content]; anchor_tag = substantive_obj_misc_tuple[sObj.anchor_tag]; - tag_assoc_html = inline_para_link_anchor(an_object, segment_anchor_tag_that_object_belongs_to, tag_assoc_html); - comp_obj_block = comp_obj_block.init; - comp_obj_block.metainfo.is_of_part = "body"; - comp_obj_block.metainfo.is_of_section = "body"; - comp_obj_block.metainfo.is_of_type = "block"; - comp_obj_block.metainfo.is_a = "verse"; - comp_obj_block.metainfo.ocn = obj_cite_digits.on; - comp_obj_block.metainfo.object_number_off = (obj_cite_digits.off==0) ? "" : obj_cite_digits.off.to!string; - comp_obj_block.tags.segment_anchor_tag_is = segment_anchor_tag_that_object_belongs_to["html"]; - comp_obj_block.metainfo.o_n_book_index = obj_cite_digits.bkidx; - comp_obj_block.metainfo.object_number_type = obj_cite_digits.type; - comp_obj_block.text = an_object["substantive"]; - comp_obj_block.has.inline_notes_reg = substantive_obj_misc_tuple[sObj.notes_reg]; - comp_obj_block.has.inline_notes_star = substantive_obj_misc_tuple[sObj.notes_star]; - comp_obj_block.has.inline_links = substantive_obj_misc_tuple[sObj.links]; - the_document_body_section ~= comp_obj_block; + comp_obj_block = comp_obj_block.init; + comp_obj_block.metainfo.is_of_part = "body"; + comp_obj_block.metainfo.is_of_section = "body"; + comp_obj_block.metainfo.is_of_type = "block"; + comp_obj_block.metainfo.is_a = "verse"; + comp_obj_block.metainfo.ocn = obj_cite_digits.on; + comp_obj_block.metainfo.object_number_off = (obj_cite_digits.off==0) ? "" : obj_cite_digits.off.to!string; + comp_obj_block.tags.html_segment_anchor_tag_is = tag_in_seg["seg_lv4"]; + comp_obj_block.tags.epub_segment_anchor_tag_is = tag_in_seg["seg_lv1_to_4"]; + comp_obj_block.metainfo.o_n_book_index = obj_cite_digits.bkidx; + comp_obj_block.metainfo.object_number_type = obj_cite_digits.type; + comp_obj_block.text = an_object["substantive"]; + comp_obj_block.has.inline_notes_reg = substantive_obj_misc_tuple[sObj.notes_reg]; + comp_obj_block.has.inline_notes_star = substantive_obj_misc_tuple[sObj.notes_star]; + comp_obj_block.has.inline_links = substantive_obj_misc_tuple[sObj.links]; + the_document_body_section ~= comp_obj_block; + tag_assoc = inline_para_link_anchor(an_object, tag_in_seg, tag_assoc); object_reset(an_object); processing.remove("verse"); ++cntr; @@ -4114,9 +4045,9 @@ void _table_closed_make_special_notation_table_(N,CMM)( auto comp_obj_location = node_construct.node_location_emitter( content_non_header, - segment_anchor_tag_that_object_belongs_to, + tag_in_seg, lev_anchor_tag, - tag_assoc_html, + tag_assoc, obj_cite_digits, cntr, heading_ptr-1, @@ -4125,15 +4056,16 @@ void _table_closed_make_special_notation_table_(N,CMM)( an_object["is"] = "table"; auto substantive_obj_misc_tuple = obj_im.obj_inline_markup_and_anchor_tags_and_misc(an_object, "body_nugget", conf_make_meta, false); - an_object["substantive"] = substantive_obj_misc_tuple[sObj.content]; - comp_obj_block.metainfo.ocn = obj_cite_digits.on; - comp_obj_block.metainfo.object_number_off = (obj_cite_digits.off==0) ? "" : obj_cite_digits.off.to!string; - comp_obj_block.tags.segment_anchor_tag_is = segment_anchor_tag_that_object_belongs_to["html"]; - comp_obj_block.metainfo.o_n_book_index = obj_cite_digits.bkidx; - comp_obj_block.metainfo.object_number_type = obj_cite_digits.type; - comp_obj_block = table_instructions(comp_obj_block, an_object["table_head"]); - comp_obj_block = table_substantive_munge_special(comp_obj_block, an_object["substantive"]); - the_document_body_section ~= comp_obj_block; + an_object["substantive"] = substantive_obj_misc_tuple[sObj.content]; + comp_obj_block.metainfo.ocn = obj_cite_digits.on; + comp_obj_block.metainfo.object_number_off = (obj_cite_digits.off==0) ? "" : obj_cite_digits.off.to!string; + comp_obj_block.tags.html_segment_anchor_tag_is = tag_in_seg["seg_lv4"]; + comp_obj_block.tags.epub_segment_anchor_tag_is = tag_in_seg["seg_lv1_to_4"]; + comp_obj_block.metainfo.o_n_book_index = obj_cite_digits.bkidx; + comp_obj_block.metainfo.object_number_type = obj_cite_digits.type; + comp_obj_block = table_instructions(comp_obj_block, an_object["table_head"]); + comp_obj_block = table_substantive_munge_special(comp_obj_block, an_object["substantive"]); + the_document_body_section ~= comp_obj_block; object_reset(an_object); processing.remove("verse"); ++cntr; @@ -4158,7 +4090,7 @@ void _block_flag_line_empty_(B,N,CMM,Ts)( return ref int[string] obj_type_status, string[string] object_number_poem, CMM conf_make_meta, - Ts segment_anchor_tag_that_object_belongs_to, + Ts tag_in_seg, ) { assert( line.empty, @@ -4184,15 +4116,15 @@ void _block_flag_line_empty_(B,N,CMM,Ts)( = bookindex_extract_hash.bookindex_nugget_hash( an_object["bookindex_nugget"], obj_cite_digits, - segment_anchor_tag_that_object_belongs_to + tag_in_seg ); an_object["is"] = "quote"; auto comp_obj_location = node_construct.node_location_emitter( content_non_header, - segment_anchor_tag_that_object_belongs_to, + tag_in_seg, lev_anchor_tag, - tag_assoc_html, + tag_assoc, obj_cite_digits, cntr, heading_ptr-1, @@ -4202,24 +4134,25 @@ void _block_flag_line_empty_(B,N,CMM,Ts)( = obj_im.obj_inline_markup_and_anchor_tags_and_misc(an_object, an_object_key, conf_make_meta, false); an_object["substantive"] = substantive_obj_misc_tuple[sObj.content]; anchor_tag = substantive_obj_misc_tuple[sObj.anchor_tag]; - tag_assoc_html = inline_para_link_anchor(an_object, segment_anchor_tag_that_object_belongs_to, tag_assoc_html); - comp_obj_block = comp_obj_block.init; - comp_obj_block.metainfo.is_of_part = "body"; - comp_obj_block.metainfo.is_of_section = "body"; - comp_obj_block.metainfo.is_of_type = "block"; - comp_obj_block.metainfo.is_a = "quote"; - comp_obj_block.metainfo.ocn = obj_cite_digits.on; - comp_obj_block.metainfo.object_number_off = (obj_cite_digits.off==0) ? "" : obj_cite_digits.off.to!string; - comp_obj_block.tags.segment_anchor_tag_is = segment_anchor_tag_that_object_belongs_to["html"]; - comp_obj_block.metainfo.o_n_book_index = obj_cite_digits.bkidx; - comp_obj_block.metainfo.object_number_type = obj_cite_digit_type; - comp_obj_block.text = an_object["substantive"]; - comp_obj_block.has.inline_notes_reg = substantive_obj_misc_tuple[sObj.notes_reg]; - comp_obj_block.has.inline_notes_star = substantive_obj_misc_tuple[sObj.notes_star]; - comp_obj_block.has.inline_links = substantive_obj_misc_tuple[sObj.links]; - the_document_body_section ~= comp_obj_block; - obj_type_status["blocks"] = TriState.off; - obj_type_status["quote"] = TriState.off; + comp_obj_block = comp_obj_block.init; + comp_obj_block.metainfo.is_of_part = "body"; + comp_obj_block.metainfo.is_of_section = "body"; + comp_obj_block.metainfo.is_of_type = "block"; + comp_obj_block.metainfo.is_a = "quote"; + comp_obj_block.metainfo.ocn = obj_cite_digits.on; + comp_obj_block.metainfo.object_number_off = (obj_cite_digits.off==0) ? "" : obj_cite_digits.off.to!string; + comp_obj_block.tags.html_segment_anchor_tag_is = tag_in_seg["seg_lv4"]; + comp_obj_block.tags.epub_segment_anchor_tag_is = tag_in_seg["seg_lv1_to_4"]; + comp_obj_block.metainfo.o_n_book_index = obj_cite_digits.bkidx; + comp_obj_block.metainfo.object_number_type = obj_cite_digit_type; + comp_obj_block.text = an_object["substantive"]; + comp_obj_block.has.inline_notes_reg = substantive_obj_misc_tuple[sObj.notes_reg]; + comp_obj_block.has.inline_notes_star = substantive_obj_misc_tuple[sObj.notes_star]; + comp_obj_block.has.inline_links = substantive_obj_misc_tuple[sObj.links]; + the_document_body_section ~= comp_obj_block; + tag_assoc = inline_para_link_anchor(an_object, tag_in_seg, tag_assoc); + obj_type_status["blocks"] = TriState.off; + obj_type_status["quote"] = TriState.off; object_reset(an_object); processing.remove("verse"); ++cntr; @@ -4237,15 +4170,15 @@ void _block_flag_line_empty_(B,N,CMM,Ts)( = bookindex_extract_hash.bookindex_nugget_hash( an_object["bookindex_nugget"], obj_cite_digits, - segment_anchor_tag_that_object_belongs_to + tag_in_seg ); an_object["is"] = "group"; auto comp_obj_location = node_construct.node_location_emitter( content_non_header, - segment_anchor_tag_that_object_belongs_to, + tag_in_seg, lev_anchor_tag, - tag_assoc_html, + tag_assoc, obj_cite_digits, cntr, heading_ptr-1, @@ -4255,24 +4188,25 @@ void _block_flag_line_empty_(B,N,CMM,Ts)( = obj_im.obj_inline_markup_and_anchor_tags_and_misc(an_object, an_object_key, conf_make_meta, false); an_object["substantive"] = substantive_obj_misc_tuple[sObj.content]; anchor_tag = substantive_obj_misc_tuple[sObj.anchor_tag]; - tag_assoc_html = inline_para_link_anchor(an_object, segment_anchor_tag_that_object_belongs_to, tag_assoc_html); - comp_obj_block = comp_obj_block.init; - comp_obj_block.metainfo.is_of_part = "body"; - comp_obj_block.metainfo.is_of_section = "body"; - comp_obj_block.metainfo.is_of_type = "block"; - comp_obj_block.metainfo.is_a = "group"; - comp_obj_block.metainfo.ocn = obj_cite_digits.on; - comp_obj_block.metainfo.object_number_off = (obj_cite_digits.off==0) ? "" : obj_cite_digits.off.to!string; - comp_obj_block.tags.segment_anchor_tag_is = segment_anchor_tag_that_object_belongs_to["html"]; - comp_obj_block.metainfo.o_n_book_index = obj_cite_digits.bkidx; - comp_obj_block.metainfo.object_number_type = obj_cite_digits.type; - comp_obj_block.text = an_object["substantive"]; - comp_obj_block.has.inline_notes_reg = substantive_obj_misc_tuple[sObj.notes_reg]; - comp_obj_block.has.inline_notes_star = substantive_obj_misc_tuple[sObj.notes_star]; - comp_obj_block.has.inline_links = substantive_obj_misc_tuple[sObj.links]; - the_document_body_section ~= comp_obj_block; - obj_type_status["blocks"] = TriState.off; - obj_type_status["group"] = TriState.off; + comp_obj_block = comp_obj_block.init; + comp_obj_block.metainfo.is_of_part = "body"; + comp_obj_block.metainfo.is_of_section = "body"; + comp_obj_block.metainfo.is_of_type = "block"; + comp_obj_block.metainfo.is_a = "group"; + comp_obj_block.metainfo.ocn = obj_cite_digits.on; + comp_obj_block.metainfo.object_number_off = (obj_cite_digits.off==0) ? "" : obj_cite_digits.off.to!string; + comp_obj_block.tags.html_segment_anchor_tag_is = tag_in_seg["seg_lv4"]; + comp_obj_block.tags.epub_segment_anchor_tag_is = tag_in_seg["seg_lv1_to_4"]; + comp_obj_block.metainfo.o_n_book_index = obj_cite_digits.bkidx; + comp_obj_block.metainfo.object_number_type = obj_cite_digits.type; + comp_obj_block.text = an_object["substantive"]; + comp_obj_block.has.inline_notes_reg = substantive_obj_misc_tuple[sObj.notes_reg]; + comp_obj_block.has.inline_notes_star = substantive_obj_misc_tuple[sObj.notes_star]; + comp_obj_block.has.inline_links = substantive_obj_misc_tuple[sObj.links]; + the_document_body_section ~= comp_obj_block; + tag_assoc = inline_para_link_anchor(an_object, tag_in_seg, tag_assoc); + obj_type_status["blocks"] = TriState.off; + obj_type_status["group"] = TriState.off; object_reset(an_object); processing.remove("verse"); ++cntr; @@ -4290,15 +4224,15 @@ void _block_flag_line_empty_(B,N,CMM,Ts)( = bookindex_extract_hash.bookindex_nugget_hash( an_object["bookindex_nugget"], obj_cite_digits, - segment_anchor_tag_that_object_belongs_to + tag_in_seg ); an_object["is"] = "block"; auto comp_obj_location = node_construct.node_location_emitter( content_non_header, - segment_anchor_tag_that_object_belongs_to, + tag_in_seg, lev_anchor_tag, - tag_assoc_html, + tag_assoc, obj_cite_digits, cntr, heading_ptr-1, @@ -4306,24 +4240,26 @@ void _block_flag_line_empty_(B,N,CMM,Ts)( ); auto substantive_obj_misc_tuple = obj_im.obj_inline_markup_and_anchor_tags_and_misc(an_object, an_object_key, conf_make_meta, false); - an_object["substantive"] = substantive_obj_misc_tuple[sObj.content]; - comp_obj_block = comp_obj_block.init; - comp_obj_block.metainfo.is_of_part = "body"; - comp_obj_block.metainfo.is_of_section = "body"; - comp_obj_block.metainfo.is_of_type = "block"; - comp_obj_block.metainfo.is_a = "block"; - comp_obj_block.metainfo.ocn = obj_cite_digits.on; - comp_obj_block.metainfo.object_number_off = (obj_cite_digits.off==0) ? "" : obj_cite_digits.off.to!string; - comp_obj_block.tags.segment_anchor_tag_is = segment_anchor_tag_that_object_belongs_to["html"]; - comp_obj_block.metainfo.o_n_book_index = obj_cite_digits.bkidx; - comp_obj_block.metainfo.object_number_type = obj_cite_digit_type; - comp_obj_block.text = an_object["substantive"]; - comp_obj_block.has.inline_notes_reg = substantive_obj_misc_tuple[sObj.notes_reg]; - comp_obj_block.has.inline_notes_star = substantive_obj_misc_tuple[sObj.notes_star]; - comp_obj_block.has.inline_links = substantive_obj_misc_tuple[sObj.links]; - the_document_body_section ~= comp_obj_block; - obj_type_status["blocks"] = TriState.off; - obj_type_status["block"] = TriState.off; + an_object["substantive"] = substantive_obj_misc_tuple[sObj.content]; + // anchor_tag = substantive_obj_misc_tuple[sObj.anchor_tag]; + comp_obj_block = comp_obj_block.init; + comp_obj_block.metainfo.is_of_part = "body"; + comp_obj_block.metainfo.is_of_section = "body"; + comp_obj_block.metainfo.is_of_type = "block"; + comp_obj_block.metainfo.is_a = "block"; + comp_obj_block.metainfo.ocn = obj_cite_digits.on; + comp_obj_block.metainfo.object_number_off = (obj_cite_digits.off==0) ? "" : obj_cite_digits.off.to!string; + comp_obj_block.tags.html_segment_anchor_tag_is = tag_in_seg["seg_lv4"]; + comp_obj_block.tags.epub_segment_anchor_tag_is = tag_in_seg["seg_lv1_to_4"]; + comp_obj_block.metainfo.o_n_book_index = obj_cite_digits.bkidx; + comp_obj_block.metainfo.object_number_type = obj_cite_digit_type; + comp_obj_block.text = an_object["substantive"]; + comp_obj_block.has.inline_notes_reg = substantive_obj_misc_tuple[sObj.notes_reg]; + comp_obj_block.has.inline_notes_star = substantive_obj_misc_tuple[sObj.notes_star]; + comp_obj_block.has.inline_links = substantive_obj_misc_tuple[sObj.links]; + the_document_body_section ~= comp_obj_block; + obj_type_status["blocks"] = TriState.off; + obj_type_status["block"] = TriState.off; object_reset(an_object); processing.remove("verse"); ++cntr; @@ -4340,15 +4276,15 @@ void _block_flag_line_empty_(B,N,CMM,Ts)( = bookindex_extract_hash.bookindex_nugget_hash( an_object["bookindex_nugget"], obj_cite_digits, - segment_anchor_tag_that_object_belongs_to + tag_in_seg ); an_object["is"] = "verse"; auto comp_obj_location = node_construct.node_location_emitter( content_non_header, - segment_anchor_tag_that_object_belongs_to, + tag_in_seg, lev_anchor_tag, - tag_assoc_html, + tag_assoc, obj_cite_digits, cntr, heading_ptr-1, @@ -4383,15 +4319,15 @@ void _block_flag_line_empty_(B,N,CMM,Ts)( = bookindex_extract_hash.bookindex_nugget_hash( an_object["bookindex_nugget"], obj_cite_digits, - segment_anchor_tag_that_object_belongs_to + tag_in_seg ); an_object["is"] = "code"; auto comp_obj_location = node_construct.node_location_emitter( content_non_header, - segment_anchor_tag_that_object_belongs_to, + tag_in_seg, lev_anchor_tag, - tag_assoc_html, + tag_assoc, obj_cite_digits, cntr, heading_ptr-1, @@ -4401,23 +4337,24 @@ void _block_flag_line_empty_(B,N,CMM,Ts)( = obj_im.obj_inline_markup_and_anchor_tags_and_misc(an_object, an_object_key, conf_make_meta, false); an_object["substantive"] = substantive_obj_misc_tuple[sObj.content]; anchor_tag = substantive_obj_misc_tuple[sObj.anchor_tag]; - comp_obj_code = comp_obj_code.init; - comp_obj_code.metainfo.is_of_part = "body"; - comp_obj_code.metainfo.is_of_section = "body"; - comp_obj_code.metainfo.is_of_type = "block"; - comp_obj_code.metainfo.is_a = "code"; - comp_obj_code.metainfo.ocn = obj_cite_digits.on; - comp_obj_code.metainfo.object_number_off = (obj_cite_digits.off==0) ? "" : obj_cite_digits.off.to!string; - comp_obj_code.tags.segment_anchor_tag_is = segment_anchor_tag_that_object_belongs_to["html"]; - comp_obj_code.metainfo.o_n_book_index = obj_cite_digits.bkidx; - comp_obj_code.metainfo.object_number_type = obj_cite_digits.type; - comp_obj_code.text = an_object["substantive"]; - comp_obj_code.has.inline_notes_reg = substantive_obj_misc_tuple[sObj.notes_reg]; - comp_obj_code.has.inline_notes_star = substantive_obj_misc_tuple[sObj.notes_star]; - comp_obj_code.has.inline_links = substantive_obj_misc_tuple[sObj.links]; - the_document_body_section ~= comp_obj_code; - obj_type_status["blocks"] = TriState.off; - obj_type_status["code"] = TriState.off; + comp_obj_code = comp_obj_code.init; + comp_obj_code.metainfo.is_of_part = "body"; + comp_obj_code.metainfo.is_of_section = "body"; + comp_obj_code.metainfo.is_of_type = "block"; + comp_obj_code.metainfo.is_a = "code"; + comp_obj_code.metainfo.ocn = obj_cite_digits.on; + comp_obj_code.metainfo.object_number_off = (obj_cite_digits.off==0) ? "" : obj_cite_digits.off.to!string; + comp_obj_code.tags.html_segment_anchor_tag_is = tag_in_seg["seg_lv4"]; + comp_obj_code.tags.epub_segment_anchor_tag_is = tag_in_seg["seg_lv1_to_4"]; + comp_obj_code.metainfo.o_n_book_index = obj_cite_digits.bkidx; + comp_obj_code.metainfo.object_number_type = obj_cite_digits.type; + comp_obj_code.text = an_object["substantive"]; + comp_obj_code.has.inline_notes_reg = substantive_obj_misc_tuple[sObj.notes_reg]; + comp_obj_code.has.inline_notes_star = substantive_obj_misc_tuple[sObj.notes_star]; + comp_obj_code.has.inline_links = substantive_obj_misc_tuple[sObj.links]; + the_document_body_section ~= comp_obj_code; + obj_type_status["blocks"] = TriState.off; + obj_type_status["code"] = TriState.off; object_reset(an_object); processing.remove("verse"); ++cntr; @@ -4436,15 +4373,15 @@ void _block_flag_line_empty_(B,N,CMM,Ts)( = bookindex_extract_hash.bookindex_nugget_hash( an_object["bookindex_nugget"], obj_cite_digits, - segment_anchor_tag_that_object_belongs_to + tag_in_seg ); an_object["is"] = "table"; auto comp_obj_location = node_construct.node_location_emitter( content_non_header, - segment_anchor_tag_that_object_belongs_to, + tag_in_seg, lev_anchor_tag, - tag_assoc_html, + tag_assoc, obj_cite_digits, cntr, heading_ptr-1, @@ -4452,18 +4389,19 @@ void _block_flag_line_empty_(B,N,CMM,Ts)( ); auto substantive_obj_misc_tuple = obj_im.obj_inline_markup_and_anchor_tags_and_misc(an_object, an_object_key, conf_make_meta, false); - an_object["substantive"] = substantive_obj_misc_tuple[sObj.content]; - comp_obj_block = comp_obj_block.init; - comp_obj_block.metainfo.ocn = obj_cite_digits.on; - comp_obj_block.metainfo.object_number_off = (obj_cite_digits.off==0) ? "" : obj_cite_digits.off.to!string; - comp_obj_block.tags.segment_anchor_tag_is = segment_anchor_tag_that_object_belongs_to["html"]; - comp_obj_block.metainfo.o_n_book_index = obj_cite_digits.bkidx; - comp_obj_block.metainfo.object_number_type = obj_cite_digits.type; - comp_obj_block = table_instructions(comp_obj_block, an_object["table_head"]); - comp_obj_block = table_substantive_munge(comp_obj_block, an_object["substantive"]); - the_document_body_section ~= comp_obj_block; - obj_type_status["blocks"] = TriState.off; - obj_type_status["table"] = TriState.off; + an_object["substantive"] = substantive_obj_misc_tuple[sObj.content]; + comp_obj_block = comp_obj_block.init; + comp_obj_block.metainfo.ocn = obj_cite_digits.on; + comp_obj_block.metainfo.object_number_off = (obj_cite_digits.off==0) ? "" : obj_cite_digits.off.to!string; + comp_obj_block.tags.html_segment_anchor_tag_is = tag_in_seg["seg_lv4"]; + comp_obj_block.tags.epub_segment_anchor_tag_is = tag_in_seg["seg_lv1_to_4"]; + comp_obj_block.metainfo.o_n_book_index = obj_cite_digits.bkidx; + comp_obj_block.metainfo.object_number_type = obj_cite_digits.type; + comp_obj_block = table_instructions(comp_obj_block, an_object["table_head"]); + comp_obj_block = table_substantive_munge(comp_obj_block, an_object["substantive"]); + the_document_body_section ~= comp_obj_block; + obj_type_status["blocks"] = TriState.off; + obj_type_status["table"] = TriState.off; object_reset(an_object); processing.remove("verse"); ++cntr; @@ -5858,18 +5796,18 @@ static struct ObjInlineMarkup { auto table_of_contents_gather_headings(O,CMM,Ts,Ta,X,Toc)( O obj_, CMM conf_make_meta, - Ts segment_anchor_tag_that_object_belongs_to, + Ts tag_in_seg, Ta _anchor_tag, return ref X lev4_subtoc, Toc the_table_of_contents_section, ) in { debug(asserts) { - static assert(is(typeof(obj_) == string[string])); - static assert(is(typeof(segment_anchor_tag_that_object_belongs_to) == string[string])); - static assert(is(typeof(_anchor_tag) == string)); - static assert(is(typeof(lev4_subtoc) == string[][string])); - static assert(is(typeof(the_table_of_contents_section) == ObjGenericComposite[][string])); + static assert(is(typeof(obj_) == string[string])); + static assert(is(typeof(tag_in_seg) == string[string])); + static assert(is(typeof(_anchor_tag) == string)); + static assert(is(typeof(lev4_subtoc) == string[][string])); + static assert(is(typeof(the_table_of_contents_section) == ObjGenericComposite[])); } } body { @@ -5905,7 +5843,7 @@ static struct ObjInlineMarkup { comp_obj_toc.attrib.bullet = false; comp_obj_toc.text = toc_txt_.to!string.strip; comp_obj_toc.has.inline_links = true; - the_table_of_contents_section["scroll"] ~= comp_obj_toc; + the_table_of_contents_section ~= comp_obj_toc; } else { indent=[ "hang_position" : 0, @@ -5924,7 +5862,7 @@ static struct ObjInlineMarkup { comp_obj_toc.attrib.bullet = false; comp_obj_toc.text = "Table of Contents"; comp_obj_toc.has.inline_links = true; - the_table_of_contents_section["scroll"] ~= comp_obj_toc; + the_table_of_contents_section ~= comp_obj_toc; } comp_obj_toc = comp_obj_toc.init; comp_obj_toc.metainfo.is_of_part = "frontmatter"; @@ -5937,83 +5875,21 @@ static struct ObjInlineMarkup { comp_obj_toc.attrib.bullet = false; comp_obj_toc.has.inline_links = true; switch (obj_["lev_markup_number"].to!int) { - case 0: - indent=[ - "hang_position" : 0, - "base_position" : 0, - ]; - toc_txt_ = "{ Table of Contents }" ~ mkup.mark_internal_site_lnk ~ "toc.fnSuffix"; - toc_txt_= munge.url_links(toc_txt_); - comp_obj_toc.attrib.indent_hang = indent["hang_position"]; - comp_obj_toc.attrib.indent_base = indent["base_position"]; - comp_obj_toc.text = toc_txt_.to!string.strip; - comp_obj_toc.has.inline_links = true; - the_table_of_contents_section["seg"] ~= comp_obj_toc; - break; - case 1: .. case 3: - indent=[ - "hang_position" : obj_["lev_markup_number"].to!int, - "base_position" : obj_["lev_markup_number"].to!int, - ]; - toc_txt_ = format( - "%s", - heading_toc_, - ); - toc_txt_= munge.url_links(toc_txt_); - comp_obj_toc.attrib.indent_hang = indent["hang_position"]; - comp_obj_toc.attrib.indent_base = indent["base_position"]; - comp_obj_toc.text = toc_txt_.to!string.strip; - comp_obj_toc.has.inline_links = true; - the_table_of_contents_section["seg"] ~= comp_obj_toc; + case 0: .. case 3: break; case 4: - toc_txt_ = format( - "{ %s }%s%s%s", - heading_toc_, - mkup.mark_internal_site_lnk, - segment_anchor_tag_that_object_belongs_to["html"], - ".fnSuffix", - ); - lev4_subtoc[segment_anchor_tag_that_object_belongs_to["html"]] = []; - toc_txt_= munge.url_links(toc_txt_); - indent=[ - "hang_position" : obj_["lev_markup_number"].to!int, - "base_position" : obj_["lev_markup_number"].to!int, - ]; - comp_obj_toc.attrib.indent_hang = indent["hang_position"]; - comp_obj_toc.attrib.indent_base = indent["base_position"]; - comp_obj_toc.text = toc_txt_.to!string.strip; - comp_obj_toc.has.inline_links = true; - the_table_of_contents_section["seg"] ~= comp_obj_toc; + lev4_subtoc[tag_in_seg["seg_lv4"]] = []; break; case 5: .. case 7: - toc_txt_ = format( - "{ %s }%s%s%s#%s", - heading_toc_, - mkup.mark_internal_site_lnk, - segment_anchor_tag_that_object_belongs_to["html"], - ".fnSuffix", - _anchor_tag, - ); subtoc_txt_ = format( "{ %s }#%s", heading_toc_, _anchor_tag, ); - lev4_subtoc[segment_anchor_tag_that_object_belongs_to["html"]] + lev4_subtoc[tag_in_seg["seg_lv4"]] ~= munge.url_links(obj_["lev_markup_number"] ~ "~ " ~ subtoc_txt_.to!string.strip ); - toc_txt_= munge.url_links(toc_txt_); - indent=[ - "hang_position" : obj_["lev_markup_number"].to!int, - "base_position" : obj_["lev_markup_number"].to!int, - ]; - comp_obj_toc.attrib.indent_hang = indent["hang_position"]; - comp_obj_toc.attrib.indent_base = indent["base_position"]; - comp_obj_toc.text = toc_txt_.to!string.strip; - comp_obj_toc.has.inline_links = true; - the_table_of_contents_section["seg"] ~= comp_obj_toc; break; default: break; @@ -6037,6 +5913,7 @@ private: #+BEGIN_SRC d static int[] heading_num = [ 0, 0, 0, 0 ]; static string heading_number_auto_composite = ""; + static string heading_number_auto_composite_segname = ""; static string _configured_auto_heading_numbering_and_segment_anchor_tags(M,O,CMM)( M munge_, O obj_, @@ -6130,6 +6007,10 @@ private: } else { heading_number_auto_composite = ""; } + heading_number_auto_composite_segname = + (heading_number_auto_composite.empty) + ? "" + : "seg_" ~ heading_number_auto_composite; debug(heading_number_auto) { writeln(heading_number_auto_composite); } @@ -6139,7 +6020,7 @@ private: .replaceFirst(rgx.heading, "$1~$2 " ~ heading_number_auto_composite ~ ". ") .replaceFirst(rgx.heading_marker_missing_tag, - "$1~" ~ heading_number_auto_composite ~ " "); + "$1~" ~ heading_number_auto_composite_segname ~ " "); } } return munge_; @@ -6611,7 +6492,7 @@ struct BookIndexNuggetHash { string[][string][string] bookindex_nugget_hash(BI,N,S)( BI bookindex_section, N obj_cite_digits, - S segment_anchor_tag_that_object_belongs_to, + S tag_in_seg, ) in { debug(asserts) { @@ -6622,7 +6503,9 @@ struct BookIndexNuggetHash { if (!bookindex_section.empty) { writeln( "* [bookindex] ", - "[", obj_cite_digits.on.to!string, ": ", segment_anchor_tag_that_object_belongs_to["html"], "] ", bookindex_section + "[", obj_cite_digits.on.to!string, ": ", tag_in_seg["seg_lv4"], "] ", bookindex_section, + " - - - ", + "[", obj_cite_digits.on.to!string, "] ", bookindex_section ); } } @@ -6642,15 +6525,13 @@ struct BookIndexNuggetHash { object_number_offset = m.captures[2].to!int; object_number_endpoint=(obj_cite_digits.on + object_number_offset); object_numbers ~= (obj_cite_digits.on.to!string - ~ "-" ~ object_number_endpoint.to!string - ~ ":" ~ segment_anchor_tag_that_object_belongs_to["html"]); + ~ "-" ~ object_number_endpoint.to!string); } else { main_term = bi_main_term_and_rest[0].strip; - object_numbers ~= obj_cite_digits.on.to!string - ~ ":" ~ segment_anchor_tag_that_object_belongs_to["html"]; + object_numbers ~= obj_cite_digits.on.to!string; } bi[main_term]["_a"] ~= object_numbers; - object_numbers=null; + object_numbers = null; if (bi_main_term_and_rest.length > 1) { auto bi_sub_terms_split_arr = bi_main_term_and_rest[1].split( @@ -6662,12 +6543,10 @@ struct BookIndexNuggetHash { object_number_offset = m.captures[2].to!int; object_number_endpoint=(obj_cite_digits.on + object_number_offset); object_numbers ~= (obj_cite_digits.on.to!string - ~ " - " ~ object_number_endpoint.to!string - ~ ":" ~ segment_anchor_tag_that_object_belongs_to["html"]); + ~ " - " ~ object_number_endpoint.to!string); } else { sub_term = sub_terms_bits.strip; - object_numbers ~= obj_cite_digits.on.to!string - ~ ":" ~ segment_anchor_tag_that_object_belongs_to["html"]; + object_numbers ~= obj_cite_digits.on.to!string; } if (!empty(sub_term)) { bi[main_term][sub_term] ~= object_numbers; @@ -6789,14 +6668,14 @@ struct BookIndexReportSection { int[string] indent; auto mainkeys = bookindex_unordered_hashes.byKey.array.sort().release; - ObjGenericComposite[][string] bookindex_section; + ObjGenericComposite[] bookindex_section; ObjGenericComposite comp_obj_heading_, comp_obj_para; auto node_para_int_ = node_metadata_para_int; auto node_para_str_ = node_metadata_para_str; if ((mainkeys.length > 0) && (opt_action.backmatter && opt_action.section_bookindex)) { - string bi_tmp_seg, bi_tmp_scroll; + string bi_tmp; string[] bi_tmp_tags; comp_obj_heading_ = comp_obj_heading_.init; comp_obj_heading_.metainfo.is_of_part = "backmatter"; @@ -6807,15 +6686,17 @@ struct BookIndexReportSection { 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_html = "_part_book_index"; - comp_obj_heading_.tags.segment_anchor_tag_epub = comp_obj_heading_.tags.segment_anchor_tag_html; + comp_obj_heading_.tags.segment_anchor_tag_epub = "_part_book_index"; + comp_obj_heading_.tags.anchor_tag_html = comp_obj_heading_.tags.segment_anchor_tag_epub; + comp_obj_heading_.tags.in_segment_html = "bookindex"; 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.has.inline_links = true; - bookindex_section["scroll"] ~= comp_obj_heading_; - bookindex_section["seg"] ~= comp_obj_heading_; + bookindex_section ~= comp_obj_heading_; + tag_assoc[comp_obj_heading_.tags.anchor_tag_html]["seg_lv4"] = comp_obj_heading_.tags.in_segment_html; + tag_assoc[comp_obj_heading_.tags.segment_anchor_tag_epub]["seg_lv1_to_4"] = comp_obj_heading_.tags.segment_anchor_tag_epub; ++mkn; comp_obj_heading_ = comp_obj_heading_.init; comp_obj_heading_.metainfo.is_of_part = "backmatter"; @@ -6826,44 +6707,32 @@ struct BookIndexReportSection { 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_html = "bookindex"; - comp_obj_heading_.tags.segment_anchor_tag_epub = comp_obj_heading_.tags.segment_anchor_tag_html; + comp_obj_heading_.tags.segment_anchor_tag_epub = "bookindex"; + comp_obj_heading_.tags.anchor_tag_html = comp_obj_heading_.tags.segment_anchor_tag_epub; + comp_obj_heading_.tags.in_segment_html = comp_obj_heading_.tags.anchor_tag_html; 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.has.inline_links = false; comp_obj_heading_.tags.anchor_tags = ["bookindex"]; - bookindex_section["scroll"] ~= comp_obj_heading_; - bookindex_section["seg"] ~= comp_obj_heading_; + bookindex_section ~= comp_obj_heading_; + tag_assoc[comp_obj_heading_.tags.anchor_tag_html]["seg_lv4"] = comp_obj_heading_.tags.in_segment_html; + tag_assoc[comp_obj_heading_.tags.segment_anchor_tag_epub]["seg_lv1_to_4"] = comp_obj_heading_.tags.segment_anchor_tag_epub; ++mkn; import std.array : appender; auto buffer = appender!(char[])(); string[dchar] transTable = [' ' : "_"]; foreach (mainkey; mainkeys) { bi_tmp_tags = [""]; - bi_tmp_scroll = "!{" ~ mainkey ~ "}! "; + bi_tmp = "!{" ~ mainkey ~ "}! "; buffer.clear(); bi_tmp_tags ~= translate(mainkey, transTable); - bi_tmp_seg = "!{" ~ mainkey ~ "}! "; - auto bkidx_lnk_seg(string locs) { - string markup = ""; - if (auto m = locs.matchFirst(rgx.book_index_go_seg)) { - markup - = munge.url_links("{ " ~ m["link"] ~ " }" - ~ mkup.mark_internal_site_lnk ~ m["seg"] ~ ".fnSuffix" - ~ "#" ~ m["ocn"] ~ ", "); - } else { - writeln(__LINE__, ": ", locs); - } - return markup; - } - auto bkidx_lnk_scroll(string locs) { + auto bkidx_lnk(string locs) { string markup = ""; if (auto m = locs.matchFirst(rgx.book_index_go)) { markup = munge.url_links("{ " ~ m["link"] ~ " }" - ~ mkup.mark_internal_site_lnk ~ "#" ~ m["ocn"] ~ ", "); } else { writeln(__LINE__, ": ", locs); @@ -6871,35 +6740,29 @@ struct BookIndexReportSection { return markup; } foreach (ref_; bookindex_unordered_hashes[mainkey]["_a"]) { - bi_tmp_scroll ~= bkidx_lnk_scroll(ref_); - bi_tmp_seg ~= bkidx_lnk_seg(ref_); + bi_tmp ~= bkidx_lnk(ref_); } - bi_tmp_scroll ~= " \\\\\n "; - bi_tmp_seg ~= " \\\\\n "; + bi_tmp ~= " \\\\\n "; bookindex_unordered_hashes[mainkey].remove("_a"); auto subkeys = bookindex_unordered_hashes[mainkey].byKey.array.sort().release; foreach (subkey; subkeys) { - bi_tmp_scroll ~= subkey ~ ", "; + bi_tmp ~= subkey ~ ", "; buffer.clear(); bi_tmp_tags ~= translate(subkey, transTable); - bi_tmp_seg ~= subkey ~ ", "; foreach (ref_; bookindex_unordered_hashes[mainkey][subkey]) { - bi_tmp_scroll ~= bkidx_lnk_scroll(ref_); - bi_tmp_seg ~= bkidx_lnk_seg(ref_); + bi_tmp ~= bkidx_lnk(ref_); } - bi_tmp_scroll ~= " \\\\\n "; - bi_tmp_seg ~= " \\\\\n "; + bi_tmp ~= " \\\\\n "; ++skn; } - bi_tmp_scroll = (bi_tmp_scroll).replaceFirst(rgx.trailing_linebreak, ""); - bi_tmp_seg = (bi_tmp_seg).replaceFirst(rgx.trailing_linebreak, ""); + bi_tmp = (bi_tmp).replaceFirst(rgx.trailing_linebreak, ""); comp_obj_para = comp_obj_para.init; comp_obj_para.metainfo.is_of_part = "backmatter"; comp_obj_para.metainfo.is_of_section = "bookindex"; comp_obj_para.metainfo.is_of_type = "para"; comp_obj_para.metainfo.is_a = "bookindex"; - comp_obj_para.text = bi_tmp_scroll.to!string.strip; + comp_obj_para.text = bi_tmp.to!string.strip; comp_obj_para.metainfo.ocn = 0; comp_obj_para.metainfo.object_number_off = ""; comp_obj_para.metainfo.object_number_type = 0; @@ -6908,9 +6771,8 @@ struct BookIndexReportSection { comp_obj_para.attrib.indent_base = 1; comp_obj_para.attrib.bullet = false; comp_obj_para.has.inline_links = true; - bookindex_section["scroll"] ~= comp_obj_para; - comp_obj_para.text = bi_tmp_seg.to!string.strip; - bookindex_section["seg"] ~= comp_obj_para; + comp_obj_para.text = bi_tmp.to!string.strip; + bookindex_section ~= comp_obj_para; ++mkn; } } else { // no book index, (figure out what to do here) @@ -6923,8 +6785,7 @@ struct BookIndexReportSection { comp_obj_heading_.metainfo.heading_lev_collapsed = 1; comp_obj_heading_.metainfo.parent_ocn = 1; comp_obj_heading_.metainfo.parent_lev_markup = 0; - bookindex_section["scroll"] ~= comp_obj_heading_; - bookindex_section["seg"] ~= comp_obj_heading_; + bookindex_section ~= comp_obj_heading_; } auto t = tuple( bookindex_section, @@ -6958,7 +6819,7 @@ struct NotesSection { #+BEGIN_SRC d private auto gather_notes_for_endnote_section( ObjGenericComposite[] contents_am, - string[string] segment_anchor_tag_that_object_belongs_to, + string[string] tag_in_seg, int cntr, ) in { @@ -6989,13 +6850,13 @@ struct NotesSection { writeln( "{^{", m.captures[1], ".}^}" ~ mkup.mark_internal_site_lnk, - segment_anchor_tag_that_object_belongs_to["html"], + tag_in_seg["seg_lv4"], ".fnSuffix#noteref_\n ", m.captures[1], " ", m.captures[2]); // sometimes need segment name (segmented html & epub) } // you need anchor for segments at this point -> object_notes["anchor"] ~= "note_" ~ m.captures[1] ~ "』"; - object_notes["notes"] ~= (segment_anchor_tag_that_object_belongs_to["html"].empty) + object_notes["notes"] ~= (tag_in_seg["seg_lv4"].empty) ? (munge.url_links( "{^{" ~ m.captures[1] ~ ".}^}#noteref_" ~ m.captures[1]) ~ " " @@ -7004,7 +6865,7 @@ struct NotesSection { : (munge.url_links( "{^{" ~ m.captures[1] ~ ".}^}" ~ mkup.mark_internal_site_lnk - ~ segment_anchor_tag_that_object_belongs_to["html"] + ~ tag_in_seg["seg_lv4"] ~ ".fnSuffix#noteref_" ~ m.captures[1]) ~ " " ~ m.captures[2] ~ "』" @@ -7064,13 +6925,16 @@ struct NotesSection { 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_html = "_part_endnotes"; - comp_obj_heading_.tags.segment_anchor_tag_epub = comp_obj_heading_.tags.segment_anchor_tag_html; + comp_obj_heading_.tags.segment_anchor_tag_epub = "_part_endnotes"; + comp_obj_heading_.tags.anchor_tag_html = comp_obj_heading_.tags.segment_anchor_tag_epub; + comp_obj_heading_.tags.in_segment_html = "endnotes"; 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; the_endnotes_section ~= comp_obj_heading_; + tag_assoc[comp_obj_heading_.tags.anchor_tag_html]["seg_lv4"] = comp_obj_heading_.tags.in_segment_html; + tag_assoc[comp_obj_heading_.tags.segment_anchor_tag_epub]["seg_lv1_to_4"] = comp_obj_heading_.tags.segment_anchor_tag_epub; ++mkn; comp_obj_heading_ = comp_obj_heading_.init; comp_obj_heading_.metainfo.is_of_part = "backmatter"; @@ -7081,14 +6945,17 @@ struct NotesSection { 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_html = "endnotes"; - comp_obj_heading_.tags.segment_anchor_tag_epub = comp_obj_heading_.tags.segment_anchor_tag_html; + comp_obj_heading_.tags.segment_anchor_tag_epub = "endnotes"; + comp_obj_heading_.tags.anchor_tag_html = comp_obj_heading_.tags.segment_anchor_tag_epub; + comp_obj_heading_.tags.in_segment_html = comp_obj_heading_.tags.anchor_tag_html; 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 = ["endnotes"]; the_endnotes_section ~= comp_obj_heading_; + tag_assoc[comp_obj_heading_.tags.anchor_tag_html]["seg_lv4"] = comp_obj_heading_.tags.in_segment_html; + tag_assoc[comp_obj_heading_.tags.segment_anchor_tag_epub]["seg_lv1_to_4"] = comp_obj_heading_.tags.segment_anchor_tag_epub; ++mkn; } else { comp_obj_heading_ = comp_obj_heading_.init; @@ -7295,9 +7162,9 @@ struct NodeStructureMetadata { #+BEGIN_SRC d ObjGenericComposite node_location_emitter(Lv,Tg,La,Ta,N,C,P,I)( Lv lev_markup_number, - Tg segment_anchor_tag_that_object_belongs_to, + Tg tag_in_seg, La lev_anchor_tag, - Ta tag_assoc_html, + Ta tag_assoc, N obj_cite_digits, C cntr_, P ptr_, @@ -7305,12 +7172,12 @@ struct NodeStructureMetadata { ) in { debug(asserts) { - static assert(is(typeof(lev_markup_number) == string)); - static assert(is(typeof(segment_anchor_tag_that_object_belongs_to) == string[string])); - static assert(is(typeof(obj_cite_digits.on) == int)); - static assert(is(typeof(cntr_) == int)); - static assert(is(typeof(ptr_) == int)); - static assert(is(typeof(is_) == string)); + static assert(is(typeof(lev_markup_number) == string)); + static assert(is(typeof(tag_in_seg) == string[string])); + static assert(is(typeof(obj_cite_digits.on) == int)); + static assert(is(typeof(cntr_) == int)); + static assert(is(typeof(ptr_) == int)); + static assert(is(typeof(is_) == string)); } assert(is_ != "heading"); assert(obj_cite_digits.on.to!int >= 0); @@ -7332,14 +7199,14 @@ struct NodeStructureMetadata { p_["object_number"] = lv4; } ObjGenericComposite comp_obj_location; - comp_obj_location = comp_obj_location.init; - comp_obj_location.metainfo.is_a = is_; - comp_obj_location.metainfo.ocn = obj_cite_digits.on; - comp_obj_location.tags.segment_anchor_tag_html = segment_anchor_tag_that_object_belongs_to["html"]; - comp_obj_location.tags.segment_anchor_tag_epub = segment_anchor_tag_that_object_belongs_to["epub"]; - comp_obj_location.tags.heading_lev_anchor_tag = lev_anchor_tag; - comp_obj_location.metainfo.parent_ocn = p_["object_number"]; - comp_obj_location.metainfo.parent_lev_markup = p_["lev_markup_number"]; + comp_obj_location = comp_obj_location.init; + comp_obj_location.metainfo.is_a = is_; + comp_obj_location.metainfo.ocn = obj_cite_digits.on; + comp_obj_location.tags.anchor_tag_html = tag_in_seg["seg_lv4"]; + comp_obj_location.tags.segment_anchor_tag_epub = tag_in_seg["seg_lv1_to_4"]; + comp_obj_location.tags.heading_lev_anchor_tag = lev_anchor_tag; + comp_obj_location.metainfo.parent_ocn = p_["object_number"]; + comp_obj_location.metainfo.parent_lev_markup = p_["lev_markup_number"]; debug(_node) { if (lev_markup_number.match(rgx.levels_numbered_headings)) { writeln("x ", _node.to!string); @@ -7364,9 +7231,9 @@ struct NodeStructureMetadata { T _text, Lm lev_markup_number, Lc lev_collapsed_number, - TaB segment_anchor_tag_that_object_belongs_to, + TaB tag_in_seg, TaL lev_anchor_tag, - TA tag_assoc_html, + TA tag_assoc, N obj_cite_digits, C cntr_, P ptr_, @@ -7383,7 +7250,7 @@ struct NodeStructureMetadata { static assert(is(typeof(lev) == string)); static assert(is(typeof(lev_markup_number) == string)); static assert(is(typeof(lev_collapsed_number) == string)); - static assert(is(typeof(segment_anchor_tag_that_object_belongs_to) == string[string])); + static assert(is(typeof(tag_in_seg) == string[string])); static assert(is(typeof(obj_cite_digits.on) == int)); static assert(is(typeof(cntr_) == int)); static assert(is(typeof(ptr_) == int)); @@ -7500,11 +7367,14 @@ struct NodeStructureMetadata { _comp_obj_heading_.text = _text.to!string.strip; _comp_obj_heading_.metainfo.ocn = obj_cite_digits.on; _comp_obj_heading_.metainfo.object_number_off = (obj_cite_digits.off==0) ? "" : obj_cite_digits.off.to!string; + // _comp_obj_heading_.metainfo.o_n_book_index = obj_cite_digits.bkidx; _comp_obj_heading_.metainfo.object_number_type = obj_cite_digits.type; - _comp_obj_heading_.tags.segment_anchor_tag_html = segment_anchor_tag_that_object_belongs_to["html"]; - _comp_obj_heading_.tags.segment_anchor_tag_epub = _comp_obj_heading_.tags.segment_anchor_tag_html; + _comp_obj_heading_.tags.segment_anchor_tag_epub = tag_in_seg["seg_lv1_to_4"]; + _comp_obj_heading_.tags.anchor_tag_html = tag_in_seg["seg_lv4"]; + _comp_obj_heading_.tags.in_segment_html = _comp_obj_heading_.tags.anchor_tag_html; _comp_obj_heading_.tags.heading_lev_anchor_tag = lev_anchor_tag; - _comp_obj_heading_.tags.segment_anchor_tag_is = segment_anchor_tag_that_object_belongs_to["html"]; + _comp_obj_heading_.tags.html_segment_anchor_tag_is = tag_in_seg["seg_lv4"]; + _comp_obj_heading_.tags.epub_segment_anchor_tag_is = tag_in_seg["seg_lv1_to_4"]; _comp_obj_heading_.metainfo.heading_lev_markup = (!(lev_markup_number.empty) ? lev_markup_number.to!int : 0); _comp_obj_heading_.metainfo.heading_lev_collapsed = (!(lev_collapsed_number.empty) ? lev_collapsed_number.to!int : 0); _comp_obj_heading_.metainfo.parent_ocn = p_["object_number"]; @@ -7516,6 +7386,8 @@ struct NodeStructureMetadata { _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; + tag_assoc[_comp_obj_heading_.tags.anchor_tag_html]["seg_lv4"] = _comp_obj_heading_.tags.in_segment_html; + tag_assoc[_comp_obj_heading_.tags.segment_anchor_tag_epub]["seg_lv1_to_4"] = _comp_obj_heading_.tags.segment_anchor_tag_epub; debug(_node) { if (lev_markup_number.match(rgx.levels_numbered_headings)) { writeln("* ", _node.to!string); @@ -7944,9 +7816,11 @@ struct DocObj_Pointer_ { } struct DocObj_Tags_ { string[] heading_ancestors_text = [ "", "", "", "", "", "", "", "", ]; // TODO redundant? see markedup and collapsed ancestors DONE - string segment_anchor_tag_html = ""; + string anchor_tag_html = ""; + string in_segment_html = ""; string segment_anchor_tag_epub = ""; - string segment_anchor_tag_is = ""; + string html_segment_anchor_tag_is = ""; + string epub_segment_anchor_tag_is = ""; string heading_lev_anchor_tag = ""; string segname_prev = ""; string segname_next = ""; diff --git a/org/meta_debugs.org b/org/meta_debugs.org index b6e94d4..b507a4e 100644 --- a/org/meta_debugs.org +++ b/org/meta_debugs.org @@ -235,7 +235,7 @@ debug(section_head) { #+name: meta_output_debugs #+BEGIN_SRC d debug(section_toc) { - key="toc_seg"; + key="toc"; out_toc(contents, key); } #+END_SRC @@ -244,8 +244,8 @@ debug(section_toc) { #+name: meta_output_debugs #+BEGIN_SRC d -debug(section_toc_seg) { - key="toc_seg"; +debug(section_toc) { + key="toc"; out_toc(contents, key); } #+END_SRC @@ -254,20 +254,12 @@ debug(section_toc_seg) { #+name: meta_output_debugs #+BEGIN_SRC d -debug(section_toc_scroll) { - key="toc_scroll"; +debug(section_toc) { + key="toc"; out_toc(contents, key); } #+END_SRC -#+name: meta_output_debugs -#+BEGIN_SRC d -debug(segnames) { - writeln(__LINE__); - out_segnames(contents, doc_matters); -} -#+END_SRC - *** body_section :body: #+name: meta_output_debugs @@ -429,7 +421,7 @@ debug(section_bibliography) { #+name: meta_output_debugs #+BEGIN_SRC d debug(section_bookindex) { - key="bookindex_seg"; + key="bookindex"; out_bookindex(contents, key); } #+END_SRC @@ -438,8 +430,8 @@ debug(section_bookindex) { #+name: meta_output_debugs #+BEGIN_SRC d -debug(section_bookindex_seg) { - key="bookindex_seg"; +debug(section_bookindex) { + key="bookindex"; out_bookindex(contents, key); } #+END_SRC diff --git a/org/output_sqlite.org b/org/output_sqlite.org index ae1eb6d..c1f5ecb 100644 --- a/org/output_sqlite.org +++ b/org/output_sqlite.org @@ -111,10 +111,13 @@ template SQLiteDbRun() { } catch (Exception ex) { writeln("ERROR SQLite : ", ex); } - if (opt_action.debug_do) { - writeln(note); - if (opt_action.verbose) { - writeln(db_statement); + { /+ debug +/ + if (opt_action.debug_do + && opt_action.verbose) { + writeln(note); + if (opt_action.very_verbose) { + writeln(db_statement); + } } } } @@ -362,8 +365,11 @@ auto generic_munge_sanitize_text_for_search( if (_urls.length > 0) { _txt ~= _urls; } - if (doc_matters.opt.action.debug_do) { - writeln(_txt, "\n"); + { /+ debug +/ + if (doc_matters.opt.action.debug_do + && doc_matters.opt.action.verbose) { + writeln(_txt, "\n"); + } } debug(sql_text_clean) { writeln(_txt); @@ -423,8 +429,11 @@ auto munge_html(M,O)( if (_notes.length > 0) { _txt ~= _notes; } - if (doc_matters.opt.action.debug_do) { - writeln(_txt, "\n"); + { /+ debug +/ + if (doc_matters.opt.action.debug_do + && doc_matters.opt.action.verbose) { + writeln(_txt, "\n"); + } } return _txt; } @@ -534,7 +543,7 @@ auto inline_links(M,O)( 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])][0]) { + if (m.captures[3] == doc_matters.xml.tag_associations[(m.captures[3])]["seg_lv4"]) { _txt = _txt.replaceFirst( rgx.inline_link_hash, "┥$1┝┤" @@ -549,7 +558,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])][0] + ~ doc_matters.xml.tag_associations[(m.captures[3])]["seg_lv4"] ~ ".html" ~ "#" ~ "$3" ~ "├" @@ -981,15 +990,18 @@ auto heading(M,O)( "text": generic_munge_sanitize_text_for_search(obj.text), "html": html_heading(doc_matters, obj) ]; - if (doc_matters.opt.action.debug_do) { - debug(sql_txt) { - writeln(obj_txt["text"]); - } - debug(sql_html) { - writeln(obj_txt["html"]); + { /+ debug +/ + if (doc_matters.opt.action.debug_do + && doc_matters.opt.action.verbose) { + debug(sql_txt) { + writeln(obj_txt["text"]); + } + debug(sql_html) { + writeln(obj_txt["html"]); + } + } else { + // load sql } - } else { - // load sql } return obj_txt; } @@ -1007,15 +1019,18 @@ auto para(M,O)( "text": generic_munge_sanitize_text_for_search(obj.text), "html": html_para(doc_matters, obj) ]; - if (doc_matters.opt.action.debug_do) { - debug(sql_txt) { - writeln(obj_txt["text"]); - } - debug(sql_html) { - writeln(obj_txt["html"]); + { /+ debug +/ + if (doc_matters.opt.action.debug_do + && doc_matters.opt.action.verbose) { + debug(sql_txt) { + writeln(obj_txt["text"]); + } + debug(sql_html) { + writeln(obj_txt["html"]); + } + } else { + // load sql } - } else { - // load sql } return obj_txt; } @@ -1033,15 +1048,18 @@ auto quote(M,O)( "text": generic_munge_sanitize_text_for_search(obj.text), "html": html_quote(doc_matters, obj) ]; - if (doc_matters.opt.action.debug_do) { - debug(sql_txt) { - writeln(obj_txt["text"]); - } - debug(sql_html) { - writeln(obj_txt["html"]); + { /+ debug +/ + if (doc_matters.opt.action.debug_do + && doc_matters.opt.action.verbose) { + debug(sql_txt) { + writeln(obj_txt["text"]); + } + debug(sql_html) { + writeln(obj_txt["html"]); + } + } else { + // load sql } - } else { - // load sql } return obj_txt; } @@ -1058,15 +1076,18 @@ auto group(M,O)( "text": generic_munge_sanitize_text_for_search(obj.text), "html": html_group(doc_matters, obj) ]; - if (doc_matters.opt.action.debug_do) { - debug(sql_txt) { - writeln(obj_txt["text"]); - } - debug(sql_html) { - writeln(obj_txt["html"]); + { /+ debug +/ + if (doc_matters.opt.action.debug_do + && doc_matters.opt.action.verbose) { + debug(sql_txt) { + writeln(obj_txt["text"]); + } + debug(sql_html) { + writeln(obj_txt["html"]); + } + } else { + // load sql } - } else { - // load sql } return obj_txt; } @@ -1084,15 +1105,18 @@ auto block(M,O)( "text": generic_munge_sanitize_text_for_search(obj.text), "html": html_block(doc_matters, obj) ]; - if (doc_matters.opt.action.debug_do) { - debug(sql_txt) { - writeln(obj_txt["text"]); - } - debug(sql_html) { - writeln(obj_txt["html"]); + { /+ debug +/ + if (doc_matters.opt.action.debug_do + && doc_matters.opt.action.verbose) { + debug(sql_txt) { + writeln(obj_txt["text"]); + } + debug(sql_html) { + writeln(obj_txt["html"]); + } + } else { + // load sql } - } else { - // load sql } return obj_txt; } @@ -1110,15 +1134,18 @@ auto verse(M,O)( "text": generic_munge_sanitize_text_for_search(obj.text), "html": html_verse(doc_matters, obj) ]; - if (doc_matters.opt.action.debug_do) { - debug(sql_txt) { - writeln(obj_txt["text"]); - } - debug(sql_html) { - writeln(obj_txt["html"]); + { /+ debug +/ + if (doc_matters.opt.action.debug_do + && doc_matters.opt.action.verbose) { + debug(sql_txt) { + writeln(obj_txt["text"]); + } + debug(sql_html) { + writeln(obj_txt["html"]); + } + } else { + // load sql } - } else { - // load sql } return obj_txt; } @@ -1136,15 +1163,18 @@ auto code(M,O)( "text": generic_munge_sanitize_text_for_search(obj.text), "html": html_code(obj) ]; - if (doc_matters.opt.action.debug_do) { - debug(sql_txt) { - writeln(obj_txt["text"]); - } - debug(sql_html) { - writeln(obj_txt["html"]); + { /+ debug +/ + if (doc_matters.opt.action.debug_do + && doc_matters.opt.action.verbose) { + debug(sql_txt) { + writeln(obj_txt["text"]); + } + debug(sql_html) { + writeln(obj_txt["html"]); + } + } else { + // load sql } - } else { - // load sql } return obj_txt; } @@ -1162,15 +1192,18 @@ auto table(M,O)( "text": generic_munge_sanitize_text_for_search(obj.text), "html": html_table(doc_matters, obj) ]; - if (doc_matters.opt.action.debug_do) { - debug(sql_txt) { - writeln(obj_txt["text"]); - } - debug(sql_html) { - writeln(obj_txt["html"]); + { /+ debug +/ + if (doc_matters.opt.action.debug_do + && doc_matters.opt.action.verbose) { + debug(sql_txt) { + writeln(obj_txt["text"]); + } + debug(sql_html) { + writeln(obj_txt["html"]); + } + } else { + // load sql } - } else { - // load sql } return obj_txt; } @@ -1195,15 +1228,21 @@ foreach (part; doc_matters.xml.keys_seq.sql) { obj_txt = format_and_sqlite_load.heading(doc_matters, obj); break; default: - if ((doc_matters.opt.action.debug_do)) { - writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a); + { /+ debug +/ + if (doc_matters.opt.action.debug_do + && doc_matters.opt.action.verbose) { + writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a); + } } break; } break; default: - if ((doc_matters.opt.action.debug_do)) { - writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_of_type); + { /+ debug +/ + if (doc_matters.opt.action.debug_do + && doc_matters.opt.action.verbose) { + writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_of_type); + } } break; } @@ -1224,8 +1263,11 @@ foreach (part; doc_matters.xml.keys_seq.sql) { obj_txt = format_and_sqlite_load.para(doc_matters, obj); break; default: - if ((doc_matters.opt.action.debug_do)) { - writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a); + { /+ debug +/ + if (doc_matters.opt.action.debug_do + && doc_matters.opt.action.verbose) { + writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a); + } } break; } @@ -1253,21 +1295,27 @@ foreach (part; doc_matters.xml.keys_seq.sql) { obj_txt = format_and_sqlite_load.table(doc_matters, obj); break; default: - if ((doc_matters.opt.action.debug_do)) { - writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a); + { /+ debug +/ + if (doc_matters.opt.action.debug_do + && doc_matters.opt.action.verbose) { + writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a); + } } break; } break; default: - if ((doc_matters.opt.action.debug_do)) { - writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_of_type); + { /+ debug +/ + if (doc_matters.opt.action.debug_do + && doc_matters.opt.action.verbose) { + writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_of_type); + } } break; } break; case "backmatter": - assert(part == "glossary" || "bibliography" || "bookindex_seg" || "blurb" || "tail", part); + assert(part == "glossary" || "bibliography" || "bookindex" || "blurb" || "tail", part); switch (obj.metainfo.is_of_type) { case "para": switch (obj.metainfo.is_a) { @@ -1280,22 +1328,28 @@ foreach (part; doc_matters.xml.keys_seq.sql) { case "bibliography": assert(part == "bibliography", part); obj_txt = format_and_sqlite_load.para(doc_matters, obj); break; - case "bookindex": assert(part == "bookindex_seg", part); + case "bookindex": assert(part == "bookindex", part); obj_txt = format_and_sqlite_load.para(doc_matters, obj); break; case "blurb": assert(part == "blurb", part); obj_txt = format_and_sqlite_load.para(doc_matters, obj); break; default: - if ((doc_matters.opt.action.debug_do)) { - writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a); + { /+ debug +/ + if (doc_matters.opt.action.debug_do + && doc_matters.opt.action.verbose) { + writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a); + } } break; } break; default: - if ((doc_matters.opt.action.debug_do)) { - writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_of_type); + { /+ debug +/ + if (doc_matters.opt.action.debug_do + && doc_matters.opt.action.verbose) { + writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_of_type); + } } break; } @@ -1303,10 +1357,13 @@ foreach (part; doc_matters.xml.keys_seq.sql) { case "comment": break; default: - if ((doc_matters.opt.action.debug_do)) { - writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_of_part); // check where empty value could come from - writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a); - writeln(__FILE__, ":", __LINE__, ": ", obj.text); // check where empty value could come from + { /+ debug +/ + if (doc_matters.opt.action.debug_do + && doc_matters.opt.action.verbose) { + writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_of_part); // check where empty value could come from + writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a); + writeln(__FILE__, ":", __LINE__, ": ", obj.text); // check where empty value could come from + } } break; } diff --git a/org/output_xmls.org b/org/output_xmls.org index 060a75c..ef8e15e 100644 --- a/org/output_xmls.org +++ b/org/output_xmls.org @@ -66,16 +66,10 @@ string div_delimit( case "head": delimit_ ~= "\n
\n" ; break; - case "toc_seg": + case "toc": delimit_ ~= "\n
\n" ; break; - case "toc_scroll": - delimit_ ~= "\n
\n" ; - break; - case "bookindex_seg": - delimit_ ~= "\n
\n" ; - break; - case "bookindex_scroll": + case "bookindex": delimit_ ~= "\n
\n" ; break; default: @@ -458,6 +452,7 @@ auto inline_links(M,O)( string _suffix = ".html", string _xml_type = "seg", ) { + string seg_lvs; if (obj.has.inline_links) { if ((_txt.match(rgx.mark_internal_site_lnk)) && (_xml_type == "scroll")) { // conditions reversed to avoid: gdc compiled program run segfault @@ -466,9 +461,13 @@ auto inline_links(M,O)( "$1"); } 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] == doc_matters.xml.tag_associations[(m.captures[3])][0]) { + if ( + m.captures[3] + == doc_matters.xml.tag_associations[(m.captures[3])][seg_lvs] + ) { _txt = _txt.replaceFirst( rgx.inline_link_hash, "┥$1┝┤$3" ~ _suffix ~ "├" @@ -477,7 +476,7 @@ auto inline_links(M,O)( _txt = _txt.replaceFirst( rgx.inline_link_hash, "┥$1┝┤" - ~ doc_matters.xml.tag_associations[(m.captures[3])][0] + ~ doc_matters.xml.tag_associations[(m.captures[3])][seg_lvs] ~ _suffix ~ "#" ~ "$3" ~ "├" @@ -485,7 +484,9 @@ auto inline_links(M,O)( } } else { writeln( - "WARNING on internal document links, anchor to link not found in document, " + "WARNING on internal document links, anchor to link <<" + ~ m.captures[3] + ~ ">> not found in document, " ~ "anchor: " ~ m.captures[3] ~ " document: " ~ doc_matters.src.filename ); @@ -1438,7 +1439,7 @@ void scroll(D,M)( delimit = xhtml_format.div_delimit(part, previous_part); string _txt = xhtml_format.special_characters(obj, obj.text); switch (obj.metainfo.is_of_part) { - case "frontmatter": assert(part == "head" || "toc_scroll"); + case "frontmatter": assert(part == "head" || "toc"); switch (obj.metainfo.is_of_type) { case "para": switch (obj.metainfo.is_a) { @@ -1449,15 +1450,21 @@ void scroll(D,M)( doc_html ~= xhtml_format.para_scroll(doc_matters, obj, _txt, suffix); break; default: - if ((doc_matters.opt.action.debug_do)) { - writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a); + { /+ debug +/ + if (doc_matters.opt.action.debug_do + && doc_matters.opt.action.verbose) { + writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a); + } } break; } break; default: - if ((doc_matters.opt.action.debug_do)) { - writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_of_type); + { /+ debug +/ + if (doc_matters.opt.action.debug_do + && doc_matters.opt.action.verbose) { + writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_of_type); + } } break; } @@ -1473,8 +1480,11 @@ void scroll(D,M)( doc_html ~= xhtml_format.para_scroll(doc_matters, obj, _txt, suffix); break; default: - if ((doc_matters.opt.action.debug_do)) { - writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a); + { /+ debug +/ + if (doc_matters.opt.action.debug_do + && doc_matters.opt.action.verbose) { + writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a); + } } break; } @@ -1502,21 +1512,27 @@ void scroll(D,M)( doc_html ~= xhtml_format.table(doc_matters, obj, _txt); break; default: - if ((doc_matters.opt.action.debug_do)) { - writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a); + { /+ debug +/ + if (doc_matters.opt.action.debug_do + && doc_matters.opt.action.verbose) { + writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a); + } } break; } break; default: - if ((doc_matters.opt.action.debug_do)) { - writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_of_type); + { /+ debug +/ + if (doc_matters.opt.action.debug_do + && doc_matters.opt.action.verbose) { + writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_of_type); + } } break; } break; case "backmatter": - assert(part == "endnotes" || "glossary" || "bibliography" || "bookindex_scroll" || "blurb" || "tail"); + assert(part == "endnotes" || "glossary" || "bibliography" || "bookindex" || "blurb" || "tail"); switch (obj.metainfo.is_of_type) { case "para": switch (obj.metainfo.is_a) { @@ -1532,22 +1548,28 @@ void scroll(D,M)( case "bibliography": assert(part == "bibliography"); doc_html ~= xhtml_format.para_scroll(doc_matters, obj, _txt, suffix); break; - case "bookindex": assert(part == "bookindex_scroll"); + case "bookindex": assert(part == "bookindex"); doc_html ~= xhtml_format.para_scroll(doc_matters, obj, _txt, suffix); break; case "blurb": assert(part == "blurb"); doc_html ~= xhtml_format.para_scroll(doc_matters, obj, _txt, suffix); break; default: - if ((doc_matters.opt.action.debug_do)) { - writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a); + { /+ debug +/ + if (doc_matters.opt.action.debug_do + && doc_matters.opt.action.verbose) { + writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a); + } } break; } break; default: - if ((doc_matters.opt.action.debug_do)) { - writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_of_type); + { /+ debug +/ + if (doc_matters.opt.action.debug_do + && doc_matters.opt.action.verbose) { + writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_of_type); + } } break; } @@ -1555,10 +1577,13 @@ void scroll(D,M)( case "comment": break; default: - if ((doc_matters.opt.action.debug_do)) { - writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_of_part); - writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a); - writeln(__FILE__, ":", __LINE__, ": ", obj.text); + { /+ debug +/ + if (doc_matters.opt.action.debug_do + && doc_matters.opt.action.verbose) { + writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_of_part); + writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a); + writeln(__FILE__, ":", __LINE__, ": ", obj.text); + } } break; } @@ -1624,7 +1649,7 @@ void seg(D,M)( delimit = xhtml_format.div_delimit(part, previous_part); string _txt = xhtml_format.special_characters(obj, obj.text); if (obj.metainfo.is_a == "heading") { - assert(part == "head" || "toc_seg" || "body" || "endnotes" || "glossary" || "bibliography" || "bookindex_seg" || "blurb" || "tail"); + assert(part == "head" || "toc" || "body" || "endnotes" || "glossary" || "bibliography" || "bookindex" || "blurb" || "tail"); switch (obj.metainfo.heading_lev_markup) { case 0: .. case 3: /+ fill buffer, and replace with new levels from 1 to 3 +/ @@ -1673,21 +1698,27 @@ void seg(D,M)( doc_html_endnotes[segment_filename] ~= t[1]; break; case 8: .. case 9: - if ((doc_matters.opt.action.debug_do)) { - writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a, ": ", obj.metainfo.heading_lev_markup); - writeln(__FILE__, ":", __LINE__, ": ", obj.text); + { /+ debug +/ + if (doc_matters.opt.action.debug_do + && doc_matters.opt.action.verbose) { + writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a, ": ", obj.metainfo.heading_lev_markup); + writeln(__FILE__, ":", __LINE__, ": ", obj.text); + } } break; default: - if ((doc_matters.opt.action.debug_do)) { - writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a, ": ", obj.metainfo.heading_lev_markup); + { /+ debug +/ + if (doc_matters.opt.action.debug_do + && doc_matters.opt.action.verbose) { + writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a, ": ", obj.metainfo.heading_lev_markup); + } } break; } } else { - assert(part == "head" || "toc_seg" || "body" || "endnotes" || "glossary" || "bibliography" || "bookindex_seg" || "blurb" || "tail"); + assert(part == "head" || "toc" || "body" || "endnotes" || "glossary" || "bibliography" || "bookindex" || "blurb" || "tail"); switch (obj.metainfo.is_of_part) { - case "frontmatter": assert(part == "head" || "toc_seg"); + case "frontmatter": assert(part == "head" || "toc"); switch (obj.metainfo.is_of_type) { case "para": switch (obj.metainfo.is_a) { @@ -1696,15 +1727,21 @@ void seg(D,M)( doc_html[segment_filename] ~= t[0].to!string; break; default: - if ((doc_matters.opt.action.debug_do)) { - writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a); + { /+ debug +/ + if (doc_matters.opt.action.debug_do + && doc_matters.opt.action.verbose) { + writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a); + } } break; } break; default: - if ((doc_matters.opt.action.debug_do)) { - writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a); + { /+ debug +/ + if (doc_matters.opt.action.debug_do + && doc_matters.opt.action.verbose) { + writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a); + } } break; } @@ -1719,8 +1756,11 @@ void seg(D,M)( doc_html_endnotes[segment_filename] ~= t[1]; break; default: - if ((doc_matters.opt.action.debug_do)) { - writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a); + { /+ debug +/ + if (doc_matters.opt.action.debug_do + && doc_matters.opt.action.verbose) { + writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a); + } } break; } @@ -1757,21 +1797,27 @@ void seg(D,M)( doc_html_endnotes[segment_filename] ~= ""; break; default: - if ((doc_matters.opt.action.debug_do)) { - writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a); + { /+ debug +/ + if (doc_matters.opt.action.debug_do + && doc_matters.opt.action.verbose) { + writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a); + } } break; } break; default: - if ((doc_matters.opt.action.debug_do)) { - writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_of_type); + { /+ debug +/ + if (doc_matters.opt.action.debug_do + && doc_matters.opt.action.verbose) { + writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_of_type); + } } break; } break; case "backmatter": - assert(part == "endnotes" || "glossary" || "bibliography" || "bookindex_seg" || "blurb" || "tail"); + assert(part == "endnotes" || "glossary" || "bibliography" || "bookindex" || "blurb" || "tail"); switch (obj.metainfo.is_of_type) { case "para": switch (obj.metainfo.is_a) { @@ -1789,7 +1835,7 @@ void seg(D,M)( doc_html[segment_filename] ~= t[0]; doc_html_endnotes[segment_filename] ~= t[1]; break; - case "bookindex": assert(part == "bookindex_seg"); + case "bookindex": assert(part == "bookindex"); auto t = xhtml_format.para_seg(doc_matters, obj, _txt, suffix, "seg"); doc_html[segment_filename] ~= t[0]; doc_html_endnotes[segment_filename] ~= t[1]; @@ -1800,15 +1846,21 @@ void seg(D,M)( doc_html_endnotes[segment_filename] ~= t[1]; break; default: - if ((doc_matters.opt.action.debug_do)) { - writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a); + { /+ debug +/ + if (doc_matters.opt.action.debug_do + && doc_matters.opt.action.verbose) { + writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a); + } } break; } break; default: - if ((doc_matters.opt.action.debug_do)) { - writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_of_type); + { /+ debug +/ + if (doc_matters.opt.action.debug_do + && doc_matters.opt.action.verbose) { + writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_of_type); + } } break; } @@ -1816,8 +1868,11 @@ void seg(D,M)( case "comment": break; default: - if ((doc_matters.opt.action.debug_do)) { - writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_of_part); + { /+ debug +/ + if (doc_matters.opt.action.debug_do + && doc_matters.opt.action.verbose) { + writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_of_part); + } } break; } @@ -2070,8 +2125,8 @@ string epub3_oebps_content(D,M,P)(D doc_abstraction, M doc_matters, P parts) { content ~= " " ~ "" ~ "\n "; content ~= "" ~ ""; debug(epubmanifest) { - foreach (s; doc_matters.xml.keys_seq.seg) { - foreach (obj; doc_abstraction[s]) { + foreach (part; doc_matters.xml.keys_seq.seg) { // TODO + foreach (obj; doc_abstraction[part]) { if (obj.metainfo.is_a == "heading") { if (obj.metainfo.heading_lev_markup == 4) { writefln( @@ -2220,8 +2275,8 @@ string epub2_oebps_toc_ncx(D,I)(D doc_abstraction, I doc_matters) { doc_matters.conf_make_meta.meta.title_full, // title (doc_matters.conf_make_meta.meta.creator_author.empty) ? "" : " by " ~ doc_matters.conf_make_meta.meta.creator_author, // author - uuid, // uuid - "3", // content depth + uuid, // uuid + "3", // content depth doc_matters.conf_make_meta.meta.title_full, // title (doc_matters.conf_make_meta.meta.creator_author.empty) ? "" : doc_matters.conf_make_meta.meta.creator_author, // author @@ -2302,7 +2357,7 @@ void outputEPub3(D,I)( foreach (obj; doc_abstraction[part]) { string _txt = xhtml_format.special_characters(obj, obj.text); if (obj.metainfo.is_a == "heading") { - assert(part == "head" || "toc_seg" || "body" || "endnotes" || "glossary" || "bibliography" || "bookindex_seg" || "blurb" || "tail"); + assert(part == "head" || "toc" || "body" || "endnotes" || "glossary" || "bibliography" || "bookindex" || "blurb" || "tail"); switch (obj.metainfo.heading_lev_markup) { case 0: .. case 3: /+ fill buffer, and replace with new levels from 1 to 3 +/ @@ -2347,21 +2402,27 @@ void outputEPub3(D,I)( doc_epub3_endnotes[segment_filename] ~= t[1]; break; case 8: .. case 9: - if ((doc_matters.opt.action.debug_do)) { - writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a, ": ", obj.metainfo.heading_lev_markup); - writeln(__FILE__, ":", __LINE__, ": ", obj.text); + { /+ debug +/ + if (doc_matters.opt.action.debug_do + && doc_matters.opt.action.verbose) { + writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a, ": ", obj.metainfo.heading_lev_markup); + writeln(__FILE__, ":", __LINE__, ": ", obj.text); + } } break; default: - if ((doc_matters.opt.action.debug_do)) { - writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a, ": ", obj.metainfo.heading_lev_markup); + { /+ debug +/ + if (doc_matters.opt.action.debug_do + && doc_matters.opt.action.verbose) { + writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a, ": ", obj.metainfo.heading_lev_markup); + } } break; } } else { - assert(part == "head" || "toc_seg" || "body" || "endnotes" || "glossary" || "bibliography" || "bookindex_seg" || "blurb" || "tail"); + assert(part == "head" || "toc" || "body" || "endnotes" || "glossary" || "bibliography" || "bookindex" || "blurb" || "tail"); switch (obj.metainfo.is_of_part) { - case "frontmatter": assert(part == "head" || "toc_seg"); + case "frontmatter": assert(part == "head" || "toc"); switch (obj.metainfo.is_of_type) { case "para": switch (obj.metainfo.is_a) { @@ -2371,15 +2432,21 @@ void outputEPub3(D,I)( doc_epub3_endnotes[segment_filename] ~= t[1]; break; default: - if ((doc_matters.opt.action.debug_do)) { - writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a); + { /+ debug +/ + if (doc_matters.opt.action.debug_do + && doc_matters.opt.action.verbose) { + writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a); + } } break; } break; default: - if ((doc_matters.opt.action.debug_do)) { - writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_of_type); + { /+ debug +/ + if (doc_matters.opt.action.debug_do + && doc_matters.opt.action.verbose) { + writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_of_type); + } } break; } @@ -2394,8 +2461,11 @@ void outputEPub3(D,I)( doc_epub3_endnotes[segment_filename] ~= t[1]; break; default: - if ((doc_matters.opt.action.debug_do)) { - writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a); + { /+ debug +/ + if (doc_matters.opt.action.debug_do + && doc_matters.opt.action.verbose) { + writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a); + } } break; } @@ -2432,21 +2502,27 @@ void outputEPub3(D,I)( doc_epub3_endnotes[segment_filename] ~= ""; break; default: - if ((doc_matters.opt.action.debug_do)) { - writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a); + { /+ debug +/ + if (doc_matters.opt.action.debug_do + && doc_matters.opt.action.verbose) { + writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a); + } } break; } break; default: - if ((doc_matters.opt.action.debug_do)) { - writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_of_type); + { /+ debug +/ + if (doc_matters.opt.action.debug_do + && doc_matters.opt.action.verbose) { + writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_of_type); + } } break; } break; case "backmatter": - assert(part == "endnotes" || "glossary" || "bibliography" || "bookindex_seg" || "blurb" || "tail"); + assert(part == "endnotes" || "glossary" || "bibliography" || "bookindex" || "blurb" || "tail"); switch (obj.metainfo.is_of_type) { case "para": switch (obj.metainfo.is_a) { @@ -2464,7 +2540,7 @@ void outputEPub3(D,I)( doc_epub3[segment_filename] ~= t[0]; doc_epub3_endnotes[segment_filename] ~= t[1]; break; - case "bookindex": assert(part == "bookindex_seg"); + case "bookindex": assert(part == "bookindex"); auto t = xhtml_format.para_seg(doc_matters, obj, _txt, suffix, "epub"); doc_epub3[segment_filename] ~= t[0]; doc_epub3_endnotes[segment_filename] ~= t[1]; @@ -2475,15 +2551,21 @@ void outputEPub3(D,I)( doc_epub3_endnotes[segment_filename] ~= t[1]; break; default: - if ((doc_matters.opt.action.debug_do)) { - writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a); + { /+ debug +/ + if (doc_matters.opt.action.debug_do + && doc_matters.opt.action.verbose) { + writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a); + } } break; } break; default: - if ((doc_matters.opt.action.debug_do)) { - writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_of_type); + { /+ debug +/ + if (doc_matters.opt.action.debug_do + && doc_matters.opt.action.verbose) { + writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_of_type); + } } break; } @@ -2491,8 +2573,11 @@ void outputEPub3(D,I)( case "comment": break; default: - if ((doc_matters.opt.action.debug_do)) { - writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_of_part); + { /+ debug +/ + if (doc_matters.opt.action.debug_do + && doc_matters.opt.action.verbose) { + writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_of_part); + } } break; } @@ -2597,15 +2682,17 @@ void epub3_write_output_files(M,D,E,Mt,Mic,Otnx,Otn,Oc)( if (!exists(pth_epub3.base)) { pth_epub3.base.mkdirRecurse; } - debug(epub_output) { - if (!exists(pth_epub3.dbg_doc_meta_inf(doc_matters.src.filename))) { - pth_epub3.dbg_doc_meta_inf(doc_matters.src.filename).mkdirRecurse; - } - if (!exists(pth_epub3.dbg_doc_oebps_css(doc_matters.src.filename))) { - pth_epub3.dbg_doc_oebps_css(doc_matters.src.filename).mkdirRecurse; - } - if (!exists(pth_epub3.dbg_doc_oebps_image(doc_matters.src.filename))) { - pth_epub3.dbg_doc_oebps_image(doc_matters.src.filename).mkdirRecurse; + { /+ debug +/ + if (doc_matters.opt.action.debug_do) { + if (!exists(pth_epub3.dbg_doc_meta_inf(doc_matters.src.filename))) { + pth_epub3.dbg_doc_meta_inf(doc_matters.src.filename).mkdirRecurse; + } + if (!exists(pth_epub3.dbg_doc_oebps_css(doc_matters.src.filename))) { + pth_epub3.dbg_doc_oebps_css(doc_matters.src.filename).mkdirRecurse; + } + if (!exists(pth_epub3.dbg_doc_oebps_image(doc_matters.src.filename))) { + pth_epub3.dbg_doc_oebps_image(doc_matters.src.filename).mkdirRecurse; + } } } { /+ OEBPS/[segments].xhtml (the document contents) +/ @@ -2614,19 +2701,25 @@ void epub3_write_output_files(M,D,E,Mt,Mic,Otnx,Otn,Oc)( auto zip_arc_member_file = new ArchiveMember(); zip_arc_member_file.name = fn; auto zip_data = new OutBuffer(); - debug(epub_output) { - string fn_dbg = pth_epub3.dbg_fn_oebps_content_xhtml(doc_matters.src.filename, seg_filename); - auto f = File(fn_dbg, "w"); + { /+ debug +/ + if (doc_matters.opt.action.debug_do) { + string fn_dbg = pth_epub3.dbg_fn_oebps_content_xhtml(doc_matters.src.filename, seg_filename); + auto f = File(fn_dbg, "w"); + foreach (docseg; doc_epub3[seg_filename]) { + f.writeln(docseg); + } + foreach (docseg; doc_epub3_endnotes[seg_filename]) { + f.writeln(docseg); + } + f.writeln(xhtml_format.tail); + } } foreach (docseg; doc_epub3[seg_filename]) { - debug(epub_output) { f.writeln(docseg); } zip_data.write(docseg.dup); } foreach (docseg; doc_epub3_endnotes[seg_filename]) { - debug(epub_output) { f.writeln(docseg); } zip_data.write(docseg.dup); } - debug(epub_output) { f.writeln(xhtml_format.tail); } zip_data.write(xhtml_format.tail.dup); zip_arc_member_file.expandedData = zip_data.toBytes(); zip.addMember(zip_arc_member_file); @@ -2635,12 +2728,14 @@ void epub3_write_output_files(M,D,E,Mt,Mic,Otnx,Otn,Oc)( } } string fn; - debug(epub_output) { string fn_dbg; } + string fn_dbg; File f; { /+ mimetypes (identify zip file type) +/ - debug(epub_output) { - fn_dbg = pth_epub3.dbg_fn_mimetypes(doc_matters.src.filename); - File(fn_dbg, "w").writeln(mimetypes); + { /+ debug +/ + if (doc_matters.opt.action.debug_do) { + fn_dbg = pth_epub3.dbg_fn_mimetypes(doc_matters.src.filename); + File(fn_dbg, "w").writeln(mimetypes); + } } fn = pth_epub3.fn_mimetypes(doc_matters.src.filename); auto zip_arc_member_file = new ArchiveMember(); @@ -2652,9 +2747,11 @@ void epub3_write_output_files(M,D,E,Mt,Mic,Otnx,Otn,Oc)( createZipFile!()(fn_epub, zip.build()); } { /+ META-INF/container.xml (identify doc root) +/ - debug(epub_output) { - fn_dbg = pth_epub3.dbg_fn_dmi_container_xml(doc_matters.src.filename); - File(fn_dbg, "w").writeln(meta_inf_container_xml); + { /+ debug +/ + if (doc_matters.opt.action.debug_do) { + fn_dbg = pth_epub3.dbg_fn_dmi_container_xml(doc_matters.src.filename); + File(fn_dbg, "w").writeln(meta_inf_container_xml); + } } fn = pth_epub3.fn_dmi_container_xml(doc_matters.src.filename); auto zip_arc_member_file = new ArchiveMember(); @@ -2666,9 +2763,11 @@ void epub3_write_output_files(M,D,E,Mt,Mic,Otnx,Otn,Oc)( createZipFile!()(fn_epub, zip.build()); } { /+ OEBPS/toc_nav.xhtml (navigation toc epub3) +/ - debug(epub_output) { - fn_dbg = pth_epub3.dbg_fn_oebps_toc_nav_xhtml(doc_matters.src.filename); - File(fn_dbg, "w").writeln(oebps_toc_nav_xhtml); + { /+ debug +/ + if (doc_matters.opt.action.debug_do) { + fn_dbg = pth_epub3.dbg_fn_oebps_toc_nav_xhtml(doc_matters.src.filename); + File(fn_dbg, "w").writeln(oebps_toc_nav_xhtml); + } } fn = pth_epub3.fn_oebps_toc_nav_xhtml(doc_matters.src.filename); auto zip_arc_member_file = new ArchiveMember(); @@ -2680,9 +2779,11 @@ void epub3_write_output_files(M,D,E,Mt,Mic,Otnx,Otn,Oc)( createZipFile!()(fn_epub, zip.build()); } { /+ OEBPS/toc.ncx (navigation toc epub2) +/ - debug(epub_output) { - fn_dbg = pth_epub3.dbg_fn_oebps_toc_ncx(doc_matters.src.filename); - File(fn_dbg, "w").writeln(oebps_toc_ncx); + { /+ debug +/ + if (doc_matters.opt.action.debug_do) { + fn_dbg = pth_epub3.dbg_fn_oebps_toc_ncx(doc_matters.src.filename); + File(fn_dbg, "w").writeln(oebps_toc_ncx); + } } fn = pth_epub3.fn_oebps_toc_ncx(doc_matters.src.filename); auto zip_arc_member_file = new ArchiveMember(); @@ -2694,9 +2795,11 @@ void epub3_write_output_files(M,D,E,Mt,Mic,Otnx,Otn,Oc)( createZipFile!()(fn_epub, zip.build()); } { /+ OEBPS/content.opf (doc manifest) +/ - debug(epub_output) { - fn_dbg = pth_epub3.dbg_fn_oebps_content_opf(doc_matters.src.filename); - File(fn_dbg, "w").writeln(oebps_content_opf); + { /+ debug +/ + if (doc_matters.opt.action.debug_do) { + fn_dbg = pth_epub3.dbg_fn_oebps_content_opf(doc_matters.src.filename); + File(fn_dbg, "w").writeln(oebps_content_opf); + } } fn = pth_epub3.fn_oebps_content_opf(doc_matters.src.filename); auto zip_arc_member_file = new ArchiveMember(); @@ -2709,20 +2812,18 @@ void epub3_write_output_files(M,D,E,Mt,Mic,Otnx,Otn,Oc)( } { /+ OEBPS/_sisu/image (images) +/ foreach (image; doc_matters.srcs.image_list) { - debug(epub_output) { - if (exists(doc_matters.src_path_info.image_root ~ "/" ~ image)) { - (doc_matters.src_path_info.image_root ~ "/" ~ image) - .copy((pth_epub3.dbg_doc_oebps_image(doc_matters.src.filename)) ~ "/" ~ image); - } - } - } - foreach (image; doc_matters.srcs.image_list) { - debug(epub_output) { - debug(epub_images) { - writeln( - doc_matters.src.image_dir_path, "/", image, " -> ", - pth_epub3.dbg_doc_oebps_image(doc_matters.src.filename), "/", image - ); + { /+ debug +/ + if (doc_matters.opt.action.debug_do) { + if (doc_matters.opt.action.very_verbose) { + writeln( + doc_matters.src.image_dir_path, "/", image, " -> ", + pth_epub3.dbg_doc_oebps_image(doc_matters.src.filename), "/", image + ); + } + if (exists(doc_matters.src.image_dir_path ~ "/" ~ image)) { + (doc_matters.src.image_dir_path ~ "/" ~ image) + .copy((pth_epub3.dbg_doc_oebps_image(doc_matters.src.filename)) ~ "/" ~ image); + } } } auto fn_src = doc_matters.src.image_dir_path ~ "/" ~ image; @@ -2742,9 +2843,11 @@ void epub3_write_output_files(M,D,E,Mt,Mic,Otnx,Otn,Oc)( } { /+ OEBPS/epub.css +/ auto css = DocReformCss(); - debug(epub_output) { - fn_dbg = pth_epub3.dbg_fn_oebps_css(doc_matters.src.filename); - File(fn_dbg, "w").writeln(css.epub_css); + { /+ debug +/ + if (doc_matters.opt.action.debug_do) { + fn_dbg = pth_epub3.dbg_fn_oebps_css(doc_matters.src.filename); + File(fn_dbg, "w").writeln(css.epub_css); + } } fn = pth_epub3.fn_oebps_css(doc_matters.src.filename); auto zip_arc_member_file = new ArchiveMember(); diff --git a/src/doc_reform/doc_reform.d b/src/doc_reform/doc_reform.d index 4a0a9b5..1d39909 100755 --- a/src/doc_reform/doc_reform.d +++ b/src/doc_reform/doc_reform.d @@ -448,11 +448,15 @@ void main(string[] args) { } } if (!(_opt_action.skip_output)) { - debug(steps) { + if ((_opt_action.debug_do) + || (_opt_action.very_verbose) + ) { writeln("step0 commence → (without processing files)"); } outputHubOp!()(_env, _opt_action); - debug(steps) { + if ((_opt_action.debug_do) + || (_opt_action.very_verbose) + ) { writeln("- step0 complete"); } } @@ -464,9 +468,8 @@ void main(string[] args) { scope(success) { if (!(_opt_action.quiet)) { writefln( - "%s\n%s", - "~ document complete, ok ~", - "------------------------------------------------------------------", + "%s", + "-- ~ document complete, ok ~ ------------------------------------", ); } } @@ -485,7 +488,9 @@ void main(string[] args) { "not a sisu markup filename: «" ~ manifest.src.filename ~ "»" ); - debug(steps) { + if ((_opt_action.debug_do) + || (_opt_action.very_verbose) + ) { writeln("--->\nstepX commence → (document abstraction)"); } auto t = DocReformAbstraction!()(_env, _opt_action, manifest); @@ -493,7 +498,9 @@ void main(string[] args) { static assert(t.length==2); auto doc_abstraction = t[dAM.abstraction]; auto doc_matters = t[dAM.matters]; - debug(steps) { + if ((doc_matters.opt.action.debug_do) + || (doc_matters.opt.action.very_verbose) + ) { writeln("- stepX complete"); } /+ ↓ debugs +/ @@ -501,26 +508,29 @@ void main(string[] args) { DocReformAbstractionSummary!()(doc_abstraction, doc_matters); } /+ ↓ debugs +/ - if ((doc_matters.opt.action.debug_do) - || (doc_matters.opt.action.verbose) - ) { + if (doc_matters.opt.action.debug_do) { DocReformDebugs!()(doc_abstraction, doc_matters); } /+ ↓ output hub +/ if (!(doc_matters.opt.action.skip_output)) { - debug(steps) { + if ((_opt_action.debug_do) + || (_opt_action.very_verbose) + ) { writeln("step5 commence → (process outputs)"); } outputHub!()(doc_abstraction, doc_matters); - debug(steps) { + if ((_opt_action.debug_do) + || (_opt_action.very_verbose) + ) { writeln("- step5 complete"); } } scope(exit) { if (!(_opt_action.quiet)) { writefln( - "processed file: %s", - manifest.src.filename + "processed file: %s (%s)", + manifest.src.filename, + manifest.src.language ); } destroy(manifest); @@ -538,9 +548,8 @@ void main(string[] args) { scope(success) { if (!(_opt_action.quiet)) { writefln( - "%s\n%s", - "~ document complete, ok ~", - "------------------------------------------------------------------", + "%s", + "-- ~ document complete, ok ~ ------------------------------------", ); } } @@ -559,7 +568,9 @@ void main(string[] args) { "not a sisu markup filename: «" ~ manifest.src.filename ~ "»" ); - debug(steps) { + if ((_opt_action.debug_do) + || (_opt_action.very_verbose) + ) { writeln("--->\nstepX commence → (document abstraction)"); } auto t = DocReformAbstraction!()(_env, _opt_action, manifest); @@ -567,7 +578,9 @@ void main(string[] args) { static assert(t.length==2); auto doc_abstraction = t[dAM.abstraction]; auto doc_matters = t[dAM.matters]; - debug(steps) { + if ((doc_matters.opt.action.debug_do) + || (doc_matters.opt.action.very_verbose) + ) { writeln("- stepX complete"); } /+ ↓ debugs +/ @@ -575,26 +588,29 @@ void main(string[] args) { DocReformAbstractionSummary!()(doc_abstraction, doc_matters); } /+ ↓ debugs +/ - if ((doc_matters.opt.action.debug_do) - || (doc_matters.opt.action.verbose) - ) { + if (doc_matters.opt.action.debug_do) { DocReformDebugs!()(doc_abstraction, doc_matters); } /+ ↓ output hub +/ if (!(doc_matters.opt.action.skip_output)) { - debug(steps) { + if ((_opt_action.debug_do) + || (_opt_action.very_verbose) + ) { writeln("step5 commence → (process outputs)"); } outputHub!()(doc_abstraction, doc_matters); - debug(steps) { + if ((_opt_action.debug_do) + || (_opt_action.very_verbose) + ) { writeln("- step5 complete"); } } scope(exit) { if (!(_opt_action.quiet)) { writefln( - "processed file: %s", - manifest.src.filename + "processed file: %s (%s)", + manifest.src.filename, + manifest.src.language ); } destroy(manifest); diff --git a/src/doc_reform/meta/defaults.d b/src/doc_reform/meta/defaults.d index fd13b44..661234c 100644 --- a/src/doc_reform/meta/defaults.d +++ b/src/doc_reform/meta/defaults.d @@ -130,20 +130,20 @@ template InternalMarkup() { auto lnk_o = "┥"; auto lnk_c = "┝"; auto url_o = "┤"; auto url_c = "├"; auto mark_internal_site_lnk = "¤"; - auto nbsp = "░"; - auto br_line = "┘"; - auto br_nl = "┙"; - auto br_paragraph = "┚"; - auto br_obj = "break_obj"; - auto br_page_line = "┼"; - auto br_page = "┿"; - auto br_page_new = "╂"; - auto tc_s = "┊"; - auto tc_o = "┏"; - auto tc_c = "┚"; - auto tc_p = "┆"; - auto mono = "■"; - auto img = "☼"; + auto nbsp = "░"; + auto br_line = "┘"; + auto br_nl = "┙"; + auto br_paragraph = "┚"; + auto br_obj = "break_obj"; + auto br_page_line = "┼"; + auto br_page = "┿"; + auto br_page_new = "╂"; + auto tc_s = "┊"; + auto tc_o = "┏"; + auto tc_c = "┚"; + auto tc_p = "┆"; + auto mono = "■"; + auto img = "☼"; static string indent_by_spaces_provided(int indent, string _indent_spaces ="░░") { _indent_spaces = replicate(_indent_spaces, indent); return _indent_spaces; diff --git a/src/doc_reform/meta/doc_debugs.d b/src/doc_reform/meta/doc_debugs.d index ae3ab98..8765c06 100644 --- a/src/doc_reform/meta/doc_debugs.d +++ b/src/doc_reform/meta/doc_debugs.d @@ -74,21 +74,17 @@ template DocReformDebugs() { } } debug(section_toc) { - key="toc_seg"; + key="toc"; out_toc(contents, key); } - debug(section_toc_seg) { - key="toc_seg"; + debug(section_toc) { + key="toc"; out_toc(contents, key); } - debug(section_toc_scroll) { - key="toc_scroll"; + debug(section_toc) { + key="toc"; out_toc(contents, key); } - debug(segnames) { - writeln(__LINE__); - out_segnames(contents, doc_matters); - } debug(section_body) { key="body"; if (contents[key].length > 1) { @@ -202,11 +198,11 @@ template DocReformDebugs() { } } debug(section_bookindex) { - key="bookindex_seg"; + key="bookindex"; out_bookindex(contents, key); } - debug(section_bookindex_seg) { - key="bookindex_seg"; + debug(section_bookindex) { + key="bookindex"; out_bookindex(contents, key); } debug(section_bookindex_scroll) { diff --git a/src/doc_reform/meta/metadoc.d b/src/doc_reform/meta/metadoc.d index e164f36..4cb218e 100644 --- a/src/doc_reform/meta/metadoc.d +++ b/src/doc_reform/meta/metadoc.d @@ -40,7 +40,9 @@ template DocReformAbstraction() { _make_and_meta_struct = configParseTOMLreturnDocReformStruct!()(_make_and_meta_struct, _config_local_site_struct); /+ ↓ read file (filename with path) +/ /+ ↓ file tuple of header and content +/ - debug(steps) { + if ((_opt_action.debug_do) + || (_opt_action.very_verbose) + ) { writeln("step1 commence → (get document header & body & insert file list & if needed image list)" ); } @@ -48,7 +50,9 @@ template DocReformAbstraction() { = DocReformRawMarkupContent!()(_opt_action, _manifest.src.path_and_fn); static assert(!isTypeTuple!(_header_body_insertfilelist_imagelist)); static assert(_header_body_insertfilelist_imagelist.length==4); - debug(steps) { + if ((_opt_action.debug_do) + || (_opt_action.very_verbose) + ) { writeln("- step1 complete"); } debug(header_and_body) { @@ -57,7 +61,9 @@ template DocReformAbstraction() { writeln(_header_body_insertfilelist_imagelist.length[headBody.body_content][0]); } /+ ↓ split header into make and meta +/ - debug(steps) { + if ((_opt_action.debug_do) + || (_opt_action.very_verbose) + ) { writeln("step2 commence → (read document header - toml, return struct)"); } _make_and_meta_struct = @@ -65,11 +71,15 @@ template DocReformAbstraction() { _make_and_meta_struct, _header_body_insertfilelist_imagelist[headBody.header] ); - debug(steps) { + if ((_opt_action.debug_do) + || (_opt_action.very_verbose) + ) { writeln("- step2 complete"); } /+ ↓ document abstraction: process document, return abstraction as tuple +/ - debug(steps) { + if ((_opt_action.debug_do) + || (_opt_action.very_verbose) + ) { writeln("step3 commence → (document abstraction (da); da keys; segnames; doc_matters)"); } auto da = DocReformDocAbstraction!()( @@ -91,10 +101,14 @@ template DocReformAbstraction() { } auto _doc_tag_assoc = da[docAbst.tag_assoc]; auto _images = da[docAbst.images]; - debug(steps) { + if ((_opt_action.debug_do) + || (_opt_action.very_verbose) + ) { writeln("- step3 complete"); } - debug(steps) { + if ((_opt_action.debug_do) + || (_opt_action.very_verbose) + ) { writeln("step4 commence → (doc_matters)"); } struct DocumentMatters { @@ -175,7 +189,9 @@ template DocReformAbstraction() { } } auto doc_matters = DocumentMatters(); - debug(steps) { + if ((_opt_action.debug_do) + || (_opt_action.very_verbose) + ) { writeln("- step4 complete"); } auto t = tuple(doc_abstraction, doc_matters); diff --git a/src/doc_reform/meta/metadoc_from_src.d b/src/doc_reform/meta/metadoc_from_src.d index 68f4433..64dd6e6 100644 --- a/src/doc_reform/meta/metadoc_from_src.d +++ b/src/doc_reform/meta/metadoc_from_src.d @@ -23,7 +23,7 @@ template DocReformDocAbstraction() { mixin DocReformRgxInit; /+ ↓ abstraction struct init +/ /+ initialize +/ - ObjGenericComposite[][string] the_table_of_contents_section; + ObjGenericComposite[] the_table_of_contents_section; ObjGenericComposite[] the_document_head_section, the_document_body_section, the_bibliography_section, the_glossary_section, the_blurb_section; ObjGenericComposite[] the_dom_tail_section; string[string] an_object, processing; @@ -31,11 +31,10 @@ template DocReformDocAbstraction() { string[] anchor_tags; string anchor_tag; string anchor_tag_; - string[string] segment_anchor_tag_that_object_belongs_to; + string[string] tag_in_seg; string lev_anchor_tag; - string[][string] tag_assoc_html; - string[][string] tag_assoc_lv0_to_lv3_html; - string[][string] tag_assoc_lv0_to_lv3_epub; + string[string][string] tag_assoc; + string[] lv0_to_3_tags; /+ enum +/ enum State { off, on } enum TriState { off, on, closing } @@ -239,16 +238,21 @@ template DocReformDocAbstraction() { ObjGenericComposite comp_obj_heading, comp_obj_location, comp_obj_block, comp_obj_code, comp_obj_poem_ocn, comp_obj_comment; auto node_construct = NodeStructureMetadata(); enum sObj { content, anchor_tag, notes_reg, notes_star, links, image_no_dimensions } - auto inline_para_link_anchor(O,St,TA)(O an_object, St segment_anchor_tag_that_object_belongs_to, TA tag_assoc_html) { + auto inline_para_link_anchor(O,St,TA)( + O an_object, + St tag_in_seg, + TA tag_assoc + ) { static auto rgx = Rgx(); if (auto m = an_object["substantive"].match(rgx.inline_link_anchor)) { - if (m.captures[1] !in tag_assoc_html) { - tag_assoc_html[(m.captures[1])] = [segment_anchor_tag_that_object_belongs_to["html"]]; + if (m.captures[1] !in tag_assoc) { + tag_assoc[(m.captures[1])]["seg_lv4"] = tag_in_seg["seg_lv4"]; + tag_assoc[(m.captures[1])]["seg_lv1_to_4"] = tag_in_seg["seg_lv1_to_4"]; } else { writeln("a tag named already exists, check text line\n ", an_object["substantive"]); } } - return tag_assoc_html; + return tag_assoc; } /+ ↓ abstract marked up document +/ auto DocReformDocAbstraction(Src,CMM,Opt,Mfst)( @@ -350,8 +354,9 @@ template DocReformDocAbstraction() { 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_html = "toc"; - comp_obj_heading_.tags.segment_anchor_tag_epub = comp_obj_heading_.tags.segment_anchor_tag_html; + comp_obj_heading_.tags.segment_anchor_tag_epub = "toc"; + comp_obj_heading_.tags.anchor_tag_html = comp_obj_heading_.tags.segment_anchor_tag_epub; + comp_obj_heading_.tags.in_segment_html = comp_obj_heading_.tags.anchor_tag_html; comp_obj_heading_.metainfo.heading_lev_markup = 4; comp_obj_heading_.metainfo.heading_lev_collapsed = 1; comp_obj_heading_.metainfo.parent_ocn = 1; @@ -360,18 +365,17 @@ template DocReformDocAbstraction() { 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]; + tag_assoc[comp_obj_heading_.tags.anchor_tag_html]["seg_lv4"] = comp_obj_heading_.tags.in_segment_html; + tag_assoc[comp_obj_heading_.tags.segment_anchor_tag_epub]["seg_lv1_to_4"] = comp_obj_heading_.tags.segment_anchor_tag_epub; auto toc_head = comp_obj_heading_; html_segnames_ptr_cntr++; - the_table_of_contents_section = [ - "seg": [toc_head], - "scroll": [toc_head], - ]; + the_table_of_contents_section = [toc_head]; static auto mkup = InlineMarkup(); static auto munge = ObjInlineMarkupMunge(); auto note_section = NotesSection(); auto bookindex_extract_hash = BookIndexNuggetHash(); string[][string] lev4_subtoc; - string[] html_segnames=["toc"]; + string[][string] segnames = ["html": ["toc"], "epub": ["toc"]]; int cnt1 = 1; int cnt2 = 1; int cnt3 = 1; /+ abstraction init ↑ +/ enum Substitute { match, markup, } @@ -490,8 +494,9 @@ template DocReformDocAbstraction() { 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_html = "_part_glossary"; - comp_obj_heading_.tags.segment_anchor_tag_epub = comp_obj_heading_.tags.segment_anchor_tag_html; + comp_obj_heading_.tags.segment_anchor_tag_epub = "_part_glossary"; + comp_obj_heading_.tags.anchor_tag_html = comp_obj_heading_.tags.segment_anchor_tag_epub; + comp_obj_heading_.tags.in_segment_html = "glossary"; comp_obj_heading_.metainfo.heading_lev_markup = 1; comp_obj_heading_.metainfo.heading_lev_collapsed = 1; comp_obj_heading_.metainfo.parent_ocn = 1; @@ -499,6 +504,8 @@ template DocReformDocAbstraction() { 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_; + tag_assoc[comp_obj_heading_.tags.anchor_tag_html]["seg_lv4"] = comp_obj_heading_.tags.in_segment_html; + tag_assoc[comp_obj_heading_.tags.segment_anchor_tag_epub]["seg_lv1_to_4"] = comp_obj_heading_.tags.segment_anchor_tag_epub; comp_obj_heading_ = comp_obj_heading_.init; comp_obj_heading_.metainfo.is_of_part = "backmatter"; comp_obj_heading_.metainfo.is_of_section = "glossary"; @@ -508,8 +515,9 @@ template DocReformDocAbstraction() { 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_html = "glossary"; - comp_obj_heading_.tags.segment_anchor_tag_epub = comp_obj_heading_.tags.segment_anchor_tag_html; + comp_obj_heading_.tags.segment_anchor_tag_epub = "glossary"; + comp_obj_heading_.tags.anchor_tag_html = comp_obj_heading_.tags.segment_anchor_tag_epub; + comp_obj_heading_.tags.in_segment_html = comp_obj_heading_.tags.anchor_tag_html; comp_obj_heading_.metainfo.heading_lev_markup = 4; comp_obj_heading_.metainfo.heading_lev_collapsed = 2; comp_obj_heading_.metainfo.parent_ocn = 1; @@ -518,6 +526,8 @@ template DocReformDocAbstraction() { 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_; + tag_assoc[comp_obj_heading_.tags.anchor_tag_html]["seg_lv4"] = comp_obj_heading_.tags.in_segment_html; + tag_assoc[comp_obj_heading_.tags.segment_anchor_tag_epub]["seg_lv1_to_4"] = comp_obj_heading_.tags.segment_anchor_tag_epub; } else { _para_match_(line, an_object, an_object_key, indent, bullet, obj_type_status, line_occur); comp_obj_para = comp_obj_para.init; @@ -598,8 +608,9 @@ template DocReformDocAbstraction() { 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_html = "_part_blurb"; - comp_obj_heading_.tags.segment_anchor_tag_epub = comp_obj_heading_.tags.segment_anchor_tag_html; + comp_obj_heading_.tags.segment_anchor_tag_epub = "_part_blurb"; + comp_obj_heading_.tags.anchor_tag_html = comp_obj_heading_.tags.segment_anchor_tag_epub; + comp_obj_heading_.tags.in_segment_html = "blurb"; comp_obj_heading_.metainfo.heading_lev_markup = 1; comp_obj_heading_.metainfo.heading_lev_collapsed = 1; comp_obj_heading_.metainfo.parent_ocn = 1; @@ -607,6 +618,8 @@ template DocReformDocAbstraction() { 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_; + tag_assoc[comp_obj_heading_.tags.anchor_tag_html]["seg_lv4"] = comp_obj_heading_.tags.in_segment_html; + tag_assoc[comp_obj_heading_.tags.segment_anchor_tag_epub]["seg_lv1_to_4"] = comp_obj_heading_.tags.segment_anchor_tag_epub; comp_obj_heading_ = comp_obj_heading_.init; comp_obj_heading_.metainfo.is_of_part = "backmatter"; comp_obj_heading_.metainfo.is_of_section = "blurb"; @@ -616,8 +629,9 @@ template DocReformDocAbstraction() { 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_html = "blurb"; - comp_obj_heading_.tags.segment_anchor_tag_epub = comp_obj_heading_.tags.segment_anchor_tag_html; + comp_obj_heading_.tags.segment_anchor_tag_epub = "blurb"; + comp_obj_heading_.tags.anchor_tag_html = comp_obj_heading_.tags.segment_anchor_tag_epub; + comp_obj_heading_.tags.in_segment_html = comp_obj_heading_.tags.anchor_tag_html; comp_obj_heading_.metainfo.heading_lev_markup = 4; comp_obj_heading_.metainfo.heading_lev_collapsed = 2; comp_obj_heading_.metainfo.parent_ocn = 1; @@ -626,6 +640,8 @@ template DocReformDocAbstraction() { 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_; + tag_assoc[comp_obj_heading_.tags.anchor_tag_html]["seg_lv4"] = comp_obj_heading_.tags.in_segment_html; + tag_assoc[comp_obj_heading_.tags.segment_anchor_tag_epub]["seg_lv1_to_4"] = comp_obj_heading_.tags.segment_anchor_tag_epub; } else if (line.matchFirst(rgx.heading) && (opt_action.backmatter && opt_action.section_blurb)) { comp_obj_heading_ = comp_obj_heading_.init; @@ -637,13 +653,16 @@ template DocReformDocAbstraction() { 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_html = "blurb"; - comp_obj_heading_.tags.segment_anchor_tag_epub = comp_obj_heading_.tags.segment_anchor_tag_html; + comp_obj_heading_.tags.segment_anchor_tag_epub = "blurb"; + comp_obj_heading_.tags.anchor_tag_html = comp_obj_heading_.tags.segment_anchor_tag_epub; + comp_obj_heading_.tags.in_segment_html = comp_obj_heading_.tags.anchor_tag_html; comp_obj_heading_.metainfo.heading_lev_markup = an_object["lev_markup_number"].to!int; // make int, remove need to conv 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_; + tag_assoc[comp_obj_heading_.tags.anchor_tag_html]["seg_lv4"] = comp_obj_heading_.tags.in_segment_html; + tag_assoc[comp_obj_heading_.tags.segment_anchor_tag_epub]["seg_lv1_to_4"] = comp_obj_heading_.tags.segment_anchor_tag_epub; } else { _para_match_(line, an_object, an_object_key, indent, bullet, obj_type_status, line_occur); comp_obj_para = comp_obj_para.init; @@ -695,7 +714,7 @@ template DocReformDocAbstraction() { continue; } else if (obj_type_status["poem"] == TriState.on) { /+ within block object: poem +/ - _poem_block_(line, an_object, obj_type_status, cntr, object_number_poem, conf_make_meta, segment_anchor_tag_that_object_belongs_to); + _poem_block_(line, an_object, obj_type_status, cntr, object_number_poem, conf_make_meta, tag_in_seg); continue; } else if (obj_type_status["table"] == TriState.on) { /+ within block object: table +/ @@ -834,7 +853,7 @@ template DocReformDocAbstraction() { obj_type_status, object_number_poem, conf_make_meta, - segment_anchor_tag_that_object_belongs_to, + tag_in_seg, ); } else { /+ line.empty, post contents, empty variables: +/ @@ -847,6 +866,11 @@ template DocReformDocAbstraction() { (obj_type_status["blocks"] == State.off), "code block status: none" ); + if (_new_doc) { + tag_assoc = tag_assoc.init; + lv0_to_3_tags = lv0_to_3_tags.init; + tag_in_seg = tag_in_seg.init; + } if ((obj_type_status["heading"] == State.on) && (line_occur["heading"] > State.off)) { /+ heading object (current line empty) +/ @@ -868,27 +892,29 @@ template DocReformDocAbstraction() { if ( an_object["lev_markup_number"].to!int == 4 && (!(anchor_tag.empty) - || (tag_assoc_lv0_to_lv3_html.length > 1)) + || (lv0_to_3_tags.length > 0)) ) { - segment_anchor_tag_that_object_belongs_to["html"] = anchor_tag; + tag_in_seg["seg_lv4"] = anchor_tag; + tag_in_seg["seg_lv1_to_4"] = anchor_tag; lev_anchor_tag = anchor_tag; - tag_assoc_html[anchor_tag] = [segment_anchor_tag_that_object_belongs_to["html"]]; - if (tag_assoc_lv0_to_lv3_html.length > 1) { /+ names used for html markup segments 1 to 4 (rather than epub which has separate segments for A to D) +/ - foreach (lv0_to_lv3_html_tag; tag_assoc_lv0_to_lv3_html) { - tag_assoc_html[lv0_to_lv3_html_tag[0]] = [segment_anchor_tag_that_object_belongs_to["html"]]; + tag_assoc[anchor_tag]["seg_lv4"] = tag_in_seg["seg_lv4"]; + tag_assoc[anchor_tag]["seg_lv1_to_4"] = tag_in_seg["seg_lv1_to_4"]; + if (lv0_to_3_tags.length > 0) { /+ names used for html markup segments 1 to 4 (rather than epub which has separate segments for A to D) +/ + foreach (lv0_to_lv3_html_tag; lv0_to_3_tags) { + tag_assoc[lv0_to_lv3_html_tag]["seg_lv4"] = anchor_tag; } } - segment_anchor_tag_that_object_belongs_to["html_uri"] = anchor_tag ~ ".fnSuffix"; anchor_tag_ = anchor_tag; - tag_assoc_lv0_to_lv3_html = tag_assoc_lv0_to_lv3_html.init; + lv0_to_3_tags = lv0_to_3_tags.init; } else if (an_object["lev_markup_number"].to!int > 4) { - segment_anchor_tag_that_object_belongs_to["html"] = anchor_tag_; + tag_in_seg["seg_lv4"] = anchor_tag_; + tag_in_seg["seg_lv1_to_4"] = anchor_tag_; lev_anchor_tag = anchor_tag; - tag_assoc_html[anchor_tag] = [segment_anchor_tag_that_object_belongs_to["html"]]; - segment_anchor_tag_that_object_belongs_to["html_uri"] = anchor_tag_ ~ ".fnSuffix#" ~ obj_cite_digits.on.to!string; + tag_assoc[anchor_tag]["seg_lv4"] = tag_in_seg["seg_lv4"]; + tag_assoc[anchor_tag]["seg_lv1_to_4"] = tag_in_seg["seg_lv1_to_4"]; } else if (an_object["lev_markup_number"].to!int < 4) { string segn; - switch (an_object["lev_markup_number"].to!int) { + switch (an_object["lev_markup_number"].to!int) { /+ names used for epub markup segments A to D +/ case 0: segn = "_the_title"; goto default; @@ -897,50 +923,51 @@ template DocReformDocAbstraction() { ++cnt1; goto default; case 2: - segn = "_part_" ~ cnt1.to!string ~ "_" ~ cnt2.to!string; + segn = "_part_" ~ cnt1.to!string ~ "_" ~ cnt2.to!string; ++cnt2; goto default; case 3: - segn = "_part_" ~ cnt1.to!string ~ "_" ~ cnt2.to!string ~ "_" ~ cnt3.to!string; + segn = "_part_" ~ cnt1.to!string ~ "_" ~ cnt2.to!string ~ "_" ~ cnt3.to!string; ++cnt3; goto default; default: - segment_anchor_tag_that_object_belongs_to["html"] = segn; - segment_anchor_tag_that_object_belongs_to["html_uri"] = segn ~ ".fnSuffix"; - segment_anchor_tag_that_object_belongs_to["epub"] = segn; - segment_anchor_tag_that_object_belongs_to["epub_uri"] = segn ~ ".fnSuffix"; - tag_assoc_lv0_to_lv3_html[segn] = [""]; - tag_assoc_lv0_to_lv3_epub[segn] = ["segn"]; + lv0_to_3_tags ~= obj_cite_digits.on.to!string; + lv0_to_3_tags ~= segn; + tag_in_seg["seg_lv4"] = segn; // for html segname need following lv4 not yet known + tag_in_seg["seg_lv1_to_4"] = segn; break; } } an_object["bookindex_nugget"] = ("bookindex_nugget" in an_object) ? an_object["bookindex_nugget"] : ""; bookindex_unordered_hashes - = bookindex_extract_hash.bookindex_nugget_hash(an_object["bookindex_nugget"], obj_cite_digits, segment_anchor_tag_that_object_belongs_to); + = bookindex_extract_hash.bookindex_nugget_hash(an_object["bookindex_nugget"], obj_cite_digits, tag_in_seg); /+ (incrementally build toc) table of contents here! +/ _anchor_tag=obj_cite_digits.on.to!string; the_table_of_contents_section = obj_im.table_of_contents_gather_headings( an_object, conf_make_meta, - segment_anchor_tag_that_object_belongs_to, + tag_in_seg, _anchor_tag, lev4_subtoc, the_table_of_contents_section, ); if (an_object["lev_markup_number"] == "4") { - html_segnames ~= segment_anchor_tag_that_object_belongs_to["html"]; + segnames["html"] ~= tag_in_seg["seg_lv4"]; html_segnames_ptr = html_segnames_ptr_cntr; html_segnames_ptr_cntr++; } + if (an_object["lev_markup_number"].to!int <= 4) { + segnames["epub"] ~= tag_in_seg["seg_lv1_to_4"]; + } auto comp_obj_heading = node_construct.node_emitter_heading( - an_object["substantive"], // string - an_object["lev_markup_number"], // string - an_object["lev_collapsed_number"], // string - segment_anchor_tag_that_object_belongs_to, // string - lev_anchor_tag, // string - tag_assoc_html, + an_object["substantive"], + an_object["lev_markup_number"], + an_object["lev_collapsed_number"], + tag_in_seg, + lev_anchor_tag, + tag_assoc, obj_cite_digits, // OCNset cntr, // int heading_ptr, // int @@ -954,7 +981,8 @@ template DocReformDocAbstraction() { ++heading_ptr; debug(segments) { writeln(an_object["lev_markup_number"]); - writeln(segment_anchor_tag_that_object_belongs_to["html"]); + writeln(tag_in_seg["seg_lv4"]); + writeln(tag_in_seg["seg_lv1_to_4"]); } the_document_body_section ~= comp_obj_heading; debug(objectrelated1) { // check @@ -972,14 +1000,14 @@ template DocReformDocAbstraction() { an_object["bookindex_nugget"] = ("bookindex_nugget" in an_object) ? an_object["bookindex_nugget"] : ""; bookindex_unordered_hashes - = bookindex_extract_hash.bookindex_nugget_hash(an_object["bookindex_nugget"], obj_cite_digits, segment_anchor_tag_that_object_belongs_to); + = bookindex_extract_hash.bookindex_nugget_hash(an_object["bookindex_nugget"], obj_cite_digits, tag_in_seg); an_object["is"] = "para"; auto comp_obj_heading = node_construct.node_location_emitter( content_non_header, - segment_anchor_tag_that_object_belongs_to, + tag_in_seg, lev_anchor_tag, - tag_assoc_html, + tag_assoc, obj_cite_digits, cntr, heading_ptr-1, @@ -989,14 +1017,14 @@ template DocReformDocAbstraction() { = obj_im.obj_inline_markup_and_anchor_tags_and_misc(an_object, an_object_key, conf_make_meta, false); an_object["substantive"] = substantive_obj_misc_tuple[sObj.content]; anchor_tag = substantive_obj_misc_tuple[sObj.anchor_tag]; - tag_assoc_html = inline_para_link_anchor(an_object, segment_anchor_tag_that_object_belongs_to, tag_assoc_html); comp_obj_para = comp_obj_para.init; comp_obj_para.metainfo.is_of_part = "body"; comp_obj_para.metainfo.is_of_section = "body"; comp_obj_para.metainfo.is_of_type = "para"; comp_obj_para.metainfo.is_a = "para"; comp_obj_para.text = an_object["substantive"].to!string.strip; - comp_obj_para.tags.segment_anchor_tag_is = segment_anchor_tag_that_object_belongs_to["html"]; + comp_obj_para.tags.html_segment_anchor_tag_is = tag_in_seg["seg_lv4"]; + comp_obj_para.tags.epub_segment_anchor_tag_is = tag_in_seg["seg_lv1_to_4"]; comp_obj_para.metainfo.ocn = obj_cite_digits.digit; comp_obj_para.metainfo.object_number_off = (obj_cite_digits.off==0) ? "" : obj_cite_digits.off.to!string; comp_obj_para.metainfo.o_n_book_index = obj_cite_digits.bkidx; @@ -1010,6 +1038,7 @@ template DocReformDocAbstraction() { comp_obj_para.has.inline_links = substantive_obj_misc_tuple[sObj.links]; comp_obj_para.has.contains_image_without_dimensions = substantive_obj_misc_tuple[sObj.image_no_dimensions]; the_document_body_section ~= comp_obj_para; + tag_assoc = inline_para_link_anchor(an_object, tag_in_seg, tag_assoc); _common_reset_(line_occur, an_object, obj_type_status); indent=[ "hang_position" : 0, @@ -1048,7 +1077,7 @@ template DocReformDocAbstraction() { )) { note_section.gather_notes_for_endnote_section( the_document_body_section, - segment_anchor_tag_that_object_belongs_to, + tag_in_seg, (i).to!int, ); } @@ -1063,7 +1092,7 @@ template DocReformDocAbstraction() { previous_count=(the_document_body_section.length -1).to!int; note_section.gather_notes_for_endnote_section( the_document_body_section, - segment_anchor_tag_that_object_belongs_to, + tag_in_seg, (the_document_body_section.length-1).to!int, ); } @@ -1089,20 +1118,20 @@ template DocReformDocAbstraction() { } } if (an_object["glossary_nugget"].length == 0) { - comp_obj_heading_ = comp_obj_heading_.init; - comp_obj_heading_.metainfo.is_of_part = "empty"; - comp_obj_heading_.metainfo.is_of_section = "empty"; - comp_obj_heading_.metainfo.is_of_type = "para"; - comp_obj_heading_.metainfo.is_a = "heading"; - comp_obj_heading_.text = "(skip) there is no Glossary section"; - comp_obj_heading_.metainfo.ocn = 0; - comp_obj_heading_.metainfo.object_number_off = ""; - comp_obj_heading_.metainfo.object_number_type = 0; - 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; - the_glossary_section ~= comp_obj_heading_; + comp_obj_heading_ = comp_obj_heading_.init; + comp_obj_heading_.metainfo.is_of_part = "empty"; + comp_obj_heading_.metainfo.is_of_section = "empty"; + comp_obj_heading_.metainfo.is_of_type = "para"; + comp_obj_heading_.metainfo.is_a = "heading"; + comp_obj_heading_.text = "(skip) there is no Glossary section"; + comp_obj_heading_.metainfo.ocn = 0; + comp_obj_heading_.metainfo.object_number_off = ""; + comp_obj_heading_.metainfo.object_number_type = 0; + 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; + the_glossary_section ~= comp_obj_heading_; } debug(glossary) { foreach (gloss; the_glossary_section) { @@ -1114,54 +1143,60 @@ template DocReformDocAbstraction() { auto biblio_ordered = biblio._bibliography_(biblio_unsorted_incomplete, bib_arr_json); if (biblio_ordered.length > 0) { - comp_obj_heading_ = comp_obj_heading_.init; - comp_obj_heading_.metainfo.is_of_part = "backmatter"; - comp_obj_heading_.metainfo.is_of_section = "bibliography"; - comp_obj_heading_.metainfo.is_of_type = "para"; - comp_obj_heading_.metainfo.is_a = "heading"; - comp_obj_heading_.text = "Bibliography"; - 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_html = "_part_bibliography"; - comp_obj_heading_.tags.segment_anchor_tag_epub = comp_obj_heading_.tags.segment_anchor_tag_html; - 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; - the_bibliography_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 = "bibliography"; - comp_obj_heading_.metainfo.is_of_type = "para"; - comp_obj_heading_.metainfo.is_a = "heading"; - comp_obj_heading_.text = "Bibliography"; - 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_html = "bibliography"; - comp_obj_heading_.tags.segment_anchor_tag_epub = comp_obj_heading_.tags.segment_anchor_tag_html; - 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 = ["bibliography"]; - the_bibliography_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 = "bibliography"; + comp_obj_heading_.metainfo.is_of_type = "para"; + comp_obj_heading_.metainfo.is_a = "heading"; + comp_obj_heading_.text = "Bibliography"; + 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_epub = "_part_bibliography"; + comp_obj_heading_.tags.anchor_tag_html = comp_obj_heading_.tags.segment_anchor_tag_epub; + comp_obj_heading_.tags.in_segment_html = "bibliography"; + 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; + the_bibliography_section ~= comp_obj_heading_; + tag_assoc[comp_obj_heading_.tags.anchor_tag_html]["seg_lv4"] = comp_obj_heading_.tags.in_segment_html; + tag_assoc[comp_obj_heading_.tags.segment_anchor_tag_epub]["seg_lv1_to_4"] = comp_obj_heading_.tags.segment_anchor_tag_epub; + comp_obj_heading_ = comp_obj_heading_.init; + comp_obj_heading_.metainfo.is_of_part = "backmatter"; + comp_obj_heading_.metainfo.is_of_section = "bibliography"; + comp_obj_heading_.metainfo.is_of_type = "para"; + comp_obj_heading_.metainfo.is_a = "heading"; + comp_obj_heading_.text = "Bibliography"; + 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_epub = "bibliography"; + comp_obj_heading_.tags.anchor_tag_html = comp_obj_heading_.tags.segment_anchor_tag_epub; + comp_obj_heading_.tags.in_segment_html = comp_obj_heading_.tags.anchor_tag_html; + 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 = ["bibliography"]; + the_bibliography_section ~= comp_obj_heading_; + tag_assoc[comp_obj_heading_.tags.anchor_tag_html]["seg_lv4"] = comp_obj_heading_.tags.in_segment_html; + tag_assoc[comp_obj_heading_.tags.segment_anchor_tag_epub]["seg_lv1_to_4"] = comp_obj_heading_.tags.segment_anchor_tag_epub; } else { - comp_obj_heading_ = comp_obj_heading_.init; - comp_obj_heading_.metainfo.is_of_part = "empty"; - comp_obj_heading_.metainfo.is_of_section = "empty"; - comp_obj_heading_.metainfo.is_of_type = "para"; - comp_obj_heading_.metainfo.is_a = "heading"; - comp_obj_heading_.text = "(skip) there is no Bibliography"; - comp_obj_heading_.metainfo.ocn = 0; - comp_obj_heading_.metainfo.object_number_off = ""; - comp_obj_heading_.metainfo.object_number_type = 0; - 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; - the_bibliography_section ~= comp_obj_heading_; + comp_obj_heading_ = comp_obj_heading_.init; + comp_obj_heading_.metainfo.is_of_part = "empty"; + comp_obj_heading_.metainfo.is_of_section = "empty"; + comp_obj_heading_.metainfo.is_of_type = "para"; + comp_obj_heading_.metainfo.is_a = "heading"; + comp_obj_heading_.text = "(skip) there is no Bibliography"; + comp_obj_heading_.metainfo.ocn = 0; + comp_obj_heading_.metainfo.object_number_off = ""; + comp_obj_heading_.metainfo.object_number_type = 0; + 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; + the_bibliography_section ~= comp_obj_heading_; } string out_; foreach (entry; biblio_ordered) { @@ -1211,7 +1246,7 @@ template DocReformDocAbstraction() { auto the_bookindex_section = bi_tuple[0]; obj_cite_digits = bi_tuple[1]; debug(bookindex) { - foreach (bi_entry; the_bookindex_section["seg"]) { + foreach (bi_entry; the_bookindex_section) { writeln(bi_entry); } } @@ -1225,8 +1260,9 @@ template DocReformDocAbstraction() { comp_obj_heading_.metainfo.ocn = 0; comp_obj_para.metainfo.object_number_off = ""; comp_obj_para.metainfo.object_number_type = 0; - comp_obj_heading_.tags.segment_anchor_tag_html = ""; comp_obj_heading_.tags.segment_anchor_tag_epub = ""; + comp_obj_heading_.tags.anchor_tag_html = ""; + comp_obj_heading_.tags.in_segment_html = ""; comp_obj_heading_.metainfo.heading_lev_markup = 1; comp_obj_heading_.metainfo.heading_lev_collapsed = 1; comp_obj_heading_.metainfo.parent_ocn = 1; @@ -1255,29 +1291,16 @@ template DocReformDocAbstraction() { comp_obj_toc.attrib.bullet = false; if (the_endnotes_section.length > 1) { toc_txt_ = format( - "{ %s }%s%s%s", + "{ %s }#%s", "Endnotes", - mkup.mark_internal_site_lnk, "endnotes", - ".fnSuffix", ); toc_txt_= munge.url_links(toc_txt_); comp_obj_toc.text = toc_txt_.to!string.strip; comp_obj_toc.has.inline_links = true; - the_table_of_contents_section["seg"] ~= comp_obj_toc; + the_table_of_contents_section ~= comp_obj_toc; } if (the_glossary_section.length > 1) { - toc_txt_ = format( - "{ %s }%s%s%s", - "Glossary", - mkup.mark_internal_site_lnk, - "glossary", - ".fnSuffix", - ); - toc_txt_= munge.url_links(toc_txt_); - comp_obj_toc.text = toc_txt_.to!string.strip; - comp_obj_toc.has.inline_links = true; - the_table_of_contents_section["seg"] ~= comp_obj_toc; toc_txt_ = format( "{ %s }#%s", "Glossary", @@ -1286,21 +1309,9 @@ template DocReformDocAbstraction() { toc_txt_= munge.url_links(toc_txt_); comp_obj_toc.text = toc_txt_.to!string.strip; comp_obj_toc.has.inline_links = true; - the_table_of_contents_section["scroll"] ~= comp_obj_toc; + the_table_of_contents_section ~= comp_obj_toc; } if (the_bibliography_section.length > 1){ - toc_txt_ = format( - "{ %s }%s%s%s", - "Bibliography", - mkup.mark_internal_site_lnk, - "bibliography", - ".fnSuffix", - ); - toc_txt_= munge.url_links(toc_txt_); - comp_obj_toc.text = toc_txt_.to!string.strip; - comp_obj_toc.has.inline_links = true; - the_table_of_contents_section["seg"] ~= comp_obj_toc; - toc_txt_ = format( "{ %s }#%s", "Bibliography", @@ -1309,22 +1320,9 @@ template DocReformDocAbstraction() { toc_txt_= munge.url_links(toc_txt_); comp_obj_toc.text = toc_txt_.to!string.strip; comp_obj_toc.has.inline_links = true; - the_table_of_contents_section["scroll"] ~= comp_obj_toc; - } - if (the_bookindex_section["seg"].length > 1) { - toc_txt_ = format( - "{ %s }%s%s%s", - "Book Index", - mkup.mark_internal_site_lnk, - "bookindex", - ".fnSuffix", - ); - toc_txt_= munge.url_links(toc_txt_); - comp_obj_toc.text = toc_txt_.to!string.strip; - comp_obj_toc.has.inline_links = true; - the_table_of_contents_section["seg"] ~= comp_obj_toc; + the_table_of_contents_section ~= comp_obj_toc; } - if (the_bookindex_section["scroll"].length > 1) { + if (the_bookindex_section.length > 1) { toc_txt_ = format( "{ %s }#%s", "Book Index", @@ -1333,20 +1331,9 @@ template DocReformDocAbstraction() { toc_txt_= munge.url_links(toc_txt_); comp_obj_toc.text = toc_txt_.to!string.strip; comp_obj_toc.has.inline_links = true; - the_table_of_contents_section["scroll"] ~= comp_obj_toc; + the_table_of_contents_section ~= comp_obj_toc; } if (the_blurb_section.length > 1) { - toc_txt_ = format( - "{ %s }%s%s%s", - "Blurb", - mkup.mark_internal_site_lnk, - "blurb", - ".fnSuffix", - ); - toc_txt_= munge.url_links(toc_txt_); - comp_obj_toc.text = toc_txt_.to!string.strip; - comp_obj_toc.has.inline_links = true; - the_table_of_contents_section["seg"] ~= comp_obj_toc; toc_txt_ = format( "{ %s }#%s", "Blurb", @@ -1355,25 +1342,14 @@ template DocReformDocAbstraction() { toc_txt_= munge.url_links(toc_txt_); comp_obj_toc.has.inline_links = true; comp_obj_toc.text = toc_txt_.to!string.strip; - the_table_of_contents_section["scroll"] ~= comp_obj_toc; + the_table_of_contents_section ~= comp_obj_toc; } debug(toc) { writefln( "%s %s", __LINE__, - the_table_of_contents_section["seg"].length ); - foreach (toc_linked_heading; the_table_of_contents_section["seg"]) { - writeln(mkup.indent_by_spaces_provided(toc_linked_heading.attrib.indent_hang), toc_linked_heading.text); - } - } - debug(tocscroll) { - writefln( - "%s %s", - __LINE__, - the_table_of_contents_section["seg"].length - ); - foreach (toc_linked_heading; the_table_of_contents_section["scroll"]) { + foreach (toc_linked_heading; the_table_of_contents_section) { writeln(mkup.indent_by_spaces_provided(toc_linked_heading.attrib.indent_hang), toc_linked_heading.text); } } @@ -1573,7 +1549,8 @@ template DocReformDocAbstraction() { } } if (the_endnotes_section.length > 1) { - html_segnames ~= "endnotes"; + segnames["html"] ~= "endnotes"; + segnames["epub"] ~= "endnotes"; html_segnames_ptr = html_segnames_ptr_cntr; foreach (ref obj; the_endnotes_section) { if (obj.metainfo.is_a == "heading") { @@ -1587,7 +1564,8 @@ template DocReformDocAbstraction() { html_segnames_ptr_cntr++; } if (the_glossary_section.length > 1) { - html_segnames ~= "glossary"; + segnames["html"] ~= "glossary"; + segnames["epub"] ~= "glossary"; html_segnames_ptr = html_segnames_ptr_cntr; foreach (ref obj; the_glossary_section) { if (obj.metainfo.is_a == "heading") { @@ -1601,7 +1579,8 @@ template DocReformDocAbstraction() { html_segnames_ptr_cntr++; } if (the_bibliography_section.length > 1) { - html_segnames ~= "bibliography"; + segnames["html"] ~= "bibliography"; + segnames["epub"] ~= "bibliography"; html_segnames_ptr = html_segnames_ptr_cntr; foreach (ref obj; the_bibliography_section) { if (obj.metainfo.is_a == "heading") { @@ -1614,10 +1593,11 @@ template DocReformDocAbstraction() { } html_segnames_ptr_cntr++; } - if (the_bookindex_section["scroll"].length > 1) { - html_segnames ~= "bookindex"; + if (the_bookindex_section.length > 1) { + segnames["html"] ~= "bookindex"; + segnames["epub"] ~= "bookindex"; html_segnames_ptr = html_segnames_ptr_cntr; - foreach (ref obj; the_bookindex_section["scroll"]) { + foreach (ref obj; the_bookindex_section) { if (obj.metainfo.is_a == "heading") { obj.metainfo.parent_ocn = obj.metainfo.markedup_ancestors[obj.metainfo.parent_lev_markup]; } @@ -1626,16 +1606,11 @@ template DocReformDocAbstraction() { break; } } - foreach (ref obj; the_bookindex_section["seg"]) { - if (obj.metainfo.heading_lev_markup == 4) { - obj.ptr.html_segnames = html_segnames_ptr; - break; - } - } html_segnames_ptr_cntr++; } if (the_blurb_section.length > 1) { - html_segnames ~= "blurb"; + segnames["html"] ~= "blurb"; + segnames["epub"] ~= "blurb"; html_segnames_ptr = html_segnames_ptr_cntr; foreach (ref obj; the_blurb_section) { if (obj.metainfo.is_a == "heading") { @@ -1767,17 +1742,18 @@ template DocReformDocAbstraction() { obj = obj_heading_ancestors(obj, lv_ancestors_txt); } } - if (the_table_of_contents_section["scroll"].length > 1) { + if (the_table_of_contents_section.length > 1) { /+ scroll +/ 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"]) { + 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; if (obj.metainfo.heading_lev_markup == 4) { - obj.tags.segname_next = html_segnames[obj.ptr.html_segnames + 1]; - assert(obj.tags.segment_anchor_tag_html == html_segnames[obj.ptr.html_segnames], - obj.tags.segment_anchor_tag_html ~ "!=" ~ html_segnames[obj.ptr.html_segnames]); + obj.tags.segname_next = segnames["html"][obj.ptr.html_segnames + 1]; + assert(obj.tags.anchor_tag_html == segnames["html"][obj.ptr.html_segnames], + obj.tags.anchor_tag_html ~ "!=" ~ segnames["html"][obj.ptr.html_segnames]); } } /+ dom structure (marked up & collapsed) +/ @@ -1793,36 +1769,18 @@ template DocReformDocAbstraction() { obj = obj_heading_ancestors(obj, lv_ancestors_txt); } } - /+ seg +/ - 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) { - writeln(obj.text); - } - if (obj.metainfo.heading_lev_markup <= 4) { - segnames_lv0_to_4 ~= obj.tags.segment_anchor_tag_epub; - if (obj.metainfo.heading_lev_markup == 4) { - obj.tags.segname_next = html_segnames[obj.ptr.html_segnames + 1]; - assert(obj.tags.segment_anchor_tag_html == html_segnames[obj.ptr.html_segnames], - obj.tags.segment_anchor_tag_html ~ "!=" ~ html_segnames[obj.ptr.html_segnames]); - } - } - if ((opt_action.html) - || (opt_action.html_scroll) - || (opt_action.html_seg) - || (opt_action.epub)) { - 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); - } - } } /+ multiple 1~ levels, loop through document body +/ if (the_document_body_section.length > 1) { foreach (ref obj; the_document_body_section) { + if (!(((obj.metainfo.ocn.to!string) in tag_assoc) + && ("seg_lv4" in tag_assoc[(obj.metainfo.ocn.to!string)])) + ) { + tag_assoc[(obj.metainfo.ocn.to!string)]["seg_lv4"] + = obj.tags.html_segment_anchor_tag_is; + } + tag_assoc[(obj.metainfo.ocn.to!string)]["seg_lv1_to_4"] + = obj.tags.epub_segment_anchor_tag_is; if (obj.metainfo.is_a == "heading") { debug(dom) { writeln(obj.text); @@ -1830,13 +1788,13 @@ template DocReformDocAbstraction() { if (obj.metainfo.heading_lev_markup <= 4) { segnames_lv0_to_4 ~= obj.tags.segment_anchor_tag_epub; if (obj.metainfo.heading_lev_markup == 4) { - obj.tags.lev4_subtoc = lev4_subtoc[obj.tags.segment_anchor_tag_html]; - obj.tags.segname_prev = html_segnames[obj.ptr.html_segnames - 1]; - if (html_segnames.length > obj.ptr.html_segnames + 1) { - obj.tags.segname_next = html_segnames[obj.ptr.html_segnames + 1]; + obj.tags.lev4_subtoc = lev4_subtoc[obj.tags.anchor_tag_html]; + obj.tags.segname_prev = segnames["html"][obj.ptr.html_segnames - 1]; + if (segnames["html"].length > obj.ptr.html_segnames + 1) { + obj.tags.segname_next = segnames["html"][obj.ptr.html_segnames + 1]; } - assert(obj.tags.segment_anchor_tag_html == html_segnames[obj.ptr.html_segnames], - obj.tags.segment_anchor_tag_html ~ "!=" ~ html_segnames[obj.ptr.html_segnames]); + assert(obj.tags.anchor_tag_html == segnames["html"][obj.ptr.html_segnames], + obj.tags.anchor_tag_html ~ "!=" ~ segnames["html"][obj.ptr.html_segnames]); } } /+ dom structure (marked up & collapsed) +/ @@ -1859,10 +1817,10 @@ template DocReformDocAbstraction() { auto images=uniq(_images.sort()); /+ optional only one 1~ level +/ if (the_endnotes_section.length > 1) { - dom_structure_markedup_tags_status_buffer = dom_structure_markedup_tags_status.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; + 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) { @@ -1873,12 +1831,12 @@ template DocReformDocAbstraction() { if (obj.metainfo.heading_lev_markup <= 4) { segnames_lv0_to_4 ~= obj.tags.segment_anchor_tag_epub; if (obj.metainfo.heading_lev_markup == 4) { - obj.tags.segname_prev = html_segnames[obj.ptr.html_segnames - 1]; - if (html_segnames.length > obj.ptr.html_segnames + 1) { - obj.tags.segname_next = html_segnames[obj.ptr.html_segnames + 1]; + obj.tags.segname_prev = segnames["html"][obj.ptr.html_segnames - 1]; + if (segnames["html"].length > obj.ptr.html_segnames + 1) { + obj.tags.segname_next = segnames["html"][obj.ptr.html_segnames + 1]; } - assert(obj.tags.segment_anchor_tag_html == html_segnames[obj.ptr.html_segnames], - obj.tags.segment_anchor_tag_html ~ "!=" ~ html_segnames[obj.ptr.html_segnames]); + assert(obj.tags.anchor_tag_html == segnames["html"][obj.ptr.html_segnames], + obj.tags.anchor_tag_html ~ "!=" ~ segnames["html"][obj.ptr.html_segnames]); } } /+ dom structure (marked up & collapsed) +/ @@ -1907,12 +1865,12 @@ template DocReformDocAbstraction() { if (obj.metainfo.heading_lev_markup <= 4) { segnames_lv0_to_4 ~= obj.tags.segment_anchor_tag_epub; if (obj.metainfo.heading_lev_markup == 4) { - obj.tags.segname_prev = html_segnames[obj.ptr.html_segnames - 1]; - if (html_segnames.length > obj.ptr.html_segnames + 1) { - obj.tags.segname_next = html_segnames[obj.ptr.html_segnames + 1]; + obj.tags.segname_prev = segnames["html"][obj.ptr.html_segnames - 1]; + if (segnames["html"].length > obj.ptr.html_segnames + 1) { + obj.tags.segname_next = segnames["html"][obj.ptr.html_segnames + 1]; } - assert(obj.tags.segment_anchor_tag_html == html_segnames[obj.ptr.html_segnames], - obj.tags.segment_anchor_tag_html ~ "!=" ~ html_segnames[obj.ptr.html_segnames]); + assert(obj.tags.anchor_tag_html == segnames["html"][obj.ptr.html_segnames], + obj.tags.anchor_tag_html ~ "!=" ~ segnames["html"][obj.ptr.html_segnames]); } } /+ dom structure (marked up & collapsed) +/ @@ -1944,12 +1902,12 @@ template DocReformDocAbstraction() { if (obj.metainfo.heading_lev_markup <= 4) { segnames_lv0_to_4 ~= obj.tags.segment_anchor_tag_epub; if (obj.metainfo.heading_lev_markup == 4) { - obj.tags.segname_prev = html_segnames[obj.ptr.html_segnames - 1]; - if (html_segnames.length > obj.ptr.html_segnames + 1) { - obj.tags.segname_next = html_segnames[obj.ptr.html_segnames + 1]; + obj.tags.segname_prev = segnames["html"][obj.ptr.html_segnames - 1]; + if (segnames["html"].length > obj.ptr.html_segnames + 1) { + obj.tags.segname_next = segnames["html"][obj.ptr.html_segnames + 1]; } - assert(obj.tags.segment_anchor_tag_html == html_segnames[obj.ptr.html_segnames], - obj.tags.segment_anchor_tag_html ~ "!=" ~ html_segnames[obj.ptr.html_segnames]); + assert(obj.tags.anchor_tag_html == segnames["html"][obj.ptr.html_segnames], + obj.tags.anchor_tag_html ~ "!=" ~ segnames["html"][obj.ptr.html_segnames]); } } /+ dom structure (marked up & collapsed) +/ @@ -1973,24 +1931,27 @@ template DocReformDocAbstraction() { int ocn_ = obj_cite_digits.on; int ocn_bkidx_ = 0; int ocn_bidx_; - if (the_bookindex_section["scroll"].length > 1) { + if (the_bookindex_section.length > 1) { /+ scroll +/ 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"]) { + foreach (ref obj; the_bookindex_section) { if (obj.metainfo.is_a == "heading") { debug(dom) { } + if (obj.metainfo.heading_lev_markup <= 4) { + segnames_lv0_to_4 ~= obj.tags.segment_anchor_tag_epub; + } obj_cite_digits = ocn_emit(OCNstatus.on); obj.metainfo.ocn = obj_cite_digits.on; if (obj.metainfo.heading_lev_markup <= 4) { if (obj.metainfo.heading_lev_markup == 4) { - obj.tags.segname_prev = html_segnames[obj.ptr.html_segnames - 1]; - if (html_segnames.length > obj.ptr.html_segnames + 1) { - obj.tags.segname_next = html_segnames[obj.ptr.html_segnames + 1]; + obj.tags.segname_prev = segnames["html"][obj.ptr.html_segnames - 1]; + if (segnames["html"].length > obj.ptr.html_segnames + 1) { + obj.tags.segname_next = segnames["html"][obj.ptr.html_segnames + 1]; } - assert(obj.tags.segment_anchor_tag_html == html_segnames[obj.ptr.html_segnames], - obj.tags.segment_anchor_tag_html ~ "!=" ~ html_segnames[obj.ptr.html_segnames]); + assert(obj.tags.anchor_tag_html == segnames["html"][obj.ptr.html_segnames], + obj.tags.anchor_tag_html ~ "!=" ~ segnames["html"][obj.ptr.html_segnames]); } } /+ dom structure (marked up & collapsed) +/ @@ -2011,43 +1972,6 @@ template DocReformDocAbstraction() { obj.metainfo.object_number_type = OCNtype.bkidx; } } - /+ seg +/ - 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) { - writeln(obj.text); - } - obj.metainfo.ocn = ++ocn_; - if (obj.metainfo.heading_lev_markup <= 4) { - segnames_lv0_to_4 ~= obj.tags.segment_anchor_tag_epub; - if (obj.metainfo.heading_lev_markup == 4) { - obj.tags.segname_prev = html_segnames[obj.ptr.html_segnames - 1]; - if (html_segnames.length > obj.ptr.html_segnames + 1) { - obj.tags.segname_next = html_segnames[obj.ptr.html_segnames + 1]; - } - assert(obj.tags.segment_anchor_tag_html == html_segnames[obj.ptr.html_segnames], - obj.tags.segment_anchor_tag_html ~ "!=" ~ html_segnames[obj.ptr.html_segnames]); - } - } - /+ dom structure (marked up & collapsed) +/ - if ((opt_action.html) - || (opt_action.html_scroll) - || (opt_action.html_seg) - || (opt_action.epub) - || (opt_action.sqlite_discrete) - || (opt_action.sqlite_update)) { - 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_; - obj.metainfo.o_n_book_index = ocn_bidx_; // FIX need to distinguish from regular ocn - obj.metainfo.object_number_type = OCNtype.bkidx; - } - } /+ TODO assert failure, reinstate assert(obj_cite_digit_bkidx == ocn_bidx_ obj_cite_digit_bkidx ~ " == ocn_" ~ ocn_ ~ "?"); @@ -2065,12 +1989,12 @@ template DocReformDocAbstraction() { if (obj.metainfo.heading_lev_markup <= 4) { segnames_lv0_to_4 ~= obj.tags.segment_anchor_tag_epub; if (obj.metainfo.heading_lev_markup == 4) { - obj.tags.segname_prev = html_segnames[obj.ptr.html_segnames - 1]; - if (html_segnames.length > obj.ptr.html_segnames + 1) { - obj.tags.segname_next = html_segnames[obj.ptr.html_segnames + 1]; + obj.tags.segname_prev = segnames["html"][obj.ptr.html_segnames - 1]; + if (segnames["html"].length > obj.ptr.html_segnames + 1) { + obj.tags.segname_next = segnames["html"][obj.ptr.html_segnames + 1]; } - assert(obj.tags.segment_anchor_tag_html == html_segnames[obj.ptr.html_segnames], - obj.tags.segment_anchor_tag_html ~ "!=" ~ html_segnames[obj.ptr.html_segnames]); + assert(obj.tags.anchor_tag_html == segnames["html"][obj.ptr.html_segnames], + obj.tags.anchor_tag_html ~ "!=" ~ segnames["html"][obj.ptr.html_segnames]); } } /+ dom structure (marked up & collapsed) +/ @@ -2098,7 +2022,7 @@ template DocReformDocAbstraction() { the_endnotes_section ~ the_glossary_section ~ the_bibliography_section ~ - the_bookindex_section["scroll"] ~ + the_bookindex_section ~ the_blurb_section ); debug(decendants_tuple) { @@ -2160,8 +2084,8 @@ template DocReformDocAbstraction() { } } } - if (the_bookindex_section["scroll"].length > 1) { - foreach (ref obj; the_bookindex_section["scroll"]) { + if (the_bookindex_section.length > 1) { + foreach (ref obj; the_bookindex_section) { if (obj.metainfo.is_a == "heading") { foreach (pair; pairs) { if (obj.metainfo.ocn == pair[0]) { @@ -2189,21 +2113,23 @@ template DocReformDocAbstraction() { - 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"; - comp_obj_heading_.metainfo.is_of_section = "empty"; - comp_obj_heading_.metainfo.is_of_type = "para"; - comp_obj_heading_.metainfo.is_a = "heading"; - comp_obj_heading_.metainfo.ocn = 0; - comp_obj_para.metainfo.object_number_off = ""; - comp_obj_para.metainfo.object_number_type = 0; - comp_obj_heading_.tags.segment_anchor_tag_html = ""; - comp_obj_heading_.tags.segment_anchor_tag_epub = ""; - comp_obj_heading_.tags.segment_anchor_tag_is = ""; - comp_obj_heading_.metainfo.heading_lev_markup = 9; - 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_ = comp_obj_heading_.init; + comp_obj_heading_.metainfo.is_of_part = "empty"; + comp_obj_heading_.metainfo.is_of_section = "empty"; + comp_obj_heading_.metainfo.is_of_type = "para"; + comp_obj_heading_.metainfo.is_a = "heading"; + comp_obj_heading_.metainfo.ocn = 0; + comp_obj_para.metainfo.object_number_off = ""; + comp_obj_para.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 = ""; + comp_obj_heading_.tags.html_segment_anchor_tag_is = ""; + comp_obj_heading_.tags.epub_segment_anchor_tag_is = ""; + comp_obj_heading_.metainfo.heading_lev_markup = 9; + 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_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); @@ -2212,23 +2138,21 @@ template DocReformDocAbstraction() { // the_dom_tail_section ~= comp_obj_heading_; // remove tail for now, decide on later auto document_the = [ "head": the_document_head_section, - "toc_seg": the_table_of_contents_section["seg"], - "toc_scroll": the_table_of_contents_section["scroll"], + "toc": the_table_of_contents_section, /+ substantive/body: +/ "body": the_document_body_section, /+ backmatter: +/ "endnotes": the_endnotes_section, "glossary": the_glossary_section, "bibliography": the_bibliography_section, - "bookindex_scroll": the_bookindex_section["scroll"], - "bookindex_seg": the_bookindex_section["seg"], + "bookindex": the_bookindex_section, "blurb": the_blurb_section, /+ dom tail only +/ "tail": the_dom_tail_section, ]; string[][string] document_section_keys_sequenced = [ - "seg": ["head", "toc_seg", "body",], - "scroll": ["head", "toc_scroll", "body",], + "seg": ["head", "toc", "body",], + "scroll": ["head", "toc", "body",], "sql": ["head", "body",] ]; if (document_the["endnotes"].length > 1) { @@ -2245,12 +2169,10 @@ template DocReformDocAbstraction() { document_section_keys_sequenced["scroll"] ~= "bibliography"; document_section_keys_sequenced["sql"] ~= "bibliography"; } - if (document_the["bookindex_seg"].length > 1) { - document_section_keys_sequenced["seg"] ~= "bookindex_seg"; - document_section_keys_sequenced["sql"] ~= "bookindex_seg"; - } - if (document_the["bookindex_scroll"].length > 1) { - document_section_keys_sequenced["scroll"] ~= "bookindex_scroll"; + if (document_the["bookindex"].length > 1) { + document_section_keys_sequenced["seg"] ~= "bookindex"; + document_section_keys_sequenced["scroll"] ~= "bookindex"; + document_section_keys_sequenced["sql"] ~= "bookindex"; } if (document_the["blurb"].length > 1) { document_section_keys_sequenced["seg"] ~= "blurb"; @@ -2265,7 +2187,12 @@ template DocReformDocAbstraction() { document_section_keys_sequenced["scroll"] ~= "tail"; } auto sequenced_document_keys = docSectKeysSeq!()(document_section_keys_sequenced); - auto segnames_lv4 = html_segnames.dup; + auto segnames_lv4 = segnames["html"].dup; + auto segnames_lv1_to_4 = segnames["epub"].dup; + debug(segnames) { + writeln("segnames_lv4: ", segnames_lv4); + writeln("segnames_lv1_to_4: ", segnames_lv1_to_4); + } destroy(the_document_head_section); destroy(the_table_of_contents_section); destroy(the_document_body_section); @@ -2274,7 +2201,7 @@ template DocReformDocAbstraction() { destroy(the_bibliography_section); destroy(the_bookindex_section); destroy(the_blurb_section); - destroy(html_segnames); + destroy(segnames); destroy(bookindex_unordered_hashes); destroy(an_object); obj_cite_digits = ocn_emit(OCNstatus.reset); @@ -2336,7 +2263,7 @@ template DocReformDocAbstraction() { sequenced_document_keys, segnames_lv4, segnames_lv0_to_4, - tag_assoc_html, + tag_assoc, images, ); return t; @@ -2500,7 +2427,7 @@ template DocReformDocAbstraction() { line ); } - object_number_poem["start"] = obj_cite_digits.on.to!string; + object_number_poem["start"] = obj_cite_digits.on.to!string; obj_type_status["blocks"] = TriState.on; obj_type_status["verse_new"] = State.on; obj_type_status["poem"] = TriState.on; @@ -2579,7 +2506,7 @@ template DocReformDocAbstraction() { line ); } - object_number_poem["start"] = obj_cite_digits.on.to!string; + object_number_poem["start"] = obj_cite_digits.on.to!string; obj_type_status["blocks"] = TriState.on; obj_type_status["verse_new"] = State.on; obj_type_status["poem"] = TriState.on; @@ -2691,7 +2618,7 @@ template DocReformDocAbstraction() { debug(group) { writeln(line); } - an_object[an_object_key] = an_object[an_object_key].stripRight; + an_object[an_object_key] = an_object[an_object_key].stripRight; obj_type_status["blocks"] = TriState.closing; obj_type_status["group"] = TriState.closing; obj_type_status["curly_group"] = TriState.off; @@ -2706,7 +2633,7 @@ template DocReformDocAbstraction() { debug(group) { writeln(line); } - an_object[an_object_key] = an_object[an_object_key].stripRight; + an_object[an_object_key] = an_object[an_object_key].stripRight; obj_type_status["blocks"] = TriState.closing; obj_type_status["group"] = TriState.closing; obj_type_status["tic_group"] = TriState.off; @@ -2734,7 +2661,7 @@ template DocReformDocAbstraction() { debug(block) { // block (curly) close writeln(line); } - an_object[an_object_key] = an_object[an_object_key].stripRight; + an_object[an_object_key] = an_object[an_object_key].stripRight; obj_type_status["blocks"] = TriState.closing; obj_type_status["block"] = TriState.closing; obj_type_status["curly_block"] = TriState.off; @@ -2749,7 +2676,7 @@ template DocReformDocAbstraction() { debug(block) { writeln(line); } - an_object[an_object_key] = an_object[an_object_key].stripRight; + an_object[an_object_key] = an_object[an_object_key].stripRight; obj_type_status["blocks"] = TriState.closing; obj_type_status["block"] = TriState.closing; obj_type_status["tic_block"] = TriState.off; @@ -2768,7 +2695,7 @@ template DocReformDocAbstraction() { return ref C cntr, N object_number_poem, CMM conf_make_meta, - Ts segment_anchor_tag_that_object_belongs_to, + Ts tag_in_seg, ) { debug(asserts) { static assert(is(typeof(line) == char[])); @@ -2812,22 +2739,23 @@ template DocReformDocAbstraction() { = obj_im.obj_inline_markup_and_anchor_tags_and_misc(an_object, an_object_key, conf_make_meta, false); an_object["substantive"] = substantive_obj_misc_tuple[sObj.content]; anchor_tag = substantive_obj_misc_tuple[sObj.anchor_tag]; - tag_assoc_html = inline_para_link_anchor(an_object, segment_anchor_tag_that_object_belongs_to, tag_assoc_html); - comp_obj_block = comp_obj_block.init; - comp_obj_block.metainfo.is_of_part = "body"; - comp_obj_block.metainfo.is_of_section = "body"; - comp_obj_block.metainfo.is_of_type = "block"; - comp_obj_block.metainfo.is_a = "verse"; - comp_obj_block.metainfo.ocn = obj_cite_digits.on; - comp_obj_block.metainfo.object_number_off = (obj_cite_digits.off==0) ? "" : obj_cite_digits.off.to!string; - comp_obj_block.tags.segment_anchor_tag_is = segment_anchor_tag_that_object_belongs_to["html"]; - comp_obj_block.metainfo.o_n_book_index = obj_cite_digits.bkidx; - comp_obj_block.metainfo.object_number_type = obj_cite_digits.type; - comp_obj_block.text = an_object["substantive"]; - comp_obj_block.has.inline_notes_reg = substantive_obj_misc_tuple[sObj.notes_reg]; - comp_obj_block.has.inline_notes_star = substantive_obj_misc_tuple[sObj.notes_star]; - comp_obj_block.has.inline_links = substantive_obj_misc_tuple[sObj.links]; - the_document_body_section ~= comp_obj_block; + comp_obj_block = comp_obj_block.init; + comp_obj_block.metainfo.is_of_part = "body"; + comp_obj_block.metainfo.is_of_section = "body"; + comp_obj_block.metainfo.is_of_type = "block"; + comp_obj_block.metainfo.is_a = "verse"; + comp_obj_block.metainfo.ocn = obj_cite_digits.on; + comp_obj_block.metainfo.object_number_off = (obj_cite_digits.off==0) ? "" : obj_cite_digits.off.to!string; + comp_obj_block.tags.html_segment_anchor_tag_is = tag_in_seg["seg_lv4"]; + comp_obj_block.tags.epub_segment_anchor_tag_is = tag_in_seg["seg_lv1_to_4"]; + comp_obj_block.metainfo.o_n_book_index = obj_cite_digits.bkidx; + comp_obj_block.metainfo.object_number_type = obj_cite_digits.type; + comp_obj_block.text = an_object["substantive"]; + comp_obj_block.has.inline_notes_reg = substantive_obj_misc_tuple[sObj.notes_reg]; + comp_obj_block.has.inline_notes_star = substantive_obj_misc_tuple[sObj.notes_star]; + comp_obj_block.has.inline_links = substantive_obj_misc_tuple[sObj.links]; + the_document_body_section ~= comp_obj_block; + tag_assoc = inline_para_link_anchor(an_object, tag_in_seg, tag_assoc); } object_reset(an_object); processing.remove("verse"); @@ -2861,9 +2789,9 @@ template DocReformDocAbstraction() { an_object["is"] = "verse"; auto comp_obj_location = node_construct.node_location_emitter( content_non_header, - segment_anchor_tag_that_object_belongs_to, + tag_in_seg, lev_anchor_tag, - tag_assoc_html, + tag_assoc, obj_cite_digits, cntr, heading_ptr-1, @@ -2873,22 +2801,23 @@ template DocReformDocAbstraction() { = obj_im.obj_inline_markup_and_anchor_tags_and_misc(an_object, an_object_key, conf_make_meta, false); an_object["substantive"] = substantive_obj_misc_tuple[sObj.content]; anchor_tag = substantive_obj_misc_tuple[sObj.anchor_tag]; - tag_assoc_html = inline_para_link_anchor(an_object, segment_anchor_tag_that_object_belongs_to, tag_assoc_html); - comp_obj_block = comp_obj_block.init; - comp_obj_block.metainfo.is_of_part = "body"; - comp_obj_block.metainfo.is_of_section = "body"; - comp_obj_block.metainfo.is_of_type = "block"; - comp_obj_block.metainfo.is_a = "verse"; - comp_obj_block.metainfo.ocn = obj_cite_digits.on; - comp_obj_block.metainfo.object_number_off = (obj_cite_digits.off==0) ? "" : obj_cite_digits.off.to!string; - comp_obj_block.tags.segment_anchor_tag_is = segment_anchor_tag_that_object_belongs_to["html"]; - comp_obj_block.metainfo.o_n_book_index = obj_cite_digits.bkidx; - comp_obj_block.metainfo.object_number_type = obj_cite_digits.type; - comp_obj_block.text = an_object["substantive"]; - comp_obj_block.has.inline_notes_reg = substantive_obj_misc_tuple[sObj.notes_reg]; - comp_obj_block.has.inline_notes_star = substantive_obj_misc_tuple[sObj.notes_star]; - comp_obj_block.has.inline_links = substantive_obj_misc_tuple[sObj.links]; - the_document_body_section ~= comp_obj_block; + comp_obj_block = comp_obj_block.init; + comp_obj_block.metainfo.is_of_part = "body"; + comp_obj_block.metainfo.is_of_section = "body"; + comp_obj_block.metainfo.is_of_type = "block"; + comp_obj_block.metainfo.is_a = "verse"; + comp_obj_block.metainfo.ocn = obj_cite_digits.on; + comp_obj_block.metainfo.object_number_off = (obj_cite_digits.off==0) ? "" : obj_cite_digits.off.to!string; + comp_obj_block.tags.html_segment_anchor_tag_is = tag_in_seg["seg_lv4"]; + comp_obj_block.tags.epub_segment_anchor_tag_is = tag_in_seg["seg_lv1_to_4"]; + comp_obj_block.metainfo.o_n_book_index = obj_cite_digits.bkidx; + comp_obj_block.metainfo.object_number_type = obj_cite_digits.type; + comp_obj_block.text = an_object["substantive"]; + comp_obj_block.has.inline_notes_reg = substantive_obj_misc_tuple[sObj.notes_reg]; + comp_obj_block.has.inline_notes_star = substantive_obj_misc_tuple[sObj.notes_star]; + comp_obj_block.has.inline_links = substantive_obj_misc_tuple[sObj.links]; + the_document_body_section ~= comp_obj_block; + tag_assoc = inline_para_link_anchor(an_object, tag_in_seg, tag_assoc); object_reset(an_object); processing.remove("verse"); ++cntr; @@ -2912,28 +2841,29 @@ template DocReformDocAbstraction() { writeln(obj_cite_digits.on, line); } processing.remove("verse"); - an_object["is"] = "verse"; + an_object["is"] = "verse"; auto substantive_obj_misc_tuple = obj_im.obj_inline_markup_and_anchor_tags_and_misc(an_object, an_object_key, conf_make_meta, false); an_object["substantive"] = substantive_obj_misc_tuple[sObj.content]; anchor_tag = substantive_obj_misc_tuple[sObj.anchor_tag]; - tag_assoc_html = inline_para_link_anchor(an_object, segment_anchor_tag_that_object_belongs_to, tag_assoc_html); - comp_obj_block = comp_obj_block.init; - comp_obj_block.metainfo.is_of_part = "body"; - comp_obj_block.metainfo.is_of_section = "body"; - comp_obj_block.metainfo.is_of_type = "block"; - comp_obj_block.metainfo.is_a = "verse"; - comp_obj_block.metainfo.ocn = obj_cite_digits.on; - comp_obj_block.metainfo.object_number_off = (obj_cite_digits.off==0) ? "" : obj_cite_digits.off.to!string; - comp_obj_block.tags.segment_anchor_tag_is = segment_anchor_tag_that_object_belongs_to["html"]; - comp_obj_block.metainfo.o_n_book_index = obj_cite_digits.bkidx; - comp_obj_block.metainfo.object_number_type = obj_cite_digits.type; - comp_obj_block.text = an_object["substantive"]; - comp_obj_block.has.inline_notes_reg = substantive_obj_misc_tuple[sObj.notes_reg]; - comp_obj_block.has.inline_notes_star = substantive_obj_misc_tuple[sObj.notes_star]; - comp_obj_block.has.inline_links = substantive_obj_misc_tuple[sObj.links]; - the_document_body_section ~= comp_obj_block; - object_number_poem["end"] = obj_cite_digits.on.to!string; + comp_obj_block = comp_obj_block.init; + comp_obj_block.metainfo.is_of_part = "body"; + comp_obj_block.metainfo.is_of_section = "body"; + comp_obj_block.metainfo.is_of_type = "block"; + comp_obj_block.metainfo.is_a = "verse"; + comp_obj_block.metainfo.ocn = obj_cite_digits.on; + comp_obj_block.metainfo.object_number_off = (obj_cite_digits.off==0) ? "" : obj_cite_digits.off.to!string; + comp_obj_block.tags.html_segment_anchor_tag_is = tag_in_seg["seg_lv4"]; + comp_obj_block.tags.epub_segment_anchor_tag_is = tag_in_seg["seg_lv1_to_4"]; + comp_obj_block.metainfo.o_n_book_index = obj_cite_digits.bkidx; + comp_obj_block.metainfo.object_number_type = obj_cite_digits.type; + comp_obj_block.text = an_object["substantive"]; + comp_obj_block.has.inline_notes_reg = substantive_obj_misc_tuple[sObj.notes_reg]; + comp_obj_block.has.inline_notes_star = substantive_obj_misc_tuple[sObj.notes_star]; + comp_obj_block.has.inline_links = substantive_obj_misc_tuple[sObj.links]; + the_document_body_section ~= comp_obj_block; + tag_assoc = inline_para_link_anchor(an_object, tag_in_seg, tag_assoc); + object_number_poem["end"] = obj_cite_digits.on.to!string; object_reset(an_object); processing.remove("verse"); ++cntr; @@ -2966,9 +2896,9 @@ template DocReformDocAbstraction() { auto comp_obj_location = node_construct.node_location_emitter( content_non_header, - segment_anchor_tag_that_object_belongs_to, + tag_in_seg, lev_anchor_tag, - tag_assoc_html, + tag_assoc, obj_cite_digits, cntr, heading_ptr-1, @@ -2978,22 +2908,23 @@ template DocReformDocAbstraction() { = obj_im.obj_inline_markup_and_anchor_tags_and_misc(an_object, an_object_key, conf_make_meta, false); an_object["substantive"] = substantive_obj_misc_tuple[sObj.content]; anchor_tag = substantive_obj_misc_tuple[sObj.anchor_tag]; - tag_assoc_html = inline_para_link_anchor(an_object, segment_anchor_tag_that_object_belongs_to, tag_assoc_html); - comp_obj_block = comp_obj_block.init; - comp_obj_block.metainfo.is_of_part = "body"; - comp_obj_block.metainfo.is_of_section = "body"; - comp_obj_block.metainfo.is_of_type = "block"; - comp_obj_block.metainfo.is_a = "verse"; - comp_obj_block.metainfo.ocn = obj_cite_digits.on; - comp_obj_block.metainfo.object_number_off = (obj_cite_digits.off==0) ? "" : obj_cite_digits.off.to!string; - comp_obj_block.tags.segment_anchor_tag_is = segment_anchor_tag_that_object_belongs_to["html"]; - comp_obj_block.metainfo.o_n_book_index = obj_cite_digits.bkidx; - comp_obj_block.metainfo.object_number_type = obj_cite_digits.type; - comp_obj_block.text = an_object["substantive"]; - comp_obj_block.has.inline_notes_reg = substantive_obj_misc_tuple[sObj.notes_reg]; - comp_obj_block.has.inline_notes_star = substantive_obj_misc_tuple[sObj.notes_star]; - comp_obj_block.has.inline_links = substantive_obj_misc_tuple[sObj.links]; - the_document_body_section ~= comp_obj_block; + comp_obj_block = comp_obj_block.init; + comp_obj_block.metainfo.is_of_part = "body"; + comp_obj_block.metainfo.is_of_section = "body"; + comp_obj_block.metainfo.is_of_type = "block"; + comp_obj_block.metainfo.is_a = "verse"; + comp_obj_block.metainfo.ocn = obj_cite_digits.on; + comp_obj_block.metainfo.object_number_off = (obj_cite_digits.off==0) ? "" : obj_cite_digits.off.to!string; + comp_obj_block.tags.html_segment_anchor_tag_is = tag_in_seg["seg_lv4"]; + comp_obj_block.tags.epub_segment_anchor_tag_is = tag_in_seg["seg_lv1_to_4"]; + comp_obj_block.metainfo.o_n_book_index = obj_cite_digits.bkidx; + comp_obj_block.metainfo.object_number_type = obj_cite_digits.type; + comp_obj_block.text = an_object["substantive"]; + comp_obj_block.has.inline_notes_reg = substantive_obj_misc_tuple[sObj.notes_reg]; + comp_obj_block.has.inline_notes_star = substantive_obj_misc_tuple[sObj.notes_star]; + comp_obj_block.has.inline_links = substantive_obj_misc_tuple[sObj.links]; + the_document_body_section ~= comp_obj_block; + tag_assoc = inline_para_link_anchor(an_object, tag_in_seg, tag_assoc); object_reset(an_object); processing.remove("verse"); ++cntr; @@ -3270,9 +3201,9 @@ template DocReformDocAbstraction() { auto comp_obj_location = node_construct.node_location_emitter( content_non_header, - segment_anchor_tag_that_object_belongs_to, + tag_in_seg, lev_anchor_tag, - tag_assoc_html, + tag_assoc, obj_cite_digits, cntr, heading_ptr-1, @@ -3281,15 +3212,16 @@ template DocReformDocAbstraction() { an_object["is"] = "table"; auto substantive_obj_misc_tuple = obj_im.obj_inline_markup_and_anchor_tags_and_misc(an_object, "body_nugget", conf_make_meta, false); - an_object["substantive"] = substantive_obj_misc_tuple[sObj.content]; - comp_obj_block.metainfo.ocn = obj_cite_digits.on; - comp_obj_block.metainfo.object_number_off = (obj_cite_digits.off==0) ? "" : obj_cite_digits.off.to!string; - comp_obj_block.tags.segment_anchor_tag_is = segment_anchor_tag_that_object_belongs_to["html"]; - comp_obj_block.metainfo.o_n_book_index = obj_cite_digits.bkidx; - comp_obj_block.metainfo.object_number_type = obj_cite_digits.type; - comp_obj_block = table_instructions(comp_obj_block, an_object["table_head"]); - comp_obj_block = table_substantive_munge_special(comp_obj_block, an_object["substantive"]); - the_document_body_section ~= comp_obj_block; + an_object["substantive"] = substantive_obj_misc_tuple[sObj.content]; + comp_obj_block.metainfo.ocn = obj_cite_digits.on; + comp_obj_block.metainfo.object_number_off = (obj_cite_digits.off==0) ? "" : obj_cite_digits.off.to!string; + comp_obj_block.tags.html_segment_anchor_tag_is = tag_in_seg["seg_lv4"]; + comp_obj_block.tags.epub_segment_anchor_tag_is = tag_in_seg["seg_lv1_to_4"]; + comp_obj_block.metainfo.o_n_book_index = obj_cite_digits.bkidx; + comp_obj_block.metainfo.object_number_type = obj_cite_digits.type; + comp_obj_block = table_instructions(comp_obj_block, an_object["table_head"]); + comp_obj_block = table_substantive_munge_special(comp_obj_block, an_object["substantive"]); + the_document_body_section ~= comp_obj_block; object_reset(an_object); processing.remove("verse"); ++cntr; @@ -3306,7 +3238,7 @@ template DocReformDocAbstraction() { return ref int[string] obj_type_status, string[string] object_number_poem, CMM conf_make_meta, - Ts segment_anchor_tag_that_object_belongs_to, + Ts tag_in_seg, ) { assert( line.empty, @@ -3326,15 +3258,15 @@ template DocReformDocAbstraction() { = bookindex_extract_hash.bookindex_nugget_hash( an_object["bookindex_nugget"], obj_cite_digits, - segment_anchor_tag_that_object_belongs_to + tag_in_seg ); an_object["is"] = "quote"; auto comp_obj_location = node_construct.node_location_emitter( content_non_header, - segment_anchor_tag_that_object_belongs_to, + tag_in_seg, lev_anchor_tag, - tag_assoc_html, + tag_assoc, obj_cite_digits, cntr, heading_ptr-1, @@ -3344,24 +3276,25 @@ template DocReformDocAbstraction() { = obj_im.obj_inline_markup_and_anchor_tags_and_misc(an_object, an_object_key, conf_make_meta, false); an_object["substantive"] = substantive_obj_misc_tuple[sObj.content]; anchor_tag = substantive_obj_misc_tuple[sObj.anchor_tag]; - tag_assoc_html = inline_para_link_anchor(an_object, segment_anchor_tag_that_object_belongs_to, tag_assoc_html); - comp_obj_block = comp_obj_block.init; - comp_obj_block.metainfo.is_of_part = "body"; - comp_obj_block.metainfo.is_of_section = "body"; - comp_obj_block.metainfo.is_of_type = "block"; - comp_obj_block.metainfo.is_a = "quote"; - comp_obj_block.metainfo.ocn = obj_cite_digits.on; - comp_obj_block.metainfo.object_number_off = (obj_cite_digits.off==0) ? "" : obj_cite_digits.off.to!string; - comp_obj_block.tags.segment_anchor_tag_is = segment_anchor_tag_that_object_belongs_to["html"]; - comp_obj_block.metainfo.o_n_book_index = obj_cite_digits.bkidx; - comp_obj_block.metainfo.object_number_type = obj_cite_digit_type; - comp_obj_block.text = an_object["substantive"]; - comp_obj_block.has.inline_notes_reg = substantive_obj_misc_tuple[sObj.notes_reg]; - comp_obj_block.has.inline_notes_star = substantive_obj_misc_tuple[sObj.notes_star]; - comp_obj_block.has.inline_links = substantive_obj_misc_tuple[sObj.links]; - the_document_body_section ~= comp_obj_block; - obj_type_status["blocks"] = TriState.off; - obj_type_status["quote"] = TriState.off; + comp_obj_block = comp_obj_block.init; + comp_obj_block.metainfo.is_of_part = "body"; + comp_obj_block.metainfo.is_of_section = "body"; + comp_obj_block.metainfo.is_of_type = "block"; + comp_obj_block.metainfo.is_a = "quote"; + comp_obj_block.metainfo.ocn = obj_cite_digits.on; + comp_obj_block.metainfo.object_number_off = (obj_cite_digits.off==0) ? "" : obj_cite_digits.off.to!string; + comp_obj_block.tags.html_segment_anchor_tag_is = tag_in_seg["seg_lv4"]; + comp_obj_block.tags.epub_segment_anchor_tag_is = tag_in_seg["seg_lv1_to_4"]; + comp_obj_block.metainfo.o_n_book_index = obj_cite_digits.bkidx; + comp_obj_block.metainfo.object_number_type = obj_cite_digit_type; + comp_obj_block.text = an_object["substantive"]; + comp_obj_block.has.inline_notes_reg = substantive_obj_misc_tuple[sObj.notes_reg]; + comp_obj_block.has.inline_notes_star = substantive_obj_misc_tuple[sObj.notes_star]; + comp_obj_block.has.inline_links = substantive_obj_misc_tuple[sObj.links]; + the_document_body_section ~= comp_obj_block; + tag_assoc = inline_para_link_anchor(an_object, tag_in_seg, tag_assoc); + obj_type_status["blocks"] = TriState.off; + obj_type_status["quote"] = TriState.off; object_reset(an_object); processing.remove("verse"); ++cntr; @@ -3373,15 +3306,15 @@ template DocReformDocAbstraction() { = bookindex_extract_hash.bookindex_nugget_hash( an_object["bookindex_nugget"], obj_cite_digits, - segment_anchor_tag_that_object_belongs_to + tag_in_seg ); an_object["is"] = "group"; auto comp_obj_location = node_construct.node_location_emitter( content_non_header, - segment_anchor_tag_that_object_belongs_to, + tag_in_seg, lev_anchor_tag, - tag_assoc_html, + tag_assoc, obj_cite_digits, cntr, heading_ptr-1, @@ -3391,24 +3324,25 @@ template DocReformDocAbstraction() { = obj_im.obj_inline_markup_and_anchor_tags_and_misc(an_object, an_object_key, conf_make_meta, false); an_object["substantive"] = substantive_obj_misc_tuple[sObj.content]; anchor_tag = substantive_obj_misc_tuple[sObj.anchor_tag]; - tag_assoc_html = inline_para_link_anchor(an_object, segment_anchor_tag_that_object_belongs_to, tag_assoc_html); - comp_obj_block = comp_obj_block.init; - comp_obj_block.metainfo.is_of_part = "body"; - comp_obj_block.metainfo.is_of_section = "body"; - comp_obj_block.metainfo.is_of_type = "block"; - comp_obj_block.metainfo.is_a = "group"; - comp_obj_block.metainfo.ocn = obj_cite_digits.on; - comp_obj_block.metainfo.object_number_off = (obj_cite_digits.off==0) ? "" : obj_cite_digits.off.to!string; - comp_obj_block.tags.segment_anchor_tag_is = segment_anchor_tag_that_object_belongs_to["html"]; - comp_obj_block.metainfo.o_n_book_index = obj_cite_digits.bkidx; - comp_obj_block.metainfo.object_number_type = obj_cite_digits.type; - comp_obj_block.text = an_object["substantive"]; - comp_obj_block.has.inline_notes_reg = substantive_obj_misc_tuple[sObj.notes_reg]; - comp_obj_block.has.inline_notes_star = substantive_obj_misc_tuple[sObj.notes_star]; - comp_obj_block.has.inline_links = substantive_obj_misc_tuple[sObj.links]; - the_document_body_section ~= comp_obj_block; - obj_type_status["blocks"] = TriState.off; - obj_type_status["group"] = TriState.off; + comp_obj_block = comp_obj_block.init; + comp_obj_block.metainfo.is_of_part = "body"; + comp_obj_block.metainfo.is_of_section = "body"; + comp_obj_block.metainfo.is_of_type = "block"; + comp_obj_block.metainfo.is_a = "group"; + comp_obj_block.metainfo.ocn = obj_cite_digits.on; + comp_obj_block.metainfo.object_number_off = (obj_cite_digits.off==0) ? "" : obj_cite_digits.off.to!string; + comp_obj_block.tags.html_segment_anchor_tag_is = tag_in_seg["seg_lv4"]; + comp_obj_block.tags.epub_segment_anchor_tag_is = tag_in_seg["seg_lv1_to_4"]; + comp_obj_block.metainfo.o_n_book_index = obj_cite_digits.bkidx; + comp_obj_block.metainfo.object_number_type = obj_cite_digits.type; + comp_obj_block.text = an_object["substantive"]; + comp_obj_block.has.inline_notes_reg = substantive_obj_misc_tuple[sObj.notes_reg]; + comp_obj_block.has.inline_notes_star = substantive_obj_misc_tuple[sObj.notes_star]; + comp_obj_block.has.inline_links = substantive_obj_misc_tuple[sObj.links]; + the_document_body_section ~= comp_obj_block; + tag_assoc = inline_para_link_anchor(an_object, tag_in_seg, tag_assoc); + obj_type_status["blocks"] = TriState.off; + obj_type_status["group"] = TriState.off; object_reset(an_object); processing.remove("verse"); ++cntr; @@ -3420,15 +3354,15 @@ template DocReformDocAbstraction() { = bookindex_extract_hash.bookindex_nugget_hash( an_object["bookindex_nugget"], obj_cite_digits, - segment_anchor_tag_that_object_belongs_to + tag_in_seg ); an_object["is"] = "block"; auto comp_obj_location = node_construct.node_location_emitter( content_non_header, - segment_anchor_tag_that_object_belongs_to, + tag_in_seg, lev_anchor_tag, - tag_assoc_html, + tag_assoc, obj_cite_digits, cntr, heading_ptr-1, @@ -3436,24 +3370,26 @@ template DocReformDocAbstraction() { ); auto substantive_obj_misc_tuple = obj_im.obj_inline_markup_and_anchor_tags_and_misc(an_object, an_object_key, conf_make_meta, false); - an_object["substantive"] = substantive_obj_misc_tuple[sObj.content]; - comp_obj_block = comp_obj_block.init; - comp_obj_block.metainfo.is_of_part = "body"; - comp_obj_block.metainfo.is_of_section = "body"; - comp_obj_block.metainfo.is_of_type = "block"; - comp_obj_block.metainfo.is_a = "block"; - comp_obj_block.metainfo.ocn = obj_cite_digits.on; - comp_obj_block.metainfo.object_number_off = (obj_cite_digits.off==0) ? "" : obj_cite_digits.off.to!string; - comp_obj_block.tags.segment_anchor_tag_is = segment_anchor_tag_that_object_belongs_to["html"]; - comp_obj_block.metainfo.o_n_book_index = obj_cite_digits.bkidx; - comp_obj_block.metainfo.object_number_type = obj_cite_digit_type; - comp_obj_block.text = an_object["substantive"]; - comp_obj_block.has.inline_notes_reg = substantive_obj_misc_tuple[sObj.notes_reg]; - comp_obj_block.has.inline_notes_star = substantive_obj_misc_tuple[sObj.notes_star]; - comp_obj_block.has.inline_links = substantive_obj_misc_tuple[sObj.links]; - the_document_body_section ~= comp_obj_block; - obj_type_status["blocks"] = TriState.off; - obj_type_status["block"] = TriState.off; + an_object["substantive"] = substantive_obj_misc_tuple[sObj.content]; + // anchor_tag = substantive_obj_misc_tuple[sObj.anchor_tag]; + comp_obj_block = comp_obj_block.init; + comp_obj_block.metainfo.is_of_part = "body"; + comp_obj_block.metainfo.is_of_section = "body"; + comp_obj_block.metainfo.is_of_type = "block"; + comp_obj_block.metainfo.is_a = "block"; + comp_obj_block.metainfo.ocn = obj_cite_digits.on; + comp_obj_block.metainfo.object_number_off = (obj_cite_digits.off==0) ? "" : obj_cite_digits.off.to!string; + comp_obj_block.tags.html_segment_anchor_tag_is = tag_in_seg["seg_lv4"]; + comp_obj_block.tags.epub_segment_anchor_tag_is = tag_in_seg["seg_lv1_to_4"]; + comp_obj_block.metainfo.o_n_book_index = obj_cite_digits.bkidx; + comp_obj_block.metainfo.object_number_type = obj_cite_digit_type; + comp_obj_block.text = an_object["substantive"]; + comp_obj_block.has.inline_notes_reg = substantive_obj_misc_tuple[sObj.notes_reg]; + comp_obj_block.has.inline_notes_star = substantive_obj_misc_tuple[sObj.notes_star]; + comp_obj_block.has.inline_links = substantive_obj_misc_tuple[sObj.links]; + the_document_body_section ~= comp_obj_block; + obj_type_status["blocks"] = TriState.off; + obj_type_status["block"] = TriState.off; object_reset(an_object); processing.remove("verse"); ++cntr; @@ -3464,15 +3400,15 @@ template DocReformDocAbstraction() { = bookindex_extract_hash.bookindex_nugget_hash( an_object["bookindex_nugget"], obj_cite_digits, - segment_anchor_tag_that_object_belongs_to + tag_in_seg ); an_object["is"] = "verse"; auto comp_obj_location = node_construct.node_location_emitter( content_non_header, - segment_anchor_tag_that_object_belongs_to, + tag_in_seg, lev_anchor_tag, - tag_assoc_html, + tag_assoc, obj_cite_digits, cntr, heading_ptr-1, @@ -3501,15 +3437,15 @@ template DocReformDocAbstraction() { = bookindex_extract_hash.bookindex_nugget_hash( an_object["bookindex_nugget"], obj_cite_digits, - segment_anchor_tag_that_object_belongs_to + tag_in_seg ); an_object["is"] = "code"; auto comp_obj_location = node_construct.node_location_emitter( content_non_header, - segment_anchor_tag_that_object_belongs_to, + tag_in_seg, lev_anchor_tag, - tag_assoc_html, + tag_assoc, obj_cite_digits, cntr, heading_ptr-1, @@ -3519,23 +3455,24 @@ template DocReformDocAbstraction() { = obj_im.obj_inline_markup_and_anchor_tags_and_misc(an_object, an_object_key, conf_make_meta, false); an_object["substantive"] = substantive_obj_misc_tuple[sObj.content]; anchor_tag = substantive_obj_misc_tuple[sObj.anchor_tag]; - comp_obj_code = comp_obj_code.init; - comp_obj_code.metainfo.is_of_part = "body"; - comp_obj_code.metainfo.is_of_section = "body"; - comp_obj_code.metainfo.is_of_type = "block"; - comp_obj_code.metainfo.is_a = "code"; - comp_obj_code.metainfo.ocn = obj_cite_digits.on; - comp_obj_code.metainfo.object_number_off = (obj_cite_digits.off==0) ? "" : obj_cite_digits.off.to!string; - comp_obj_code.tags.segment_anchor_tag_is = segment_anchor_tag_that_object_belongs_to["html"]; - comp_obj_code.metainfo.o_n_book_index = obj_cite_digits.bkidx; - comp_obj_code.metainfo.object_number_type = obj_cite_digits.type; - comp_obj_code.text = an_object["substantive"]; - comp_obj_code.has.inline_notes_reg = substantive_obj_misc_tuple[sObj.notes_reg]; - comp_obj_code.has.inline_notes_star = substantive_obj_misc_tuple[sObj.notes_star]; - comp_obj_code.has.inline_links = substantive_obj_misc_tuple[sObj.links]; - the_document_body_section ~= comp_obj_code; - obj_type_status["blocks"] = TriState.off; - obj_type_status["code"] = TriState.off; + comp_obj_code = comp_obj_code.init; + comp_obj_code.metainfo.is_of_part = "body"; + comp_obj_code.metainfo.is_of_section = "body"; + comp_obj_code.metainfo.is_of_type = "block"; + comp_obj_code.metainfo.is_a = "code"; + comp_obj_code.metainfo.ocn = obj_cite_digits.on; + comp_obj_code.metainfo.object_number_off = (obj_cite_digits.off==0) ? "" : obj_cite_digits.off.to!string; + comp_obj_code.tags.html_segment_anchor_tag_is = tag_in_seg["seg_lv4"]; + comp_obj_code.tags.epub_segment_anchor_tag_is = tag_in_seg["seg_lv1_to_4"]; + comp_obj_code.metainfo.o_n_book_index = obj_cite_digits.bkidx; + comp_obj_code.metainfo.object_number_type = obj_cite_digits.type; + comp_obj_code.text = an_object["substantive"]; + comp_obj_code.has.inline_notes_reg = substantive_obj_misc_tuple[sObj.notes_reg]; + comp_obj_code.has.inline_notes_star = substantive_obj_misc_tuple[sObj.notes_star]; + comp_obj_code.has.inline_links = substantive_obj_misc_tuple[sObj.links]; + the_document_body_section ~= comp_obj_code; + obj_type_status["blocks"] = TriState.off; + obj_type_status["code"] = TriState.off; object_reset(an_object); processing.remove("verse"); ++cntr; @@ -3548,15 +3485,15 @@ template DocReformDocAbstraction() { = bookindex_extract_hash.bookindex_nugget_hash( an_object["bookindex_nugget"], obj_cite_digits, - segment_anchor_tag_that_object_belongs_to + tag_in_seg ); an_object["is"] = "table"; auto comp_obj_location = node_construct.node_location_emitter( content_non_header, - segment_anchor_tag_that_object_belongs_to, + tag_in_seg, lev_anchor_tag, - tag_assoc_html, + tag_assoc, obj_cite_digits, cntr, heading_ptr-1, @@ -3564,18 +3501,19 @@ template DocReformDocAbstraction() { ); auto substantive_obj_misc_tuple = obj_im.obj_inline_markup_and_anchor_tags_and_misc(an_object, an_object_key, conf_make_meta, false); - an_object["substantive"] = substantive_obj_misc_tuple[sObj.content]; - comp_obj_block = comp_obj_block.init; - comp_obj_block.metainfo.ocn = obj_cite_digits.on; - comp_obj_block.metainfo.object_number_off = (obj_cite_digits.off==0) ? "" : obj_cite_digits.off.to!string; - comp_obj_block.tags.segment_anchor_tag_is = segment_anchor_tag_that_object_belongs_to["html"]; - comp_obj_block.metainfo.o_n_book_index = obj_cite_digits.bkidx; - comp_obj_block.metainfo.object_number_type = obj_cite_digits.type; - comp_obj_block = table_instructions(comp_obj_block, an_object["table_head"]); - comp_obj_block = table_substantive_munge(comp_obj_block, an_object["substantive"]); - the_document_body_section ~= comp_obj_block; - obj_type_status["blocks"] = TriState.off; - obj_type_status["table"] = TriState.off; + an_object["substantive"] = substantive_obj_misc_tuple[sObj.content]; + comp_obj_block = comp_obj_block.init; + comp_obj_block.metainfo.ocn = obj_cite_digits.on; + comp_obj_block.metainfo.object_number_off = (obj_cite_digits.off==0) ? "" : obj_cite_digits.off.to!string; + comp_obj_block.tags.html_segment_anchor_tag_is = tag_in_seg["seg_lv4"]; + comp_obj_block.tags.epub_segment_anchor_tag_is = tag_in_seg["seg_lv1_to_4"]; + comp_obj_block.metainfo.o_n_book_index = obj_cite_digits.bkidx; + comp_obj_block.metainfo.object_number_type = obj_cite_digits.type; + comp_obj_block = table_instructions(comp_obj_block, an_object["table_head"]); + comp_obj_block = table_substantive_munge(comp_obj_block, an_object["substantive"]); + the_document_body_section ~= comp_obj_block; + obj_type_status["blocks"] = TriState.off; + obj_type_status["table"] = TriState.off; object_reset(an_object); processing.remove("verse"); ++cntr; @@ -4737,18 +4675,18 @@ template DocReformDocAbstraction() { auto table_of_contents_gather_headings(O,CMM,Ts,Ta,X,Toc)( O obj_, CMM conf_make_meta, - Ts segment_anchor_tag_that_object_belongs_to, + Ts tag_in_seg, Ta _anchor_tag, return ref X lev4_subtoc, Toc the_table_of_contents_section, ) in { debug(asserts) { - static assert(is(typeof(obj_) == string[string])); - static assert(is(typeof(segment_anchor_tag_that_object_belongs_to) == string[string])); - static assert(is(typeof(_anchor_tag) == string)); - static assert(is(typeof(lev4_subtoc) == string[][string])); - static assert(is(typeof(the_table_of_contents_section) == ObjGenericComposite[][string])); + static assert(is(typeof(obj_) == string[string])); + static assert(is(typeof(tag_in_seg) == string[string])); + static assert(is(typeof(_anchor_tag) == string)); + static assert(is(typeof(lev4_subtoc) == string[][string])); + static assert(is(typeof(the_table_of_contents_section) == ObjGenericComposite[])); } } body { @@ -4784,7 +4722,7 @@ template DocReformDocAbstraction() { comp_obj_toc.attrib.bullet = false; comp_obj_toc.text = toc_txt_.to!string.strip; comp_obj_toc.has.inline_links = true; - the_table_of_contents_section["scroll"] ~= comp_obj_toc; + the_table_of_contents_section ~= comp_obj_toc; } else { indent=[ "hang_position" : 0, @@ -4803,7 +4741,7 @@ template DocReformDocAbstraction() { comp_obj_toc.attrib.bullet = false; comp_obj_toc.text = "Table of Contents"; comp_obj_toc.has.inline_links = true; - the_table_of_contents_section["scroll"] ~= comp_obj_toc; + the_table_of_contents_section ~= comp_obj_toc; } comp_obj_toc = comp_obj_toc.init; comp_obj_toc.metainfo.is_of_part = "frontmatter"; @@ -4816,83 +4754,21 @@ template DocReformDocAbstraction() { comp_obj_toc.attrib.bullet = false; comp_obj_toc.has.inline_links = true; switch (obj_["lev_markup_number"].to!int) { - case 0: - indent=[ - "hang_position" : 0, - "base_position" : 0, - ]; - toc_txt_ = "{ Table of Contents }" ~ mkup.mark_internal_site_lnk ~ "toc.fnSuffix"; - toc_txt_= munge.url_links(toc_txt_); - comp_obj_toc.attrib.indent_hang = indent["hang_position"]; - comp_obj_toc.attrib.indent_base = indent["base_position"]; - comp_obj_toc.text = toc_txt_.to!string.strip; - comp_obj_toc.has.inline_links = true; - the_table_of_contents_section["seg"] ~= comp_obj_toc; - break; - case 1: .. case 3: - indent=[ - "hang_position" : obj_["lev_markup_number"].to!int, - "base_position" : obj_["lev_markup_number"].to!int, - ]; - toc_txt_ = format( - "%s", - heading_toc_, - ); - toc_txt_= munge.url_links(toc_txt_); - comp_obj_toc.attrib.indent_hang = indent["hang_position"]; - comp_obj_toc.attrib.indent_base = indent["base_position"]; - comp_obj_toc.text = toc_txt_.to!string.strip; - comp_obj_toc.has.inline_links = true; - the_table_of_contents_section["seg"] ~= comp_obj_toc; + case 0: .. case 3: break; case 4: - toc_txt_ = format( - "{ %s }%s%s%s", - heading_toc_, - mkup.mark_internal_site_lnk, - segment_anchor_tag_that_object_belongs_to["html"], - ".fnSuffix", - ); - lev4_subtoc[segment_anchor_tag_that_object_belongs_to["html"]] = []; - toc_txt_= munge.url_links(toc_txt_); - indent=[ - "hang_position" : obj_["lev_markup_number"].to!int, - "base_position" : obj_["lev_markup_number"].to!int, - ]; - comp_obj_toc.attrib.indent_hang = indent["hang_position"]; - comp_obj_toc.attrib.indent_base = indent["base_position"]; - comp_obj_toc.text = toc_txt_.to!string.strip; - comp_obj_toc.has.inline_links = true; - the_table_of_contents_section["seg"] ~= comp_obj_toc; + lev4_subtoc[tag_in_seg["seg_lv4"]] = []; break; case 5: .. case 7: - toc_txt_ = format( - "{ %s }%s%s%s#%s", - heading_toc_, - mkup.mark_internal_site_lnk, - segment_anchor_tag_that_object_belongs_to["html"], - ".fnSuffix", - _anchor_tag, - ); subtoc_txt_ = format( "{ %s }#%s", heading_toc_, _anchor_tag, ); - lev4_subtoc[segment_anchor_tag_that_object_belongs_to["html"]] + lev4_subtoc[tag_in_seg["seg_lv4"]] ~= munge.url_links(obj_["lev_markup_number"] ~ "~ " ~ subtoc_txt_.to!string.strip ); - toc_txt_= munge.url_links(toc_txt_); - indent=[ - "hang_position" : obj_["lev_markup_number"].to!int, - "base_position" : obj_["lev_markup_number"].to!int, - ]; - comp_obj_toc.attrib.indent_hang = indent["hang_position"]; - comp_obj_toc.attrib.indent_base = indent["base_position"]; - comp_obj_toc.text = toc_txt_.to!string.strip; - comp_obj_toc.has.inline_links = true; - the_table_of_contents_section["seg"] ~= comp_obj_toc; break; default: break; @@ -4904,6 +4780,7 @@ template DocReformDocAbstraction() { private: static int[] heading_num = [ 0, 0, 0, 0 ]; static string heading_number_auto_composite = ""; + static string heading_number_auto_composite_segname = ""; static string _configured_auto_heading_numbering_and_segment_anchor_tags(M,O,CMM)( M munge_, O obj_, @@ -4997,6 +4874,10 @@ template DocReformDocAbstraction() { } else { heading_number_auto_composite = ""; } + heading_number_auto_composite_segname = + (heading_number_auto_composite.empty) + ? "" + : "seg_" ~ heading_number_auto_composite; debug(heading_number_auto) { writeln(heading_number_auto_composite); } @@ -5006,7 +4887,7 @@ template DocReformDocAbstraction() { .replaceFirst(rgx.heading, "$1~$2 " ~ heading_number_auto_composite ~ ". ") .replaceFirst(rgx.heading_marker_missing_tag, - "$1~" ~ heading_number_auto_composite ~ " "); + "$1~" ~ heading_number_auto_composite_segname ~ " "); } } return munge_; @@ -5364,7 +5245,7 @@ template DocReformDocAbstraction() { string[][string][string] bookindex_nugget_hash(BI,N,S)( BI bookindex_section, N obj_cite_digits, - S segment_anchor_tag_that_object_belongs_to, + S tag_in_seg, ) in { debug(asserts) { @@ -5375,7 +5256,9 @@ template DocReformDocAbstraction() { if (!bookindex_section.empty) { writeln( "* [bookindex] ", - "[", obj_cite_digits.on.to!string, ": ", segment_anchor_tag_that_object_belongs_to["html"], "] ", bookindex_section + "[", obj_cite_digits.on.to!string, ": ", tag_in_seg["seg_lv4"], "] ", bookindex_section, + " - - - ", + "[", obj_cite_digits.on.to!string, "] ", bookindex_section ); } } @@ -5395,15 +5278,13 @@ template DocReformDocAbstraction() { object_number_offset = m.captures[2].to!int; object_number_endpoint=(obj_cite_digits.on + object_number_offset); object_numbers ~= (obj_cite_digits.on.to!string - ~ "-" ~ object_number_endpoint.to!string - ~ ":" ~ segment_anchor_tag_that_object_belongs_to["html"]); + ~ "-" ~ object_number_endpoint.to!string); } else { main_term = bi_main_term_and_rest[0].strip; - object_numbers ~= obj_cite_digits.on.to!string - ~ ":" ~ segment_anchor_tag_that_object_belongs_to["html"]; + object_numbers ~= obj_cite_digits.on.to!string; } bi[main_term]["_a"] ~= object_numbers; - object_numbers=null; + object_numbers = null; if (bi_main_term_and_rest.length > 1) { auto bi_sub_terms_split_arr = bi_main_term_and_rest[1].split( @@ -5415,12 +5296,10 @@ template DocReformDocAbstraction() { object_number_offset = m.captures[2].to!int; object_number_endpoint=(obj_cite_digits.on + object_number_offset); object_numbers ~= (obj_cite_digits.on.to!string - ~ " - " ~ object_number_endpoint.to!string - ~ ":" ~ segment_anchor_tag_that_object_belongs_to["html"]); + ~ " - " ~ object_number_endpoint.to!string); } else { sub_term = sub_terms_bits.strip; - object_numbers ~= obj_cite_digits.on.to!string - ~ ":" ~ segment_anchor_tag_that_object_belongs_to["html"]; + object_numbers ~= obj_cite_digits.on.to!string; } if (!empty(sub_term)) { bi[main_term][sub_term] ~= object_numbers; @@ -5517,14 +5396,14 @@ template DocReformDocAbstraction() { int[string] indent; auto mainkeys = bookindex_unordered_hashes.byKey.array.sort().release; - ObjGenericComposite[][string] bookindex_section; + ObjGenericComposite[] bookindex_section; ObjGenericComposite comp_obj_heading_, comp_obj_para; auto node_para_int_ = node_metadata_para_int; auto node_para_str_ = node_metadata_para_str; if ((mainkeys.length > 0) && (opt_action.backmatter && opt_action.section_bookindex)) { - string bi_tmp_seg, bi_tmp_scroll; + string bi_tmp; string[] bi_tmp_tags; comp_obj_heading_ = comp_obj_heading_.init; comp_obj_heading_.metainfo.is_of_part = "backmatter"; @@ -5535,15 +5414,17 @@ template DocReformDocAbstraction() { 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_html = "_part_book_index"; - comp_obj_heading_.tags.segment_anchor_tag_epub = comp_obj_heading_.tags.segment_anchor_tag_html; + comp_obj_heading_.tags.segment_anchor_tag_epub = "_part_book_index"; + comp_obj_heading_.tags.anchor_tag_html = comp_obj_heading_.tags.segment_anchor_tag_epub; + comp_obj_heading_.tags.in_segment_html = "bookindex"; 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.has.inline_links = true; - bookindex_section["scroll"] ~= comp_obj_heading_; - bookindex_section["seg"] ~= comp_obj_heading_; + bookindex_section ~= comp_obj_heading_; + tag_assoc[comp_obj_heading_.tags.anchor_tag_html]["seg_lv4"] = comp_obj_heading_.tags.in_segment_html; + tag_assoc[comp_obj_heading_.tags.segment_anchor_tag_epub]["seg_lv1_to_4"] = comp_obj_heading_.tags.segment_anchor_tag_epub; ++mkn; comp_obj_heading_ = comp_obj_heading_.init; comp_obj_heading_.metainfo.is_of_part = "backmatter"; @@ -5554,44 +5435,32 @@ template DocReformDocAbstraction() { 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_html = "bookindex"; - comp_obj_heading_.tags.segment_anchor_tag_epub = comp_obj_heading_.tags.segment_anchor_tag_html; + comp_obj_heading_.tags.segment_anchor_tag_epub = "bookindex"; + comp_obj_heading_.tags.anchor_tag_html = comp_obj_heading_.tags.segment_anchor_tag_epub; + comp_obj_heading_.tags.in_segment_html = comp_obj_heading_.tags.anchor_tag_html; 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.has.inline_links = false; comp_obj_heading_.tags.anchor_tags = ["bookindex"]; - bookindex_section["scroll"] ~= comp_obj_heading_; - bookindex_section["seg"] ~= comp_obj_heading_; + bookindex_section ~= comp_obj_heading_; + tag_assoc[comp_obj_heading_.tags.anchor_tag_html]["seg_lv4"] = comp_obj_heading_.tags.in_segment_html; + tag_assoc[comp_obj_heading_.tags.segment_anchor_tag_epub]["seg_lv1_to_4"] = comp_obj_heading_.tags.segment_anchor_tag_epub; ++mkn; import std.array : appender; auto buffer = appender!(char[])(); string[dchar] transTable = [' ' : "_"]; foreach (mainkey; mainkeys) { bi_tmp_tags = [""]; - bi_tmp_scroll = "!{" ~ mainkey ~ "}! "; + bi_tmp = "!{" ~ mainkey ~ "}! "; buffer.clear(); bi_tmp_tags ~= translate(mainkey, transTable); - bi_tmp_seg = "!{" ~ mainkey ~ "}! "; - auto bkidx_lnk_seg(string locs) { - string markup = ""; - if (auto m = locs.matchFirst(rgx.book_index_go_seg)) { - markup - = munge.url_links("{ " ~ m["link"] ~ " }" - ~ mkup.mark_internal_site_lnk ~ m["seg"] ~ ".fnSuffix" - ~ "#" ~ m["ocn"] ~ ", "); - } else { - writeln(__LINE__, ": ", locs); - } - return markup; - } - auto bkidx_lnk_scroll(string locs) { + auto bkidx_lnk(string locs) { string markup = ""; if (auto m = locs.matchFirst(rgx.book_index_go)) { markup = munge.url_links("{ " ~ m["link"] ~ " }" - ~ mkup.mark_internal_site_lnk ~ "#" ~ m["ocn"] ~ ", "); } else { writeln(__LINE__, ": ", locs); @@ -5599,35 +5468,29 @@ template DocReformDocAbstraction() { return markup; } foreach (ref_; bookindex_unordered_hashes[mainkey]["_a"]) { - bi_tmp_scroll ~= bkidx_lnk_scroll(ref_); - bi_tmp_seg ~= bkidx_lnk_seg(ref_); + bi_tmp ~= bkidx_lnk(ref_); } - bi_tmp_scroll ~= " \\\\\n "; - bi_tmp_seg ~= " \\\\\n "; + bi_tmp ~= " \\\\\n "; bookindex_unordered_hashes[mainkey].remove("_a"); auto subkeys = bookindex_unordered_hashes[mainkey].byKey.array.sort().release; foreach (subkey; subkeys) { - bi_tmp_scroll ~= subkey ~ ", "; + bi_tmp ~= subkey ~ ", "; buffer.clear(); bi_tmp_tags ~= translate(subkey, transTable); - bi_tmp_seg ~= subkey ~ ", "; foreach (ref_; bookindex_unordered_hashes[mainkey][subkey]) { - bi_tmp_scroll ~= bkidx_lnk_scroll(ref_); - bi_tmp_seg ~= bkidx_lnk_seg(ref_); + bi_tmp ~= bkidx_lnk(ref_); } - bi_tmp_scroll ~= " \\\\\n "; - bi_tmp_seg ~= " \\\\\n "; + bi_tmp ~= " \\\\\n "; ++skn; } - bi_tmp_scroll = (bi_tmp_scroll).replaceFirst(rgx.trailing_linebreak, ""); - bi_tmp_seg = (bi_tmp_seg).replaceFirst(rgx.trailing_linebreak, ""); + bi_tmp = (bi_tmp).replaceFirst(rgx.trailing_linebreak, ""); comp_obj_para = comp_obj_para.init; comp_obj_para.metainfo.is_of_part = "backmatter"; comp_obj_para.metainfo.is_of_section = "bookindex"; comp_obj_para.metainfo.is_of_type = "para"; comp_obj_para.metainfo.is_a = "bookindex"; - comp_obj_para.text = bi_tmp_scroll.to!string.strip; + comp_obj_para.text = bi_tmp.to!string.strip; comp_obj_para.metainfo.ocn = 0; comp_obj_para.metainfo.object_number_off = ""; comp_obj_para.metainfo.object_number_type = 0; @@ -5636,9 +5499,8 @@ template DocReformDocAbstraction() { comp_obj_para.attrib.indent_base = 1; comp_obj_para.attrib.bullet = false; comp_obj_para.has.inline_links = true; - bookindex_section["scroll"] ~= comp_obj_para; - comp_obj_para.text = bi_tmp_seg.to!string.strip; - bookindex_section["seg"] ~= comp_obj_para; + comp_obj_para.text = bi_tmp.to!string.strip; + bookindex_section ~= comp_obj_para; ++mkn; } } else { // no book index, (figure out what to do here) @@ -5651,8 +5513,7 @@ template DocReformDocAbstraction() { comp_obj_heading_.metainfo.heading_lev_collapsed = 1; comp_obj_heading_.metainfo.parent_ocn = 1; comp_obj_heading_.metainfo.parent_lev_markup = 0; - bookindex_section["scroll"] ~= comp_obj_heading_; - bookindex_section["seg"] ~= comp_obj_heading_; + bookindex_section ~= comp_obj_heading_; } auto t = tuple( bookindex_section, @@ -5669,7 +5530,7 @@ template DocReformDocAbstraction() { static auto rgx = Rgx(); private auto gather_notes_for_endnote_section( ObjGenericComposite[] contents_am, - string[string] segment_anchor_tag_that_object_belongs_to, + string[string] tag_in_seg, int cntr, ) in { @@ -5700,13 +5561,13 @@ template DocReformDocAbstraction() { writeln( "{^{", m.captures[1], ".}^}" ~ mkup.mark_internal_site_lnk, - segment_anchor_tag_that_object_belongs_to["html"], + tag_in_seg["seg_lv4"], ".fnSuffix#noteref_\n ", m.captures[1], " ", m.captures[2]); // sometimes need segment name (segmented html & epub) } // you need anchor for segments at this point -> object_notes["anchor"] ~= "note_" ~ m.captures[1] ~ "』"; - object_notes["notes"] ~= (segment_anchor_tag_that_object_belongs_to["html"].empty) + object_notes["notes"] ~= (tag_in_seg["seg_lv4"].empty) ? (munge.url_links( "{^{" ~ m.captures[1] ~ ".}^}#noteref_" ~ m.captures[1]) ~ " " @@ -5715,7 +5576,7 @@ template DocReformDocAbstraction() { : (munge.url_links( "{^{" ~ m.captures[1] ~ ".}^}" ~ mkup.mark_internal_site_lnk - ~ segment_anchor_tag_that_object_belongs_to["html"] + ~ tag_in_seg["seg_lv4"] ~ ".fnSuffix#noteref_" ~ m.captures[1]) ~ " " ~ m.captures[2] ~ "』" @@ -5763,13 +5624,16 @@ template DocReformDocAbstraction() { 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_html = "_part_endnotes"; - comp_obj_heading_.tags.segment_anchor_tag_epub = comp_obj_heading_.tags.segment_anchor_tag_html; + comp_obj_heading_.tags.segment_anchor_tag_epub = "_part_endnotes"; + comp_obj_heading_.tags.anchor_tag_html = comp_obj_heading_.tags.segment_anchor_tag_epub; + comp_obj_heading_.tags.in_segment_html = "endnotes"; 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; the_endnotes_section ~= comp_obj_heading_; + tag_assoc[comp_obj_heading_.tags.anchor_tag_html]["seg_lv4"] = comp_obj_heading_.tags.in_segment_html; + tag_assoc[comp_obj_heading_.tags.segment_anchor_tag_epub]["seg_lv1_to_4"] = comp_obj_heading_.tags.segment_anchor_tag_epub; ++mkn; comp_obj_heading_ = comp_obj_heading_.init; comp_obj_heading_.metainfo.is_of_part = "backmatter"; @@ -5780,14 +5644,17 @@ template DocReformDocAbstraction() { 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_html = "endnotes"; - comp_obj_heading_.tags.segment_anchor_tag_epub = comp_obj_heading_.tags.segment_anchor_tag_html; + comp_obj_heading_.tags.segment_anchor_tag_epub = "endnotes"; + comp_obj_heading_.tags.anchor_tag_html = comp_obj_heading_.tags.segment_anchor_tag_epub; + comp_obj_heading_.tags.in_segment_html = comp_obj_heading_.tags.anchor_tag_html; 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 = ["endnotes"]; the_endnotes_section ~= comp_obj_heading_; + tag_assoc[comp_obj_heading_.tags.anchor_tag_html]["seg_lv4"] = comp_obj_heading_.tags.in_segment_html; + tag_assoc[comp_obj_heading_.tags.segment_anchor_tag_epub]["seg_lv1_to_4"] = comp_obj_heading_.tags.segment_anchor_tag_epub; ++mkn; } else { comp_obj_heading_ = comp_obj_heading_.init; @@ -5940,9 +5807,9 @@ template DocReformDocAbstraction() { static auto rgx = Rgx(); ObjGenericComposite node_location_emitter(Lv,Tg,La,Ta,N,C,P,I)( Lv lev_markup_number, - Tg segment_anchor_tag_that_object_belongs_to, + Tg tag_in_seg, La lev_anchor_tag, - Ta tag_assoc_html, + Ta tag_assoc, N obj_cite_digits, C cntr_, P ptr_, @@ -5950,12 +5817,12 @@ template DocReformDocAbstraction() { ) in { debug(asserts) { - static assert(is(typeof(lev_markup_number) == string)); - static assert(is(typeof(segment_anchor_tag_that_object_belongs_to) == string[string])); - static assert(is(typeof(obj_cite_digits.on) == int)); - static assert(is(typeof(cntr_) == int)); - static assert(is(typeof(ptr_) == int)); - static assert(is(typeof(is_) == string)); + static assert(is(typeof(lev_markup_number) == string)); + static assert(is(typeof(tag_in_seg) == string[string])); + static assert(is(typeof(obj_cite_digits.on) == int)); + static assert(is(typeof(cntr_) == int)); + static assert(is(typeof(ptr_) == int)); + static assert(is(typeof(is_) == string)); } assert(is_ != "heading"); assert(obj_cite_digits.on.to!int >= 0); @@ -5977,14 +5844,14 @@ template DocReformDocAbstraction() { p_["object_number"] = lv4; } ObjGenericComposite comp_obj_location; - comp_obj_location = comp_obj_location.init; - comp_obj_location.metainfo.is_a = is_; - comp_obj_location.metainfo.ocn = obj_cite_digits.on; - comp_obj_location.tags.segment_anchor_tag_html = segment_anchor_tag_that_object_belongs_to["html"]; - comp_obj_location.tags.segment_anchor_tag_epub = segment_anchor_tag_that_object_belongs_to["epub"]; - comp_obj_location.tags.heading_lev_anchor_tag = lev_anchor_tag; - comp_obj_location.metainfo.parent_ocn = p_["object_number"]; - comp_obj_location.metainfo.parent_lev_markup = p_["lev_markup_number"]; + comp_obj_location = comp_obj_location.init; + comp_obj_location.metainfo.is_a = is_; + comp_obj_location.metainfo.ocn = obj_cite_digits.on; + comp_obj_location.tags.anchor_tag_html = tag_in_seg["seg_lv4"]; + comp_obj_location.tags.segment_anchor_tag_epub = tag_in_seg["seg_lv1_to_4"]; + comp_obj_location.tags.heading_lev_anchor_tag = lev_anchor_tag; + comp_obj_location.metainfo.parent_ocn = p_["object_number"]; + comp_obj_location.metainfo.parent_lev_markup = p_["lev_markup_number"]; debug(_node) { if (lev_markup_number.match(rgx.levels_numbered_headings)) { writeln("x ", _node.to!string); @@ -6003,9 +5870,9 @@ template DocReformDocAbstraction() { T _text, Lm lev_markup_number, Lc lev_collapsed_number, - TaB segment_anchor_tag_that_object_belongs_to, + TaB tag_in_seg, TaL lev_anchor_tag, - TA tag_assoc_html, + TA tag_assoc, N obj_cite_digits, C cntr_, P ptr_, @@ -6022,7 +5889,7 @@ template DocReformDocAbstraction() { static assert(is(typeof(lev) == string)); static assert(is(typeof(lev_markup_number) == string)); static assert(is(typeof(lev_collapsed_number) == string)); - static assert(is(typeof(segment_anchor_tag_that_object_belongs_to) == string[string])); + static assert(is(typeof(tag_in_seg) == string[string])); static assert(is(typeof(obj_cite_digits.on) == int)); static assert(is(typeof(cntr_) == int)); static assert(is(typeof(ptr_) == int)); @@ -6139,11 +6006,14 @@ template DocReformDocAbstraction() { _comp_obj_heading_.text = _text.to!string.strip; _comp_obj_heading_.metainfo.ocn = obj_cite_digits.on; _comp_obj_heading_.metainfo.object_number_off = (obj_cite_digits.off==0) ? "" : obj_cite_digits.off.to!string; + // _comp_obj_heading_.metainfo.o_n_book_index = obj_cite_digits.bkidx; _comp_obj_heading_.metainfo.object_number_type = obj_cite_digits.type; - _comp_obj_heading_.tags.segment_anchor_tag_html = segment_anchor_tag_that_object_belongs_to["html"]; - _comp_obj_heading_.tags.segment_anchor_tag_epub = _comp_obj_heading_.tags.segment_anchor_tag_html; + _comp_obj_heading_.tags.segment_anchor_tag_epub = tag_in_seg["seg_lv1_to_4"]; + _comp_obj_heading_.tags.anchor_tag_html = tag_in_seg["seg_lv4"]; + _comp_obj_heading_.tags.in_segment_html = _comp_obj_heading_.tags.anchor_tag_html; _comp_obj_heading_.tags.heading_lev_anchor_tag = lev_anchor_tag; - _comp_obj_heading_.tags.segment_anchor_tag_is = segment_anchor_tag_that_object_belongs_to["html"]; + _comp_obj_heading_.tags.html_segment_anchor_tag_is = tag_in_seg["seg_lv4"]; + _comp_obj_heading_.tags.epub_segment_anchor_tag_is = tag_in_seg["seg_lv1_to_4"]; _comp_obj_heading_.metainfo.heading_lev_markup = (!(lev_markup_number.empty) ? lev_markup_number.to!int : 0); _comp_obj_heading_.metainfo.heading_lev_collapsed = (!(lev_collapsed_number.empty) ? lev_collapsed_number.to!int : 0); _comp_obj_heading_.metainfo.parent_ocn = p_["object_number"]; @@ -6155,6 +6025,8 @@ template DocReformDocAbstraction() { _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; + tag_assoc[_comp_obj_heading_.tags.anchor_tag_html]["seg_lv4"] = _comp_obj_heading_.tags.in_segment_html; + tag_assoc[_comp_obj_heading_.tags.segment_anchor_tag_epub]["seg_lv1_to_4"] = _comp_obj_heading_.tags.segment_anchor_tag_epub; debug(_node) { if (lev_markup_number.match(rgx.levels_numbered_headings)) { writeln("* ", _node.to!string); diff --git a/src/doc_reform/meta/metadoc_summary.d b/src/doc_reform/meta/metadoc_summary.d index 6d4a01b..e44a12c 100644 --- a/src/doc_reform/meta/metadoc_summary.d +++ b/src/doc_reform/meta/metadoc_summary.d @@ -37,7 +37,7 @@ template DocReformAbstractionSummary() { check["last_object_number"] = obj.metainfo.object_number; } } - if (k == "bookindex_seg") { + if (k == "bookindex") { if (obj.metainfo.object_number_type == 2) { check["last_object_number_book_index"] = obj.metainfo.object_number_book_index; } @@ -59,7 +59,7 @@ template DocReformAbstractionSummary() { doc_matters.src.filename, markup.repeat_character_by_number_provided("-", char_repeat_number), "length toc arr:", - to!int(doc_abstraction["toc_seg"].length), + to!int(doc_abstraction["toc"].length), "length doc_abstraction arr:", to!int(doc_abstraction["body"].length), "last doc body ocn:", @@ -79,8 +79,8 @@ template DocReformAbstractionSummary() { ? (to!int(doc_abstraction["bibliography"].length)) : 0, "length bookindex:", - (doc_abstraction["bookindex_seg"].length > 1) - ? (to!int(doc_abstraction["bookindex_seg"].length)) + (doc_abstraction["bookindex"].length > 1) + ? (to!int(doc_abstraction["bookindex"].length)) : 0, " last book idx ocn:", to!int(check["last_object_number_book_index"]), diff --git a/src/doc_reform/meta/object_setter.d b/src/doc_reform/meta/object_setter.d index ebff33b..b3325fa 100644 --- a/src/doc_reform/meta/object_setter.d +++ b/src/doc_reform/meta/object_setter.d @@ -104,9 +104,11 @@ template ObjectSetter() { } struct DocObj_Tags_ { string[] heading_ancestors_text = [ "", "", "", "", "", "", "", "", ]; // TODO redundant? see markedup and collapsed ancestors DONE - string segment_anchor_tag_html = ""; + string anchor_tag_html = ""; + string in_segment_html = ""; string segment_anchor_tag_epub = ""; - string segment_anchor_tag_is = ""; + string html_segment_anchor_tag_is = ""; + string epub_segment_anchor_tag_is = ""; string heading_lev_anchor_tag = ""; string segname_prev = ""; string segname_next = ""; diff --git a/src/doc_reform/meta/rgx.d b/src/doc_reform/meta/rgx.d index 2ff08b3..6143656 100644 --- a/src/doc_reform/meta/rgx.d +++ b/src/doc_reform/meta/rgx.d @@ -189,8 +189,8 @@ static template DocReformRgxInit() { /+ bookindex split +/ static bi_main_terms_split = ctRegex!(`\s*;\s*`); static bi_main_term_plus_rest_split = ctRegex!(`\s*:\s*`); - static bi_sub_terms_plus_object_number_offset_split = ctRegex!(`\s*\|\s*`); - static bi_term_and_object_numbers_match = ctRegex!(`^(.+?)\+(\d+)`); + static bi_sub_terms_plus_object_number_offset_split = ctRegex!(`\s*\|\s*`); + static bi_term_and_object_numbers_match = ctRegex!(`^(.+?)\+(\d+)`); /+ language codes +/ auto language_codes = ctRegex!("(am|bg|bn|br|ca|cs|cy|da|de|el|en|eo|es|et|eu|fi|fr|ga|gl|he|hi|hr|hy|ia|is|it|ja|ko|la|lo|lt|lv|ml|mr|nl|no|nn|oc|pl|pt|pt_BR|ro|ru|sa|se|sk|sl|sq|sr|sv|ta|te|th|tk|tr|uk|ur|vi|zh)"); diff --git a/src/doc_reform/output/defaults.d b/src/doc_reform/output/defaults.d index f0173cc..36f5c8e 100644 --- a/src/doc_reform/output/defaults.d +++ b/src/doc_reform/output/defaults.d @@ -11,20 +11,20 @@ template InternalMarkup() { auto lnk_o = "┥"; auto lnk_c = "┝"; auto url_o = "┤"; auto url_c = "├"; auto mark_internal_site_lnk = "¤"; - auto nbsp = "░"; - auto br_line = "┘"; - auto br_nl = "┙"; - auto br_paragraph = "┚"; - auto br_obj = "break_obj"; - auto br_page_line = "┼"; - auto br_page = "┿"; - auto br_page_new = "╂"; - auto tc_s = "┊"; - auto tc_o = "┏"; - auto tc_c = "┚"; - auto tc_p = "┆"; - auto mono = "■"; - auto img = "☼"; + auto nbsp = "░"; + auto br_line = "┘"; + auto br_nl = "┙"; + auto br_paragraph = "┚"; + auto br_obj = "break_obj"; + auto br_page_line = "┼"; + auto br_page = "┿"; + auto br_page_new = "╂"; + auto tc_s = "┊"; + auto tc_o = "┏"; + auto tc_c = "┚"; + auto tc_p = "┆"; + auto mono = "■"; + auto img = "☼"; static string indent_by_spaces_provided(int indent, string _indent_spaces ="░░") { _indent_spaces = replicate(_indent_spaces, indent); return _indent_spaces; diff --git a/src/doc_reform/output/epub3.d b/src/doc_reform/output/epub3.d index 1bcf13d..e862a3f 100644 --- a/src/doc_reform/output/epub3.d +++ b/src/doc_reform/output/epub3.d @@ -102,8 +102,8 @@ template outputEPub3() { content ~= " " ~ "" ~ "\n "; content ~= "" ~ ""; debug(epubmanifest) { - foreach (s; doc_matters.xml.keys_seq.seg) { - foreach (obj; doc_abstraction[s]) { + foreach (part; doc_matters.xml.keys_seq.seg) { // TODO + foreach (obj; doc_abstraction[part]) { if (obj.metainfo.is_a == "heading") { if (obj.metainfo.heading_lev_markup == 4) { writefln( @@ -235,8 +235,8 @@ template outputEPub3() { doc_matters.conf_make_meta.meta.title_full, // title (doc_matters.conf_make_meta.meta.creator_author.empty) ? "" : " by " ~ doc_matters.conf_make_meta.meta.creator_author, // author - uuid, // uuid - "3", // content depth + uuid, // uuid + "3", // content depth doc_matters.conf_make_meta.meta.title_full, // title (doc_matters.conf_make_meta.meta.creator_author.empty) ? "" : doc_matters.conf_make_meta.meta.creator_author, // author @@ -311,7 +311,7 @@ template outputEPub3() { foreach (obj; doc_abstraction[part]) { string _txt = xhtml_format.special_characters(obj, obj.text); if (obj.metainfo.is_a == "heading") { - assert(part == "head" || "toc_seg" || "body" || "endnotes" || "glossary" || "bibliography" || "bookindex_seg" || "blurb" || "tail"); + assert(part == "head" || "toc" || "body" || "endnotes" || "glossary" || "bibliography" || "bookindex" || "blurb" || "tail"); switch (obj.metainfo.heading_lev_markup) { case 0: .. case 3: /+ fill buffer, and replace with new levels from 1 to 3 +/ @@ -356,21 +356,27 @@ template outputEPub3() { doc_epub3_endnotes[segment_filename] ~= t[1]; break; case 8: .. case 9: - if ((doc_matters.opt.action.debug_do)) { - writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a, ": ", obj.metainfo.heading_lev_markup); - writeln(__FILE__, ":", __LINE__, ": ", obj.text); + { /+ debug +/ + if (doc_matters.opt.action.debug_do + && doc_matters.opt.action.verbose) { + writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a, ": ", obj.metainfo.heading_lev_markup); + writeln(__FILE__, ":", __LINE__, ": ", obj.text); + } } break; default: - if ((doc_matters.opt.action.debug_do)) { - writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a, ": ", obj.metainfo.heading_lev_markup); + { /+ debug +/ + if (doc_matters.opt.action.debug_do + && doc_matters.opt.action.verbose) { + writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a, ": ", obj.metainfo.heading_lev_markup); + } } break; } } else { - assert(part == "head" || "toc_seg" || "body" || "endnotes" || "glossary" || "bibliography" || "bookindex_seg" || "blurb" || "tail"); + assert(part == "head" || "toc" || "body" || "endnotes" || "glossary" || "bibliography" || "bookindex" || "blurb" || "tail"); switch (obj.metainfo.is_of_part) { - case "frontmatter": assert(part == "head" || "toc_seg"); + case "frontmatter": assert(part == "head" || "toc"); switch (obj.metainfo.is_of_type) { case "para": switch (obj.metainfo.is_a) { @@ -380,15 +386,21 @@ template outputEPub3() { doc_epub3_endnotes[segment_filename] ~= t[1]; break; default: - if ((doc_matters.opt.action.debug_do)) { - writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a); + { /+ debug +/ + if (doc_matters.opt.action.debug_do + && doc_matters.opt.action.verbose) { + writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a); + } } break; } break; default: - if ((doc_matters.opt.action.debug_do)) { - writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_of_type); + { /+ debug +/ + if (doc_matters.opt.action.debug_do + && doc_matters.opt.action.verbose) { + writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_of_type); + } } break; } @@ -403,8 +415,11 @@ template outputEPub3() { doc_epub3_endnotes[segment_filename] ~= t[1]; break; default: - if ((doc_matters.opt.action.debug_do)) { - writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a); + { /+ debug +/ + if (doc_matters.opt.action.debug_do + && doc_matters.opt.action.verbose) { + writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a); + } } break; } @@ -441,21 +456,27 @@ template outputEPub3() { doc_epub3_endnotes[segment_filename] ~= ""; break; default: - if ((doc_matters.opt.action.debug_do)) { - writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a); + { /+ debug +/ + if (doc_matters.opt.action.debug_do + && doc_matters.opt.action.verbose) { + writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a); + } } break; } break; default: - if ((doc_matters.opt.action.debug_do)) { - writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_of_type); + { /+ debug +/ + if (doc_matters.opt.action.debug_do + && doc_matters.opt.action.verbose) { + writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_of_type); + } } break; } break; case "backmatter": - assert(part == "endnotes" || "glossary" || "bibliography" || "bookindex_seg" || "blurb" || "tail"); + assert(part == "endnotes" || "glossary" || "bibliography" || "bookindex" || "blurb" || "tail"); switch (obj.metainfo.is_of_type) { case "para": switch (obj.metainfo.is_a) { @@ -473,7 +494,7 @@ template outputEPub3() { doc_epub3[segment_filename] ~= t[0]; doc_epub3_endnotes[segment_filename] ~= t[1]; break; - case "bookindex": assert(part == "bookindex_seg"); + case "bookindex": assert(part == "bookindex"); auto t = xhtml_format.para_seg(doc_matters, obj, _txt, suffix, "epub"); doc_epub3[segment_filename] ~= t[0]; doc_epub3_endnotes[segment_filename] ~= t[1]; @@ -484,15 +505,21 @@ template outputEPub3() { doc_epub3_endnotes[segment_filename] ~= t[1]; break; default: - if ((doc_matters.opt.action.debug_do)) { - writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a); + { /+ debug +/ + if (doc_matters.opt.action.debug_do + && doc_matters.opt.action.verbose) { + writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a); + } } break; } break; default: - if ((doc_matters.opt.action.debug_do)) { - writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_of_type); + { /+ debug +/ + if (doc_matters.opt.action.debug_do + && doc_matters.opt.action.verbose) { + writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_of_type); + } } break; } @@ -500,8 +527,11 @@ template outputEPub3() { case "comment": break; default: - if ((doc_matters.opt.action.debug_do)) { - writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_of_part); + { /+ debug +/ + if (doc_matters.opt.action.debug_do + && doc_matters.opt.action.verbose) { + writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_of_part); + } } break; } @@ -600,15 +630,17 @@ template outputEPub3() { if (!exists(pth_epub3.base)) { pth_epub3.base.mkdirRecurse; } - debug(epub_output) { - if (!exists(pth_epub3.dbg_doc_meta_inf(doc_matters.src.filename))) { - pth_epub3.dbg_doc_meta_inf(doc_matters.src.filename).mkdirRecurse; - } - if (!exists(pth_epub3.dbg_doc_oebps_css(doc_matters.src.filename))) { - pth_epub3.dbg_doc_oebps_css(doc_matters.src.filename).mkdirRecurse; - } - if (!exists(pth_epub3.dbg_doc_oebps_image(doc_matters.src.filename))) { - pth_epub3.dbg_doc_oebps_image(doc_matters.src.filename).mkdirRecurse; + { /+ debug +/ + if (doc_matters.opt.action.debug_do) { + if (!exists(pth_epub3.dbg_doc_meta_inf(doc_matters.src.filename))) { + pth_epub3.dbg_doc_meta_inf(doc_matters.src.filename).mkdirRecurse; + } + if (!exists(pth_epub3.dbg_doc_oebps_css(doc_matters.src.filename))) { + pth_epub3.dbg_doc_oebps_css(doc_matters.src.filename).mkdirRecurse; + } + if (!exists(pth_epub3.dbg_doc_oebps_image(doc_matters.src.filename))) { + pth_epub3.dbg_doc_oebps_image(doc_matters.src.filename).mkdirRecurse; + } } } { /+ OEBPS/[segments].xhtml (the document contents) +/ @@ -617,19 +649,25 @@ template outputEPub3() { auto zip_arc_member_file = new ArchiveMember(); zip_arc_member_file.name = fn; auto zip_data = new OutBuffer(); - debug(epub_output) { - string fn_dbg = pth_epub3.dbg_fn_oebps_content_xhtml(doc_matters.src.filename, seg_filename); - auto f = File(fn_dbg, "w"); + { /+ debug +/ + if (doc_matters.opt.action.debug_do) { + string fn_dbg = pth_epub3.dbg_fn_oebps_content_xhtml(doc_matters.src.filename, seg_filename); + auto f = File(fn_dbg, "w"); + foreach (docseg; doc_epub3[seg_filename]) { + f.writeln(docseg); + } + foreach (docseg; doc_epub3_endnotes[seg_filename]) { + f.writeln(docseg); + } + f.writeln(xhtml_format.tail); + } } foreach (docseg; doc_epub3[seg_filename]) { - debug(epub_output) { f.writeln(docseg); } zip_data.write(docseg.dup); } foreach (docseg; doc_epub3_endnotes[seg_filename]) { - debug(epub_output) { f.writeln(docseg); } zip_data.write(docseg.dup); } - debug(epub_output) { f.writeln(xhtml_format.tail); } zip_data.write(xhtml_format.tail.dup); zip_arc_member_file.expandedData = zip_data.toBytes(); zip.addMember(zip_arc_member_file); @@ -638,12 +676,14 @@ template outputEPub3() { } } string fn; - debug(epub_output) { string fn_dbg; } + string fn_dbg; File f; { /+ mimetypes (identify zip file type) +/ - debug(epub_output) { - fn_dbg = pth_epub3.dbg_fn_mimetypes(doc_matters.src.filename); - File(fn_dbg, "w").writeln(mimetypes); + { /+ debug +/ + if (doc_matters.opt.action.debug_do) { + fn_dbg = pth_epub3.dbg_fn_mimetypes(doc_matters.src.filename); + File(fn_dbg, "w").writeln(mimetypes); + } } fn = pth_epub3.fn_mimetypes(doc_matters.src.filename); auto zip_arc_member_file = new ArchiveMember(); @@ -655,9 +695,11 @@ template outputEPub3() { createZipFile!()(fn_epub, zip.build()); } { /+ META-INF/container.xml (identify doc root) +/ - debug(epub_output) { - fn_dbg = pth_epub3.dbg_fn_dmi_container_xml(doc_matters.src.filename); - File(fn_dbg, "w").writeln(meta_inf_container_xml); + { /+ debug +/ + if (doc_matters.opt.action.debug_do) { + fn_dbg = pth_epub3.dbg_fn_dmi_container_xml(doc_matters.src.filename); + File(fn_dbg, "w").writeln(meta_inf_container_xml); + } } fn = pth_epub3.fn_dmi_container_xml(doc_matters.src.filename); auto zip_arc_member_file = new ArchiveMember(); @@ -669,9 +711,11 @@ template outputEPub3() { createZipFile!()(fn_epub, zip.build()); } { /+ OEBPS/toc_nav.xhtml (navigation toc epub3) +/ - debug(epub_output) { - fn_dbg = pth_epub3.dbg_fn_oebps_toc_nav_xhtml(doc_matters.src.filename); - File(fn_dbg, "w").writeln(oebps_toc_nav_xhtml); + { /+ debug +/ + if (doc_matters.opt.action.debug_do) { + fn_dbg = pth_epub3.dbg_fn_oebps_toc_nav_xhtml(doc_matters.src.filename); + File(fn_dbg, "w").writeln(oebps_toc_nav_xhtml); + } } fn = pth_epub3.fn_oebps_toc_nav_xhtml(doc_matters.src.filename); auto zip_arc_member_file = new ArchiveMember(); @@ -683,9 +727,11 @@ template outputEPub3() { createZipFile!()(fn_epub, zip.build()); } { /+ OEBPS/toc.ncx (navigation toc epub2) +/ - debug(epub_output) { - fn_dbg = pth_epub3.dbg_fn_oebps_toc_ncx(doc_matters.src.filename); - File(fn_dbg, "w").writeln(oebps_toc_ncx); + { /+ debug +/ + if (doc_matters.opt.action.debug_do) { + fn_dbg = pth_epub3.dbg_fn_oebps_toc_ncx(doc_matters.src.filename); + File(fn_dbg, "w").writeln(oebps_toc_ncx); + } } fn = pth_epub3.fn_oebps_toc_ncx(doc_matters.src.filename); auto zip_arc_member_file = new ArchiveMember(); @@ -697,9 +743,11 @@ template outputEPub3() { createZipFile!()(fn_epub, zip.build()); } { /+ OEBPS/content.opf (doc manifest) +/ - debug(epub_output) { - fn_dbg = pth_epub3.dbg_fn_oebps_content_opf(doc_matters.src.filename); - File(fn_dbg, "w").writeln(oebps_content_opf); + { /+ debug +/ + if (doc_matters.opt.action.debug_do) { + fn_dbg = pth_epub3.dbg_fn_oebps_content_opf(doc_matters.src.filename); + File(fn_dbg, "w").writeln(oebps_content_opf); + } } fn = pth_epub3.fn_oebps_content_opf(doc_matters.src.filename); auto zip_arc_member_file = new ArchiveMember(); @@ -712,20 +760,18 @@ template outputEPub3() { } { /+ OEBPS/_sisu/image (images) +/ foreach (image; doc_matters.srcs.image_list) { - debug(epub_output) { - if (exists(doc_matters.src_path_info.image_root ~ "/" ~ image)) { - (doc_matters.src_path_info.image_root ~ "/" ~ image) - .copy((pth_epub3.dbg_doc_oebps_image(doc_matters.src.filename)) ~ "/" ~ image); - } - } - } - foreach (image; doc_matters.srcs.image_list) { - debug(epub_output) { - debug(epub_images) { - writeln( - doc_matters.src.image_dir_path, "/", image, " -> ", - pth_epub3.dbg_doc_oebps_image(doc_matters.src.filename), "/", image - ); + { /+ debug +/ + if (doc_matters.opt.action.debug_do) { + if (doc_matters.opt.action.very_verbose) { + writeln( + doc_matters.src.image_dir_path, "/", image, " -> ", + pth_epub3.dbg_doc_oebps_image(doc_matters.src.filename), "/", image + ); + } + if (exists(doc_matters.src.image_dir_path ~ "/" ~ image)) { + (doc_matters.src.image_dir_path ~ "/" ~ image) + .copy((pth_epub3.dbg_doc_oebps_image(doc_matters.src.filename)) ~ "/" ~ image); + } } } auto fn_src = doc_matters.src.image_dir_path ~ "/" ~ image; @@ -745,9 +791,11 @@ template outputEPub3() { } { /+ OEBPS/epub.css +/ auto css = DocReformCss(); - debug(epub_output) { - fn_dbg = pth_epub3.dbg_fn_oebps_css(doc_matters.src.filename); - File(fn_dbg, "w").writeln(css.epub_css); + { /+ debug +/ + if (doc_matters.opt.action.debug_do) { + fn_dbg = pth_epub3.dbg_fn_oebps_css(doc_matters.src.filename); + File(fn_dbg, "w").writeln(css.epub_css); + } } fn = pth_epub3.fn_oebps_css(doc_matters.src.filename); auto zip_arc_member_file = new ArchiveMember(); diff --git a/src/doc_reform/output/html.d b/src/doc_reform/output/html.d index 3424dc9..e247221 100644 --- a/src/doc_reform/output/html.d +++ b/src/doc_reform/output/html.d @@ -29,7 +29,7 @@ template outputHTML() { delimit = xhtml_format.div_delimit(part, previous_part); string _txt = xhtml_format.special_characters(obj, obj.text); switch (obj.metainfo.is_of_part) { - case "frontmatter": assert(part == "head" || "toc_scroll"); + case "frontmatter": assert(part == "head" || "toc"); switch (obj.metainfo.is_of_type) { case "para": switch (obj.metainfo.is_a) { @@ -40,15 +40,21 @@ template outputHTML() { doc_html ~= xhtml_format.para_scroll(doc_matters, obj, _txt, suffix); break; default: - if ((doc_matters.opt.action.debug_do)) { - writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a); + { /+ debug +/ + if (doc_matters.opt.action.debug_do + && doc_matters.opt.action.verbose) { + writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a); + } } break; } break; default: - if ((doc_matters.opt.action.debug_do)) { - writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_of_type); + { /+ debug +/ + if (doc_matters.opt.action.debug_do + && doc_matters.opt.action.verbose) { + writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_of_type); + } } break; } @@ -64,8 +70,11 @@ template outputHTML() { doc_html ~= xhtml_format.para_scroll(doc_matters, obj, _txt, suffix); break; default: - if ((doc_matters.opt.action.debug_do)) { - writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a); + { /+ debug +/ + if (doc_matters.opt.action.debug_do + && doc_matters.opt.action.verbose) { + writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a); + } } break; } @@ -93,21 +102,27 @@ template outputHTML() { doc_html ~= xhtml_format.table(doc_matters, obj, _txt); break; default: - if ((doc_matters.opt.action.debug_do)) { - writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a); + { /+ debug +/ + if (doc_matters.opt.action.debug_do + && doc_matters.opt.action.verbose) { + writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a); + } } break; } break; default: - if ((doc_matters.opt.action.debug_do)) { - writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_of_type); + { /+ debug +/ + if (doc_matters.opt.action.debug_do + && doc_matters.opt.action.verbose) { + writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_of_type); + } } break; } break; case "backmatter": - assert(part == "endnotes" || "glossary" || "bibliography" || "bookindex_scroll" || "blurb" || "tail"); + assert(part == "endnotes" || "glossary" || "bibliography" || "bookindex" || "blurb" || "tail"); switch (obj.metainfo.is_of_type) { case "para": switch (obj.metainfo.is_a) { @@ -123,22 +138,28 @@ template outputHTML() { case "bibliography": assert(part == "bibliography"); doc_html ~= xhtml_format.para_scroll(doc_matters, obj, _txt, suffix); break; - case "bookindex": assert(part == "bookindex_scroll"); + case "bookindex": assert(part == "bookindex"); doc_html ~= xhtml_format.para_scroll(doc_matters, obj, _txt, suffix); break; case "blurb": assert(part == "blurb"); doc_html ~= xhtml_format.para_scroll(doc_matters, obj, _txt, suffix); break; default: - if ((doc_matters.opt.action.debug_do)) { - writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a); + { /+ debug +/ + if (doc_matters.opt.action.debug_do + && doc_matters.opt.action.verbose) { + writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a); + } } break; } break; default: - if ((doc_matters.opt.action.debug_do)) { - writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_of_type); + { /+ debug +/ + if (doc_matters.opt.action.debug_do + && doc_matters.opt.action.verbose) { + writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_of_type); + } } break; } @@ -146,10 +167,13 @@ template outputHTML() { case "comment": break; default: - if ((doc_matters.opt.action.debug_do)) { - writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_of_part); - writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a); - writeln(__FILE__, ":", __LINE__, ": ", obj.text); + { /+ debug +/ + if (doc_matters.opt.action.debug_do + && doc_matters.opt.action.verbose) { + writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_of_part); + writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a); + writeln(__FILE__, ":", __LINE__, ": ", obj.text); + } } break; } @@ -202,7 +226,7 @@ template outputHTML() { delimit = xhtml_format.div_delimit(part, previous_part); string _txt = xhtml_format.special_characters(obj, obj.text); if (obj.metainfo.is_a == "heading") { - assert(part == "head" || "toc_seg" || "body" || "endnotes" || "glossary" || "bibliography" || "bookindex_seg" || "blurb" || "tail"); + assert(part == "head" || "toc" || "body" || "endnotes" || "glossary" || "bibliography" || "bookindex" || "blurb" || "tail"); switch (obj.metainfo.heading_lev_markup) { case 0: .. case 3: /+ fill buffer, and replace with new levels from 1 to 3 +/ @@ -251,21 +275,27 @@ template outputHTML() { doc_html_endnotes[segment_filename] ~= t[1]; break; case 8: .. case 9: - if ((doc_matters.opt.action.debug_do)) { - writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a, ": ", obj.metainfo.heading_lev_markup); - writeln(__FILE__, ":", __LINE__, ": ", obj.text); + { /+ debug +/ + if (doc_matters.opt.action.debug_do + && doc_matters.opt.action.verbose) { + writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a, ": ", obj.metainfo.heading_lev_markup); + writeln(__FILE__, ":", __LINE__, ": ", obj.text); + } } break; default: - if ((doc_matters.opt.action.debug_do)) { - writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a, ": ", obj.metainfo.heading_lev_markup); + { /+ debug +/ + if (doc_matters.opt.action.debug_do + && doc_matters.opt.action.verbose) { + writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a, ": ", obj.metainfo.heading_lev_markup); + } } break; } } else { - assert(part == "head" || "toc_seg" || "body" || "endnotes" || "glossary" || "bibliography" || "bookindex_seg" || "blurb" || "tail"); + assert(part == "head" || "toc" || "body" || "endnotes" || "glossary" || "bibliography" || "bookindex" || "blurb" || "tail"); switch (obj.metainfo.is_of_part) { - case "frontmatter": assert(part == "head" || "toc_seg"); + case "frontmatter": assert(part == "head" || "toc"); switch (obj.metainfo.is_of_type) { case "para": switch (obj.metainfo.is_a) { @@ -274,15 +304,21 @@ template outputHTML() { doc_html[segment_filename] ~= t[0].to!string; break; default: - if ((doc_matters.opt.action.debug_do)) { - writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a); + { /+ debug +/ + if (doc_matters.opt.action.debug_do + && doc_matters.opt.action.verbose) { + writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a); + } } break; } break; default: - if ((doc_matters.opt.action.debug_do)) { - writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a); + { /+ debug +/ + if (doc_matters.opt.action.debug_do + && doc_matters.opt.action.verbose) { + writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a); + } } break; } @@ -297,8 +333,11 @@ template outputHTML() { doc_html_endnotes[segment_filename] ~= t[1]; break; default: - if ((doc_matters.opt.action.debug_do)) { - writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a); + { /+ debug +/ + if (doc_matters.opt.action.debug_do + && doc_matters.opt.action.verbose) { + writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a); + } } break; } @@ -335,21 +374,27 @@ template outputHTML() { doc_html_endnotes[segment_filename] ~= ""; break; default: - if ((doc_matters.opt.action.debug_do)) { - writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a); + { /+ debug +/ + if (doc_matters.opt.action.debug_do + && doc_matters.opt.action.verbose) { + writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a); + } } break; } break; default: - if ((doc_matters.opt.action.debug_do)) { - writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_of_type); + { /+ debug +/ + if (doc_matters.opt.action.debug_do + && doc_matters.opt.action.verbose) { + writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_of_type); + } } break; } break; case "backmatter": - assert(part == "endnotes" || "glossary" || "bibliography" || "bookindex_seg" || "blurb" || "tail"); + assert(part == "endnotes" || "glossary" || "bibliography" || "bookindex" || "blurb" || "tail"); switch (obj.metainfo.is_of_type) { case "para": switch (obj.metainfo.is_a) { @@ -367,7 +412,7 @@ template outputHTML() { doc_html[segment_filename] ~= t[0]; doc_html_endnotes[segment_filename] ~= t[1]; break; - case "bookindex": assert(part == "bookindex_seg"); + case "bookindex": assert(part == "bookindex"); auto t = xhtml_format.para_seg(doc_matters, obj, _txt, suffix, "seg"); doc_html[segment_filename] ~= t[0]; doc_html_endnotes[segment_filename] ~= t[1]; @@ -378,15 +423,21 @@ template outputHTML() { doc_html_endnotes[segment_filename] ~= t[1]; break; default: - if ((doc_matters.opt.action.debug_do)) { - writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a); + { /+ debug +/ + if (doc_matters.opt.action.debug_do + && doc_matters.opt.action.verbose) { + writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a); + } } break; } break; default: - if ((doc_matters.opt.action.debug_do)) { - writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_of_type); + { /+ debug +/ + if (doc_matters.opt.action.debug_do + && doc_matters.opt.action.verbose) { + writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_of_type); + } } break; } @@ -394,8 +445,11 @@ template outputHTML() { case "comment": break; default: - if ((doc_matters.opt.action.debug_do)) { - writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_of_part); + { /+ debug +/ + if (doc_matters.opt.action.debug_do + && doc_matters.opt.action.verbose) { + writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_of_part); + } } break; } diff --git a/src/doc_reform/output/paths_output.d b/src/doc_reform/output/paths_output.d index 11232a9..f4dc083 100644 --- a/src/doc_reform/output/paths_output.d +++ b/src/doc_reform/output/paths_output.d @@ -185,46 +185,45 @@ template DocReformPathsEPUB() { string fn_oebps_css(string fn_src) { return asNormalizedPath(doc_oebps_css(fn_src).chainPath("epub.css")).array; } - debug(epub_output) { - string dbg_docdir(string fn_src) { - return base.chainPath(base_filename(fn_src)).array; - } - string dbg_docdir_oebps(string fn_src) { - return dbg_docdir(fn_src).chainPath("OEBPS").array; - } - string dbg_doc_meta_inf(string fn_src) { - return dbg_docdir(fn_src).chainPath("META-INF").array; - } - string dbg_doc_oebps(string fn_src) { - return dbg_docdir(fn_src).chainPath("OEBPS").array; - } - string dbg_doc_oebps_css(string fn_src) { - return dbg_doc_oebps(fn_src).chainPath("css").array; - } - string dbg_doc_oebps_image(string fn_src) { - return dbg_doc_oebps(fn_src).chainPath("image").array; - } - string dbg_fn_mimetypes(string fn_src) { - return dbg_docdir(fn_src).chainPath("mimetypes").array; - } - string dbg_fn_dmi_container_xml(string fn_src) { - return dbg_doc_meta_inf(fn_src).chainPath("container.xml").array; - } - string dbg_fn_oebps_toc_nav_xhtml(string fn_src) { - return dbg_docdir_oebps(fn_src).chainPath("toc_nav.xhtml").array; - } - string dbg_fn_oebps_toc_ncx(string fn_src) { - return dbg_docdir_oebps(fn_src).chainPath("toc.ncx").array; - } - string dbg_fn_oebps_content_opf(string fn_src) { - return dbg_docdir_oebps(fn_src).chainPath("content.opf").array; - } - string dbg_fn_oebps_content_xhtml(string fn_src, string seg_filename) { - return dbg_docdir_oebps(fn_src).chainPath(seg_filename ~ ".xhtml").array; - } - string dbg_fn_oebps_css(string fn_src) { - return dbg_doc_oebps_css(fn_src).chainPath("epub.css").array; - } + /+ debug +/ + string dbg_docdir(string fn_src) { + return base.chainPath(base_filename(fn_src)).array; + } + string dbg_docdir_oebps(string fn_src) { + return dbg_docdir(fn_src).chainPath("OEBPS").array; + } + string dbg_doc_meta_inf(string fn_src) { + return dbg_docdir(fn_src).chainPath("META-INF").array; + } + string dbg_doc_oebps(string fn_src) { + return dbg_docdir(fn_src).chainPath("OEBPS").array; + } + string dbg_doc_oebps_css(string fn_src) { + return dbg_doc_oebps(fn_src).chainPath("css").array; + } + string dbg_doc_oebps_image(string fn_src) { + return dbg_doc_oebps(fn_src).chainPath("image").array; + } + string dbg_fn_mimetypes(string fn_src) { + return dbg_docdir(fn_src).chainPath("mimetypes").array; + } + string dbg_fn_dmi_container_xml(string fn_src) { + return dbg_doc_meta_inf(fn_src).chainPath("container.xml").array; + } + string dbg_fn_oebps_toc_nav_xhtml(string fn_src) { + return dbg_docdir_oebps(fn_src).chainPath("toc_nav.xhtml").array; + } + string dbg_fn_oebps_toc_ncx(string fn_src) { + return dbg_docdir_oebps(fn_src).chainPath("toc.ncx").array; + } + string dbg_fn_oebps_content_opf(string fn_src) { + return dbg_docdir_oebps(fn_src).chainPath("content.opf").array; + } + string dbg_fn_oebps_content_xhtml(string fn_src, string seg_filename) { + return dbg_docdir_oebps(fn_src).chainPath(seg_filename ~ ".xhtml").array; + } + string dbg_fn_oebps_css(string fn_src) { + return dbg_doc_oebps_css(fn_src).chainPath("epub.css").array; } } return _PathsStruct(); diff --git a/src/doc_reform/output/sqlite.d b/src/doc_reform/output/sqlite.d index 0d31e2f..2456509 100644 --- a/src/doc_reform/output/sqlite.d +++ b/src/doc_reform/output/sqlite.d @@ -112,10 +112,13 @@ template SQLiteDbRun() { } catch (Exception ex) { writeln("ERROR SQLite : ", ex); } - if (opt_action.debug_do) { - writeln(note); - if (opt_action.verbose) { - writeln(db_statement); + { /+ debug +/ + if (opt_action.debug_do + && opt_action.verbose) { + writeln(note); + if (opt_action.very_verbose) { + writeln(db_statement); + } } } } @@ -158,8 +161,11 @@ template SQLiteFormatAndLoadObject() { if (_urls.length > 0) { _txt ~= _urls; } - if (doc_matters.opt.action.debug_do) { - writeln(_txt, "\n"); + { /+ debug +/ + if (doc_matters.opt.action.debug_do + && doc_matters.opt.action.verbose) { + writeln(_txt, "\n"); + } } debug(sql_text_clean) { writeln(_txt); @@ -206,8 +212,11 @@ template SQLiteFormatAndLoadObject() { if (_notes.length > 0) { _txt ~= _notes; } - if (doc_matters.opt.action.debug_do) { - writeln(_txt, "\n"); + { /+ debug +/ + if (doc_matters.opt.action.debug_do + && doc_matters.opt.action.verbose) { + writeln(_txt, "\n"); + } } return _txt; } @@ -285,7 +294,7 @@ template SQLiteFormatAndLoadObject() { 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])][0]) { + if (m.captures[3] == doc_matters.xml.tag_associations[(m.captures[3])]["seg_lv4"]) { _txt = _txt.replaceFirst( rgx.inline_link_hash, "┥$1┝┤" @@ -300,7 +309,7 @@ template SQLiteFormatAndLoadObject() { "┥$1┝┤" ~ doc_matters.conf_make_meta.conf.webserv_url_doc_root ~ "/" - ~ doc_matters.xml.tag_associations[(m.captures[3])][0] + ~ doc_matters.xml.tag_associations[(m.captures[3])]["seg_lv4"] ~ ".html" ~ "#" ~ "$3" ~ "├" @@ -621,15 +630,18 @@ template SQLiteFormatAndLoadObject() { "text": generic_munge_sanitize_text_for_search(obj.text), "html": html_heading(doc_matters, obj) ]; - if (doc_matters.opt.action.debug_do) { - debug(sql_txt) { - writeln(obj_txt["text"]); - } - debug(sql_html) { - writeln(obj_txt["html"]); + { /+ debug +/ + if (doc_matters.opt.action.debug_do + && doc_matters.opt.action.verbose) { + debug(sql_txt) { + writeln(obj_txt["text"]); + } + debug(sql_html) { + writeln(obj_txt["html"]); + } + } else { + // load sql } - } else { - // load sql } return obj_txt; } @@ -641,15 +653,18 @@ template SQLiteFormatAndLoadObject() { "text": generic_munge_sanitize_text_for_search(obj.text), "html": html_para(doc_matters, obj) ]; - if (doc_matters.opt.action.debug_do) { - debug(sql_txt) { - writeln(obj_txt["text"]); - } - debug(sql_html) { - writeln(obj_txt["html"]); + { /+ debug +/ + if (doc_matters.opt.action.debug_do + && doc_matters.opt.action.verbose) { + debug(sql_txt) { + writeln(obj_txt["text"]); + } + debug(sql_html) { + writeln(obj_txt["html"]); + } + } else { + // load sql } - } else { - // load sql } return obj_txt; } @@ -661,15 +676,18 @@ template SQLiteFormatAndLoadObject() { "text": generic_munge_sanitize_text_for_search(obj.text), "html": html_quote(doc_matters, obj) ]; - if (doc_matters.opt.action.debug_do) { - debug(sql_txt) { - writeln(obj_txt["text"]); - } - debug(sql_html) { - writeln(obj_txt["html"]); + { /+ debug +/ + if (doc_matters.opt.action.debug_do + && doc_matters.opt.action.verbose) { + debug(sql_txt) { + writeln(obj_txt["text"]); + } + debug(sql_html) { + writeln(obj_txt["html"]); + } + } else { + // load sql } - } else { - // load sql } return obj_txt; } @@ -681,15 +699,18 @@ template SQLiteFormatAndLoadObject() { "text": generic_munge_sanitize_text_for_search(obj.text), "html": html_group(doc_matters, obj) ]; - if (doc_matters.opt.action.debug_do) { - debug(sql_txt) { - writeln(obj_txt["text"]); - } - debug(sql_html) { - writeln(obj_txt["html"]); + { /+ debug +/ + if (doc_matters.opt.action.debug_do + && doc_matters.opt.action.verbose) { + debug(sql_txt) { + writeln(obj_txt["text"]); + } + debug(sql_html) { + writeln(obj_txt["html"]); + } + } else { + // load sql } - } else { - // load sql } return obj_txt; } @@ -701,15 +722,18 @@ template SQLiteFormatAndLoadObject() { "text": generic_munge_sanitize_text_for_search(obj.text), "html": html_block(doc_matters, obj) ]; - if (doc_matters.opt.action.debug_do) { - debug(sql_txt) { - writeln(obj_txt["text"]); - } - debug(sql_html) { - writeln(obj_txt["html"]); + { /+ debug +/ + if (doc_matters.opt.action.debug_do + && doc_matters.opt.action.verbose) { + debug(sql_txt) { + writeln(obj_txt["text"]); + } + debug(sql_html) { + writeln(obj_txt["html"]); + } + } else { + // load sql } - } else { - // load sql } return obj_txt; } @@ -721,15 +745,18 @@ template SQLiteFormatAndLoadObject() { "text": generic_munge_sanitize_text_for_search(obj.text), "html": html_verse(doc_matters, obj) ]; - if (doc_matters.opt.action.debug_do) { - debug(sql_txt) { - writeln(obj_txt["text"]); - } - debug(sql_html) { - writeln(obj_txt["html"]); + { /+ debug +/ + if (doc_matters.opt.action.debug_do + && doc_matters.opt.action.verbose) { + debug(sql_txt) { + writeln(obj_txt["text"]); + } + debug(sql_html) { + writeln(obj_txt["html"]); + } + } else { + // load sql } - } else { - // load sql } return obj_txt; } @@ -741,15 +768,18 @@ template SQLiteFormatAndLoadObject() { "text": generic_munge_sanitize_text_for_search(obj.text), "html": html_code(obj) ]; - if (doc_matters.opt.action.debug_do) { - debug(sql_txt) { - writeln(obj_txt["text"]); - } - debug(sql_html) { - writeln(obj_txt["html"]); + { /+ debug +/ + if (doc_matters.opt.action.debug_do + && doc_matters.opt.action.verbose) { + debug(sql_txt) { + writeln(obj_txt["text"]); + } + debug(sql_html) { + writeln(obj_txt["html"]); + } + } else { + // load sql } - } else { - // load sql } return obj_txt; } @@ -761,15 +791,18 @@ template SQLiteFormatAndLoadObject() { "text": generic_munge_sanitize_text_for_search(obj.text), "html": html_table(doc_matters, obj) ]; - if (doc_matters.opt.action.debug_do) { - debug(sql_txt) { - writeln(obj_txt["text"]); - } - debug(sql_html) { - writeln(obj_txt["html"]); + { /+ debug +/ + if (doc_matters.opt.action.debug_do + && doc_matters.opt.action.verbose) { + debug(sql_txt) { + writeln(obj_txt["text"]); + } + debug(sql_html) { + writeln(obj_txt["html"]); + } + } else { + // load sql } - } else { - // load sql } return obj_txt; } @@ -1139,15 +1172,21 @@ template SQLiteInsertDocObjectsLoop() { obj_txt = format_and_sqlite_load.heading(doc_matters, obj); break; default: - if ((doc_matters.opt.action.debug_do)) { - writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a); + { /+ debug +/ + if (doc_matters.opt.action.debug_do + && doc_matters.opt.action.verbose) { + writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a); + } } break; } break; default: - if ((doc_matters.opt.action.debug_do)) { - writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_of_type); + { /+ debug +/ + if (doc_matters.opt.action.debug_do + && doc_matters.opt.action.verbose) { + writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_of_type); + } } break; } @@ -1168,8 +1207,11 @@ template SQLiteInsertDocObjectsLoop() { obj_txt = format_and_sqlite_load.para(doc_matters, obj); break; default: - if ((doc_matters.opt.action.debug_do)) { - writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a); + { /+ debug +/ + if (doc_matters.opt.action.debug_do + && doc_matters.opt.action.verbose) { + writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a); + } } break; } @@ -1197,21 +1239,27 @@ template SQLiteInsertDocObjectsLoop() { obj_txt = format_and_sqlite_load.table(doc_matters, obj); break; default: - if ((doc_matters.opt.action.debug_do)) { - writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a); + { /+ debug +/ + if (doc_matters.opt.action.debug_do + && doc_matters.opt.action.verbose) { + writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a); + } } break; } break; default: - if ((doc_matters.opt.action.debug_do)) { - writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_of_type); + { /+ debug +/ + if (doc_matters.opt.action.debug_do + && doc_matters.opt.action.verbose) { + writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_of_type); + } } break; } break; case "backmatter": - assert(part == "glossary" || "bibliography" || "bookindex_seg" || "blurb" || "tail", part); + assert(part == "glossary" || "bibliography" || "bookindex" || "blurb" || "tail", part); switch (obj.metainfo.is_of_type) { case "para": switch (obj.metainfo.is_a) { @@ -1224,22 +1272,28 @@ template SQLiteInsertDocObjectsLoop() { case "bibliography": assert(part == "bibliography", part); obj_txt = format_and_sqlite_load.para(doc_matters, obj); break; - case "bookindex": assert(part == "bookindex_seg", part); + case "bookindex": assert(part == "bookindex", part); obj_txt = format_and_sqlite_load.para(doc_matters, obj); break; case "blurb": assert(part == "blurb", part); obj_txt = format_and_sqlite_load.para(doc_matters, obj); break; default: - if ((doc_matters.opt.action.debug_do)) { - writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a); + { /+ debug +/ + if (doc_matters.opt.action.debug_do + && doc_matters.opt.action.verbose) { + writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a); + } } break; } break; default: - if ((doc_matters.opt.action.debug_do)) { - writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_of_type); + { /+ debug +/ + if (doc_matters.opt.action.debug_do + && doc_matters.opt.action.verbose) { + writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_of_type); + } } break; } @@ -1247,10 +1301,13 @@ template SQLiteInsertDocObjectsLoop() { case "comment": break; default: - if ((doc_matters.opt.action.debug_do)) { - writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_of_part); // check where empty value could come from - writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a); - writeln(__FILE__, ":", __LINE__, ": ", obj.text); // check where empty value could come from + { /+ debug +/ + if (doc_matters.opt.action.debug_do + && doc_matters.opt.action.verbose) { + writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_of_part); // check where empty value could come from + writeln(__FILE__, ":", __LINE__, ": ", obj.metainfo.is_a); + writeln(__FILE__, ":", __LINE__, ": ", obj.text); // check where empty value could come from + } } break; } diff --git a/src/doc_reform/output/xmls.d b/src/doc_reform/output/xmls.d index bc93271..6154010 100644 --- a/src/doc_reform/output/xmls.d +++ b/src/doc_reform/output/xmls.d @@ -25,16 +25,10 @@ template outputXHTMLs() { case "head": delimit_ ~= "\n
\n" ; break; - case "toc_seg": + case "toc": delimit_ ~= "\n
\n" ; break; - case "toc_scroll": - delimit_ ~= "\n
\n" ; - break; - case "bookindex_seg": - delimit_ ~= "\n
\n" ; - break; - case "bookindex_scroll": + case "bookindex": delimit_ ~= "\n
\n" ; break; default: @@ -343,6 +337,7 @@ template outputXHTMLs() { string _suffix = ".html", string _xml_type = "seg", ) { + string seg_lvs; if (obj.has.inline_links) { if ((_txt.match(rgx.mark_internal_site_lnk)) && (_xml_type == "scroll")) { // conditions reversed to avoid: gdc compiled program run segfault @@ -351,9 +346,13 @@ template outputXHTMLs() { "$1"); } 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] == doc_matters.xml.tag_associations[(m.captures[3])][0]) { + if ( + m.captures[3] + == doc_matters.xml.tag_associations[(m.captures[3])][seg_lvs] + ) { _txt = _txt.replaceFirst( rgx.inline_link_hash, "┥$1┝┤$3" ~ _suffix ~ "├" @@ -362,7 +361,7 @@ template outputXHTMLs() { _txt = _txt.replaceFirst( rgx.inline_link_hash, "┥$1┝┤" - ~ doc_matters.xml.tag_associations[(m.captures[3])][0] + ~ doc_matters.xml.tag_associations[(m.captures[3])][seg_lvs] ~ _suffix ~ "#" ~ "$3" ~ "├" @@ -370,7 +369,9 @@ template outputXHTMLs() { } } else { writeln( - "WARNING on internal document links, anchor to link not found in document, " + "WARNING on internal document links, anchor to link <<" + ~ m.captures[3] + ~ ">> not found in document, " ~ "anchor: " ~ m.captures[3] ~ " document: " ~ doc_matters.src.filename ); diff --git a/views/version.txt b/views/version.txt index 9da2490..4bed5e2 100644 --- a/views/version.txt +++ b/views/version.txt @@ -4,7 +4,7 @@ struct Version { int minor; int patch; } -enum ver = Version(0, 2, 1); +enum ver = Version(0, 3, 0); version (Posix) { version (DigitalMars) { } else version (LDC) { -- cgit v1.2.3