aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorRalph Amissah <ralph.amissah@gmail.com>2023-12-16 22:50:16 -0500
committerRalph Amissah <ralph.amissah@gmail.com>2023-12-17 20:05:25 -0500
commitb69940c0641e56ba9ad0822ad8ad287053199458 (patch)
treeca9f4584c88ca61b62193fcfb572ba9120b7b3f8
parentorg, spine ver & doc header (copyright & license) (diff)
org, ocda (ongoing)
-rw-r--r--org/ocda.org4112
-rw-r--r--src/doc_reform/meta/metadoc_from_src.d35
2 files changed, 2113 insertions, 2034 deletions
diff --git a/org/ocda.org b/org/ocda.org
index 2de27f0..77913f9 100644
--- a/org/ocda.org
+++ b/org/ocda.org
@@ -33,8 +33,16 @@ module doc_reform.meta.metadoc_from_src;
template docAbstraction() {
// ↓ abstraction imports
<<docInitialize>>
- <<docAbstraction>>
- <<docSortOut>>
+ @system auto docAbstraction(CMM,Opt,Mf) (
+ char[][] markup_sourcefile_content,
+ CMM conf_make_meta,
+ Opt opt_action,
+ Mf manifested,
+ bool _new_doc
+ ) {
+ <<docAbstraction>>
+ } // ← closed: abstract doc source
+ <<docAbstractionRelatedFunctions>>
}
template docSectKeysSeq() {
<<docSectKeysSeq>>
@@ -508,1723 +516,1969 @@ struct ST_flow_table_substantive_munge {
#+END_SRC
** docAbstraction
+*** toc
#+NAME: docAbstraction
#+HEADER: :noweb yes
#+BEGIN_SRC d
-@system auto docAbstraction(CMM,Opt,Mf) (
- char[][] markup_sourcefile_content,
- CMM conf_make_meta,
- Opt opt_action,
- Mf manifested,
- bool _new_doc
-) {
- static auto rgx = RgxI();
- // ↓ abstraction init
- scope(success) {
- }
- scope(failure) {
- }
- scope(exit) {
- destroy(the_document_toc_section);
- destroy(the_document_head_section);
- destroy(the_document_body_section);
- destroy(the_document_bibliography_section);
- destroy(the_document_glossary_section);
- destroy(the_document_blurb_section);
- destroy(the_document_xml_dom_tail_section);
- destroy(an_object);
- destroy(processing);
- destroy(biblio_arr_json);
- previous_length = 0;
- reset_note_numbers = true;
- lev_anchor_tag = "";
- anchor_tag = "";
+<<docAbstractionInit>>
+<<docAbstractionInitSubstitutions>>
+<<docAbstractionMainLoopSrcByLine>>
+<<docAbstractionPostMainLoop>>
+<<docAbstractionReturnsStruct>>
+#+END_SRC
+
+*** abstraction init
+
+#+NAME: docAbstractionInit
+#+HEADER: :noweb yes
+#+BEGIN_SRC d
+static auto rgx = RgxI();
+// ↓ abstraction init
+scope(success) {
+}
+scope(failure) {
+}
+scope(exit) {
+ destroy(the_document_toc_section);
+ destroy(the_document_head_section);
+ destroy(the_document_body_section);
+ destroy(the_document_bibliography_section);
+ destroy(the_document_glossary_section);
+ destroy(the_document_blurb_section);
+ destroy(the_document_xml_dom_tail_section);
+ destroy(an_object);
+ destroy(processing);
+ destroy(biblio_arr_json);
+ previous_length = 0;
+ reset_note_numbers = true;
+ lev_anchor_tag = "";
+ anchor_tag = "";
+}
+mixin spineNode;
+auto node_para_int_ = node_metadata_para_int;
+auto node_para_str_ = node_metadata_para_str;
+ObjGenericComposite comp_obj_heading_, comp_obj_para, comp_obj_toc;
+line_occur = [
+ "heading" : 0,
+ "para" : 0,
+ "glossary" : 0,
+ "blurb" : 0,
+];
+uint[string] dochas = [
+ "inline_links" : 0,
+ "inline_notes" : 0,
+ "inline_notes_star" : 0,
+ "codeblock" : 0,
+ "table" : 0,
+ "block" : 0,
+ "group" : 0,
+ "poem" : 0,
+ "quote" : 0,
+ "images" : 0,
+];
+uint[string] pith = [
+ "ocn" : 1,
+ "section" : 0,
+ "txt_is" : 0,
+ "block_is" : 0,
+ "block_state" : 0,
+ "block_delim" : 0,
+ "make_headings" : 0,
+ "dummy_heading_status" : 0,
+ "dummy_heading_multiple_objects" : 0,
+ "no_ocn_multiple_objects" : 0,
+ "verse_new" : 0,
+];
+string[string] object_number_poem = [
+ "start" : "",
+ "end" : ""
+];
+string[] lv_ancestors_txt = [ "", "", "", "", "", "", "", "", ];
+int[string] lv = [
+ "lv" : eN.bi.off,
+ "h0" : eN.bi.off,
+ "h1" : eN.bi.off,
+ "h2" : eN.bi.off,
+ "h3" : eN.bi.off,
+ "h4" : eN.bi.off,
+ "h5" : eN.bi.off,
+ "h6" : eN.bi.off,
+ "h7" : eN.bi.off,
+ "lev_int_collapsed" : 0,
+];
+int[string] collapsed_lev = [
+ "h0" : eN.bi.off,
+ "h1" : eN.bi.off,
+ "h2" : eN.bi.off,
+ "h3" : eN.bi.off,
+ "h4" : eN.bi.off,
+ "h5" : eN.bi.off,
+ "h6" : eN.bi.off,
+ "h7" : eN.bi.off
+];
+string[string] heading_match_str = [
+ "h_A": "^(none)",
+ "h_B": "^(none)",
+ "h_C": "^(none)",
+ "h_D": "^(none)",
+ "h_1": "^(none)",
+ "h_2": "^(none)",
+ "h_3": "^(none)",
+ "h_4": "^(none)"
+];
+Regex!char[string] heading_match_rgx = [
+ "h_A": regex(r"^(none)"),
+ "h_B": regex(r"^(none)"),
+ "h_C": regex(r"^(none)"),
+ "h_D": regex(r"^(none)"),
+ "h_1": regex(r"^(none)"),
+ "h_2": regex(r"^(none)"),
+ "h_3": regex(r"^(none)"),
+ "h_4": regex(r"^(none)")
+];
+string _anchor_tag;
+string toc_txt_;
+an_object["glossary_nugget"] = "";
+an_object["blurb_nugget"] = "";
+comp_obj_heading_ = comp_obj_heading_.init;
+comp_obj_heading_.metainfo.is_of_part = "frontmatter";
+comp_obj_heading_.metainfo.is_of_section = "toc";
+comp_obj_heading_.metainfo.is_of_type = "para";
+comp_obj_heading_.metainfo.is_a = "heading";
+comp_obj_heading_.text = "Table of Contents";
+comp_obj_heading_.metainfo.ocn = 0;
+comp_obj_heading_.metainfo.identifier = "";
+comp_obj_heading_.metainfo.dummy_heading = false;
+comp_obj_heading_.metainfo.object_number_off = true;
+comp_obj_heading_.metainfo.object_number_type = 0;
+comp_obj_heading_.tags.segment_anchor_tag_epub = "toc";
+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;
+comp_obj_heading_.metainfo.parent_lev_markup = 0;
+comp_obj_heading_.ptr.html_segnames = html_segnames_ptr;
+comp_obj_heading_.tags.anchor_tags = ["toc"];
+comp_obj_heading_.metainfo.dom_structure_markedup_tags_status = [ 1, 1, 0, 0, 1, 0, 0, 0];
+comp_obj_heading_.metainfo.dom_structure_collapsed_tags_status = [ 1, 1, 1, 0, 0, 0, 0, 0];
+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_lv1to4"] = comp_obj_heading_.tags.segment_anchor_tag_epub;
+auto toc_head = comp_obj_heading_;
+html_segnames_ptr_cntr++;
+the_document_toc_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[][string] segnames = ["html": ["toc"], "epub": ["toc"]];
+int cnt1 = 1; int cnt2 = 1; int cnt3 = 1;
+// abstraction init ↑
+#+END_SRC
+
+*** abstraction init substitutions
+
+#+NAME: docAbstractionInitSubstitutions
+#+HEADER: :noweb yes
+#+BEGIN_SRC d
+enum Substitute { match, markup, }
+debug (substitutions) {
+ writeln(__LINE__, ":", __FILE__, ": DEBUG substitutions:");
+ if (!(conf_make_meta.make.headings.empty)) {
+ writeln(conf_make_meta.make.headings);
}
- mixin spineNode;
- auto node_para_int_ = node_metadata_para_int;
- auto node_para_str_ = node_metadata_para_str;
- ObjGenericComposite comp_obj_heading_, comp_obj_para, comp_obj_toc;
- line_occur = [
- "heading" : 0,
- "para" : 0,
- "glossary" : 0,
- "blurb" : 0,
- ];
- uint[string] dochas = [
- "inline_links" : 0,
- "inline_notes" : 0,
- "inline_notes_star" : 0,
- "codeblock" : 0,
- "table" : 0,
- "block" : 0,
- "group" : 0,
- "poem" : 0,
- "quote" : 0,
- "images" : 0,
- ];
- uint[string] pith = [
- "ocn" : 1,
- "section" : 0,
- "txt_is" : 0,
- "block_is" : 0,
- "block_state" : 0,
- "block_delim" : 0,
- "make_headings" : 0,
- "dummy_heading_status" : 0,
- "dummy_heading_multiple_objects" : 0,
- "no_ocn_multiple_objects" : 0,
- "verse_new" : 0,
- ];
- string[string] object_number_poem = [
- "start" : "",
- "end" : ""
- ];
- string[] lv_ancestors_txt = [ "", "", "", "", "", "", "", "", ];
- int[string] lv = [
- "lv" : eN.bi.off,
- "h0" : eN.bi.off,
- "h1" : eN.bi.off,
- "h2" : eN.bi.off,
- "h3" : eN.bi.off,
- "h4" : eN.bi.off,
- "h5" : eN.bi.off,
- "h6" : eN.bi.off,
- "h7" : eN.bi.off,
- "lev_int_collapsed" : 0,
- ];
- int[string] collapsed_lev = [
- "h0" : eN.bi.off,
- "h1" : eN.bi.off,
- "h2" : eN.bi.off,
- "h3" : eN.bi.off,
- "h4" : eN.bi.off,
- "h5" : eN.bi.off,
- "h6" : eN.bi.off,
- "h7" : eN.bi.off
- ];
- string[string] heading_match_str = [
- "h_A": "^(none)",
- "h_B": "^(none)",
- "h_C": "^(none)",
- "h_D": "^(none)",
- "h_1": "^(none)",
- "h_2": "^(none)",
- "h_3": "^(none)",
- "h_4": "^(none)"
- ];
- Regex!char[string] heading_match_rgx = [
- "h_A": regex(r"^(none)"),
- "h_B": regex(r"^(none)"),
- "h_C": regex(r"^(none)"),
- "h_D": regex(r"^(none)"),
- "h_1": regex(r"^(none)"),
- "h_2": regex(r"^(none)"),
- "h_3": regex(r"^(none)"),
- "h_4": regex(r"^(none)")
- ];
- string _anchor_tag;
- string toc_txt_;
- an_object["glossary_nugget"] = "";
- an_object["blurb_nugget"] = "";
- comp_obj_heading_ = comp_obj_heading_.init;
- comp_obj_heading_.metainfo.is_of_part = "frontmatter";
- comp_obj_heading_.metainfo.is_of_section = "toc";
- comp_obj_heading_.metainfo.is_of_type = "para";
- comp_obj_heading_.metainfo.is_a = "heading";
- comp_obj_heading_.text = "Table of Contents";
- comp_obj_heading_.metainfo.ocn = 0;
- comp_obj_heading_.metainfo.identifier = "";
- comp_obj_heading_.metainfo.dummy_heading = false;
- comp_obj_heading_.metainfo.object_number_off = true;
- comp_obj_heading_.metainfo.object_number_type = 0;
- comp_obj_heading_.tags.segment_anchor_tag_epub = "toc";
- 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;
- comp_obj_heading_.metainfo.parent_lev_markup = 0;
- comp_obj_heading_.ptr.html_segnames = html_segnames_ptr;
- comp_obj_heading_.tags.anchor_tags = ["toc"];
- comp_obj_heading_.metainfo.dom_structure_markedup_tags_status = [ 1, 1, 0, 0, 1, 0, 0, 0];
- comp_obj_heading_.metainfo.dom_structure_collapsed_tags_status = [ 1, 1, 1, 0, 0, 0, 0, 0];
- 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_lv1to4"] = comp_obj_heading_.tags.segment_anchor_tag_epub;
- auto toc_head = comp_obj_heading_;
- html_segnames_ptr_cntr++;
- the_document_toc_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[][string] segnames = ["html": ["toc"], "epub": ["toc"]];
- int cnt1 = 1; int cnt2 = 1; int cnt3 = 1;
- // abstraction init ↑
- enum Substitute { match, markup, }
- debug (substitutions) {
- writeln(__LINE__, ":", __FILE__, ": DEBUG substitutions:");
- if (!(conf_make_meta.make.headings.empty)) {
- writeln(conf_make_meta.make.headings);
- }
- if (conf_make_meta.make.substitute) {
- foreach(substitution_pair; conf_make_meta.make.substitute) {
- writeln("regex to match: ", substitution_pair[Substitute.match]);
- writeln("substitution to make: ", substitution_pair[Substitute.markup]);
- }
- }
- if (conf_make_meta.make.bold) {
- writeln("regex to match: ", conf_make_meta.make.bold[Substitute.match]);
- writeln("substitution to make: ", conf_make_meta.make.bold[Substitute.markup]);
- }
- if (conf_make_meta.make.emphasis) {
- writeln("regex to match: ", conf_make_meta.make.emphasis[Substitute.match]);
- writeln("substitution to make: ", conf_make_meta.make.emphasis[Substitute.markup]);
- }
- if (conf_make_meta.make.italics) {
- writeln("regex to match: ", conf_make_meta.make.italics[Substitute.match]);
- writeln("substitution to make: ", conf_make_meta.make.italics[Substitute.markup]);
+ if (conf_make_meta.make.substitute) {
+ foreach(substitution_pair; conf_make_meta.make.substitute) {
+ writeln("regex to match: ", substitution_pair[Substitute.match]);
+ writeln("substitution to make: ", substitution_pair[Substitute.markup]);
}
}
- auto loopMarkupSrcByLine(
- char[][] markup_sourcefile_content,
- string[string] an_object,
- uint[string] pith,
- ) {
- struct _loopMarkupSrcByLineStruct {
- ObjGenericComposite[] toc;
- ObjGenericComposite[] body;
- ObjGenericComposite[] glossary;
- ObjGenericComposite[] blurb;
- string[string] object_notes;
- string[][string] segnames;
- }
- _loopMarkupSrcByLineStruct ret;
- srcDocLoopLineByLine_:
- foreach (line; markup_sourcefile_content) {
- // ↓ markup document/text line by line
- // "line" variable can be empty but should never be null
- // scope
- scope(exit) { }
- scope(failure) {
- stderr.writefln(
- "\n%s\n%s\n\n%s:%s\nFAILED while processing the file: ❮❮ %s ❯❯ on line with text:\n%s\n",
- __MODULE__, __FUNCTION__,
- __FILE__, __LINE__,
- manifested.src.filename, line,
- );
- }
- debug(source) { writeln(line); }
- debug(srclines) { if (!line.empty) { writefln("* %s", line); } }
- if (!line.empty) { pith = line._check_ocn_status_(pith); }
- if ( pith["block_is"] == eN.blk_is.code
- && pith["block_state"] == eN.blk_state.on
+ if (conf_make_meta.make.bold) {
+ writeln("regex to match: ", conf_make_meta.make.bold[Substitute.match]);
+ writeln("substitution to make: ", conf_make_meta.make.bold[Substitute.markup]);
+ }
+ if (conf_make_meta.make.emphasis) {
+ writeln("regex to match: ", conf_make_meta.make.emphasis[Substitute.match]);
+ writeln("substitution to make: ", conf_make_meta.make.emphasis[Substitute.markup]);
+ }
+ if (conf_make_meta.make.italics) {
+ writeln("regex to match: ", conf_make_meta.make.italics[Substitute.match]);
+ writeln("substitution to make: ", conf_make_meta.make.italics[Substitute.markup]);
+ }
+}
+#+END_SRC
+
+*** loop source by line (large block)
+
+#+NAME: docAbstractionMainLoopSrcByLine
+#+HEADER: :noweb yes
+#+BEGIN_SRC d
+auto loopMarkupSrcByLine(
+ char[][] markup_sourcefile_content,
+ string[string] an_object,
+ uint[string] pith,
+) {
+ struct _loopMarkupSrcByLineStruct {
+ ObjGenericComposite[] toc;
+ ObjGenericComposite[] body;
+ ObjGenericComposite[] glossary;
+ ObjGenericComposite[] blurb;
+ string[string] object_notes;
+ string[][string] segnames;
+ }
+ _loopMarkupSrcByLineStruct ret;
+ srcDocLoopLineByLine_:
+ foreach (line; markup_sourcefile_content) {
+ // ↓ markup document/text line by line
+ // "line" variable can be empty but should never be null
+ // scope
+ scope(exit) { }
+ scope(failure) {
+ stderr.writefln(
+ "\n%s\n%s\n\n%s:%s\nFAILED while processing the file: ❮❮ %s ❯❯ on line with text:\n%s\n",
+ __MODULE__, __FUNCTION__,
+ __FILE__, __LINE__,
+ manifested.src.filename, line,
+ );
+ }
+ debug(source) { writeln(line); }
+ debug(srclines) { if (!line.empty) { writefln("* %s", line); } }
+ if (!line.empty) { pith = line._check_ocn_status_(pith); }
+ if ( pith["block_is"] == eN.blk_is.code
+ && pith["block_state"] == eN.blk_state.on
+ ) {
+ // block object: code
+ {
+ auto _get = line.txt_by_line_block_code(an_object, pith);
+ an_object = _get.this_object;
+ pith = _get.pith;
+ }
+ continue;
+ } else if (!matchFirst(line, rgx.skip_from_regular_parse)) {
+ // object other than "code block" object
+ // (includes regular text paragraph, headings & blocks other than code)
+ // heading, glossary, blurb, poem, group, block, quote, table
+ line = line.inline_markup_faces; // by text line (rather than by text object), linebreaks in para problematic
+ if (line.matchFirst(rgx.heading_biblio)
+ || (pith["section"] == eN.sect.bibliography
+ && ((!(line.matchFirst(rgx.heading_glossary)))
+ && (!(line.matchFirst(rgx.heading_blurb)))
+ && (!(line.matchFirst(rgx.heading)))
+ && (!(line.matchFirst(rgx.comment)))))
) {
- // block object: code
- {
- auto _get = line.txt_by_line_block_code(an_object, pith);
- an_object = _get.this_object;
- pith = _get.pith;
+ pith["section"] = eN.sect.bibliography;
+ if (opt_action.backmatter && opt_action.section_biblio) {
+ {
+ auto _get = line.txt_by_line_block_biblio(pith, bib_entry, biblio_entry_str_json, biblio_arr_json);
+ {
+ pith = _get.pith;
+ bib_entry = _get.bib_entry;
+ biblio_entry_str_json = _get.biblio_entry_str_json;
+ biblio_arr_json = _get.biblio_arr_json;
+ }
+ }
+ debug(bibliobuild) {
+ writeln("- ", biblio_entry_str_json);
+ writeln("-> ", biblio_arr_json.length);
+ }
}
continue;
- } else if (!matchFirst(line, rgx.skip_from_regular_parse)) {
- // object other than "code block" object
- // (includes regular text paragraph, headings & blocks other than code)
- // heading, glossary, blurb, poem, group, block, quote, table
- line = line.inline_markup_faces; // by text line (rather than by text object), linebreaks in para problematic
- if (line.matchFirst(rgx.heading_biblio)
- || (pith["section"] == eN.sect.bibliography
- && ((!(line.matchFirst(rgx.heading_glossary)))
- && (!(line.matchFirst(rgx.heading_blurb)))
- && (!(line.matchFirst(rgx.heading)))
- && (!(line.matchFirst(rgx.comment)))))
- ) {
- pith["section"] = eN.sect.bibliography;
- if (opt_action.backmatter && opt_action.section_biblio) {
+ } else if (line.matchFirst(rgx.heading_glossary)
+ || (pith["section"] == eN.sect.glossary
+ && ((!(line.matchFirst(rgx.heading_biblio)))
+ && (!(line.matchFirst(rgx.heading_blurb)))
+ && (!(line.matchFirst(rgx.heading)))
+ && (!(line.matchFirst(rgx.comment)))))
+ ) {
+ // within section (block object): glossary
+ debug(glossary) { writeln(__LINE__); writeln(line); }
+ pith["section"] = eN.sect.glossary;
+ if (opt_action.backmatter && opt_action.section_glossary) {
+ indent = [
+ "hang_position" : 0,
+ "base_position" : 0,
+ ];
+ bullet = false;
+ pith["txt_is"] = eN.txt_is.para;
+ line_occur["para"] = eN.bi.off;
+ an_object_key = "glossary_nugget";
+ if (line.matchFirst(rgx.heading_glossary)) {
{
- auto _get = line.txt_by_line_block_biblio(pith, bib_entry, biblio_entry_str_json, biblio_arr_json);
- {
- pith = _get.pith;
- bib_entry = _get.bib_entry;
- biblio_entry_str_json = _get.biblio_entry_str_json;
- biblio_arr_json = _get.biblio_arr_json;
- }
+ comp_obj_heading_ = comp_obj_heading_.init;
+ comp_obj_heading_.metainfo.is_of_part = "backmatter";
+ comp_obj_heading_.metainfo.is_of_section = "glossary";
+ comp_obj_heading_.metainfo.is_of_type = "para";
+ comp_obj_heading_.metainfo.is_a = "heading";
+ comp_obj_heading_.text = "Glossary";
+ comp_obj_heading_.metainfo.ocn = 0;
+ comp_obj_heading_.metainfo.identifier = "";
+ comp_obj_heading_.metainfo.dummy_heading = false;
+ comp_obj_heading_.metainfo.object_number_off = false;
+ comp_obj_heading_.metainfo.object_number_type = 0;
+ 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_.tags.anchor_tags = ["section_glossary"];
+ comp_obj_heading_.metainfo.heading_lev_markup = 1;
+ comp_obj_heading_.metainfo.heading_lev_collapsed = 1;
+ comp_obj_heading_.metainfo.parent_ocn = 1;
+ comp_obj_heading_.metainfo.parent_lev_markup = 0;
+ comp_obj_heading_.metainfo.dom_structure_markedup_tags_status = [ 1, 1, 0, 0, 0, 0, 0, 0];
+ comp_obj_heading_.metainfo.dom_structure_collapsed_tags_status = [ 1, 1, 0, 0, 0, 0, 0, 0];
+ the_document_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_lv1to4"] = comp_obj_heading_.tags.segment_anchor_tag_epub;
}
- debug(bibliobuild) {
- writeln("- ", biblio_entry_str_json);
- writeln("-> ", biblio_arr_json.length);
+ {
+ comp_obj_heading_ = comp_obj_heading_.init;
+ comp_obj_heading_.metainfo.is_of_part = "backmatter";
+ comp_obj_heading_.metainfo.is_of_section = "glossary";
+ comp_obj_heading_.metainfo.is_of_type = "para";
+ comp_obj_heading_.metainfo.is_a = "heading";
+ comp_obj_heading_.text = "Glossary";
+ comp_obj_heading_.metainfo.ocn = 0;
+ comp_obj_heading_.metainfo.identifier = "";
+ comp_obj_heading_.metainfo.dummy_heading = true;
+ comp_obj_heading_.metainfo.object_number_off = true;
+ comp_obj_heading_.metainfo.object_number_type = 0;
+ comp_obj_heading_.tags.segment_anchor_tag_epub = "glossary";
+ 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_.metainfo.dom_structure_markedup_tags_status = [ 1, 1, 0, 0, 1, 0, 0, 0];
+ comp_obj_heading_.metainfo.dom_structure_collapsed_tags_status = [ 1, 1, 1, 0, 0, 0, 0, 0];
+ comp_obj_heading_.tags.anchor_tags = ["glossary"];
+ the_document_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_lv1to4"] = comp_obj_heading_.tags.segment_anchor_tag_epub;
}
- }
- continue;
- } else if (line.matchFirst(rgx.heading_glossary)
- || (pith["section"] == eN.sect.glossary
- && ((!(line.matchFirst(rgx.heading_biblio)))
- && (!(line.matchFirst(rgx.heading_blurb)))
- && (!(line.matchFirst(rgx.heading)))
- && (!(line.matchFirst(rgx.comment)))))
- ) {
- // within section (block object): glossary
- debug(glossary) { writeln(__LINE__); writeln(line); }
- pith["section"] = eN.sect.glossary;
- if (opt_action.backmatter && opt_action.section_glossary) {
- indent = [
- "hang_position" : 0,
- "base_position" : 0,
- ];
- bullet = false;
- pith["txt_is"] = eN.txt_is.para;
- line_occur["para"] = eN.bi.off;
- an_object_key = "glossary_nugget";
- if (line.matchFirst(rgx.heading_glossary)) {
- {
- comp_obj_heading_ = comp_obj_heading_.init;
- comp_obj_heading_.metainfo.is_of_part = "backmatter";
- comp_obj_heading_.metainfo.is_of_section = "glossary";
- comp_obj_heading_.metainfo.is_of_type = "para";
- comp_obj_heading_.metainfo.is_a = "heading";
- comp_obj_heading_.text = "Glossary";
- comp_obj_heading_.metainfo.ocn = 0;
- comp_obj_heading_.metainfo.identifier = "";
- comp_obj_heading_.metainfo.dummy_heading = false;
- comp_obj_heading_.metainfo.object_number_off = false;
- comp_obj_heading_.metainfo.object_number_type = 0;
- 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_.tags.anchor_tags = ["section_glossary"];
- comp_obj_heading_.metainfo.heading_lev_markup = 1;
- comp_obj_heading_.metainfo.heading_lev_collapsed = 1;
- comp_obj_heading_.metainfo.parent_ocn = 1;
- comp_obj_heading_.metainfo.parent_lev_markup = 0;
- comp_obj_heading_.metainfo.dom_structure_markedup_tags_status = [ 1, 1, 0, 0, 0, 0, 0, 0];
- comp_obj_heading_.metainfo.dom_structure_collapsed_tags_status = [ 1, 1, 0, 0, 0, 0, 0, 0];
- the_document_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_lv1to4"] = 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";
- comp_obj_heading_.metainfo.is_of_type = "para";
- comp_obj_heading_.metainfo.is_a = "heading";
- comp_obj_heading_.text = "Glossary";
- comp_obj_heading_.metainfo.ocn = 0;
- comp_obj_heading_.metainfo.identifier = "";
- comp_obj_heading_.metainfo.dummy_heading = true;
- comp_obj_heading_.metainfo.object_number_off = true;
- comp_obj_heading_.metainfo.object_number_type = 0;
- comp_obj_heading_.tags.segment_anchor_tag_epub = "glossary";
- 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_.metainfo.dom_structure_markedup_tags_status = [ 1, 1, 0, 0, 1, 0, 0, 0];
- comp_obj_heading_.metainfo.dom_structure_collapsed_tags_status = [ 1, 1, 1, 0, 0, 0, 0, 0];
- comp_obj_heading_.tags.anchor_tags = ["glossary"];
- the_document_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_lv1to4"] = comp_obj_heading_.tags.segment_anchor_tag_epub;
- }
- } else {
+ } else {
+ {
+ auto _get = line.flow_para_match_(an_object, an_object_key, indent, bullet, pith, line_occur);
{
- auto _get = line.flow_para_match_(an_object, an_object_key, indent, bullet, pith, line_occur);
- {
- an_object = _get.this_object;
- an_object_key = _get.this_object_key;
- pith = _get.pith;
- indent = _get.indent;
- bullet = _get.bullet;
- line_occur = _get.line_occur;
- }
+ an_object = _get.this_object;
+ an_object_key = _get.this_object_key;
+ pith = _get.pith;
+ indent = _get.indent;
+ bullet = _get.bullet;
+ line_occur = _get.line_occur;
}
- comp_obj_para = comp_obj_para.init;
- comp_obj_para.metainfo.is_of_part = "backmatter";
- comp_obj_para.metainfo.is_of_section = "glossary";
- comp_obj_para.metainfo.is_of_type = "para";
- comp_obj_para.metainfo.is_a = "glossary";
- comp_obj_para.text = links_and_images(line.to!string.strip).replaceFirst(rgx.para_attribs, "");
- comp_obj_para.metainfo.ocn = 0;
- comp_obj_para.metainfo.identifier = "";
- comp_obj_para.metainfo.object_number_off = true;
- comp_obj_para.metainfo.object_number_type = 0;
- comp_obj_para.attrib.indent_hang = indent["hang_position"];
- comp_obj_para.attrib.indent_base = indent["base_position"];
- comp_obj_para.attrib.bullet = bullet;
- the_document_glossary_section ~= comp_obj_para;
}
- pith["ocn"] = eN.ocn.on;
+ comp_obj_para = comp_obj_para.init;
+ comp_obj_para.metainfo.is_of_part = "backmatter";
+ comp_obj_para.metainfo.is_of_section = "glossary";
+ comp_obj_para.metainfo.is_of_type = "para";
+ comp_obj_para.metainfo.is_a = "glossary";
+ comp_obj_para.text = links_and_images(line.to!string.strip).replaceFirst(rgx.para_attribs, "");
+ comp_obj_para.metainfo.ocn = 0;
+ comp_obj_para.metainfo.identifier = "";
+ comp_obj_para.metainfo.object_number_off = true;
+ comp_obj_para.metainfo.object_number_type = 0;
+ comp_obj_para.attrib.indent_hang = indent["hang_position"];
+ comp_obj_para.attrib.indent_base = indent["base_position"];
+ comp_obj_para.attrib.bullet = bullet;
+ the_document_glossary_section ~= comp_obj_para;
}
- continue;
- } else if (line.matchFirst(rgx.heading_blurb)
- || (pith["section"] == eN.sect.blurb
- && ((!(line.matchFirst(rgx.heading_glossary)))
- && (!(line.matchFirst(rgx.heading_biblio)))
- && (!(line.matchFirst(rgx.heading)))
- && (!(line.matchFirst(rgx.comment)))))
- ) {
- pith["section"] = eN.sect.blurb;
- debug(blurb) { writeln(__LINE__); writeln(line); }
- if (opt_action.backmatter && opt_action.section_blurb) {
+ pith["ocn"] = eN.ocn.on;
+ }
+ continue;
+ } else if (line.matchFirst(rgx.heading_blurb)
+ || (pith["section"] == eN.sect.blurb
+ && ((!(line.matchFirst(rgx.heading_glossary)))
+ && (!(line.matchFirst(rgx.heading_biblio)))
+ && (!(line.matchFirst(rgx.heading)))
+ && (!(line.matchFirst(rgx.comment)))))
+ ) {
+ pith["section"] = eN.sect.blurb;
+ debug(blurb) { writeln(__LINE__); writeln(line); }
+ if (opt_action.backmatter && opt_action.section_blurb) {
+ indent = [
+ "hang_position" : 0,
+ "base_position" : 0,
+ ];
+ bullet = false;
+ if (auto m = line.matchFirst(rgx.para_indent)) {
+ debug(paraindent) { writeln(line); }
+ indent["hang_position"] = (m["indent"]).to!int;
+ indent["base_position"] = (m["indent"]).to!int;
+ } else if (line.matchFirst(rgx.para_bullet)) {
+ debug(parabullet) { writeln(line); }
+ bullet = true;
+ } else if (auto m = line.matchFirst(rgx.para_indent_hang)) {
+ debug(paraindenthang) { writeln(line); }
indent = [
- "hang_position" : 0,
- "base_position" : 0,
+ "hang_position" : (m["hang"]).to!int,
+ "base_position" : (m["indent"]).to!int,
];
- bullet = false;
- if (auto m = line.matchFirst(rgx.para_indent)) {
- debug(paraindent) { writeln(line); }
- indent["hang_position"] = (m["indent"]).to!int;
- indent["base_position"] = (m["indent"]).to!int;
- } else if (line.matchFirst(rgx.para_bullet)) {
- debug(parabullet) { writeln(line); }
- bullet = true;
- } else if (auto m = line.matchFirst(rgx.para_indent_hang)) {
- debug(paraindenthang) { writeln(line); }
- indent = [
- "hang_position" : (m["hang"]).to!int,
- "base_position" : (m["indent"]).to!int,
- ];
- } else if (auto m = line.matchFirst(rgx.para_bullet_indent)) {
- debug(parabulletindent) { writeln(line); }
- indent = [
- "hang_position" : (m["indent"]).to!int,
- "base_position" : (m["indent"]).to!int,
- ];
- bullet = true;
- }
- pith["txt_is"] = eN.txt_is.para;
- line_occur["para"] = eN.bi.off;
- an_object_key = "blurb_nugget";
- if (line.matchFirst(rgx.heading_blurb)) {
- {
- comp_obj_heading_ = comp_obj_heading_.init;
- comp_obj_heading_.metainfo.is_of_part = "backmatter";
- comp_obj_heading_.metainfo.is_of_section = "blurb";
- comp_obj_heading_.metainfo.is_of_type = "para";
- comp_obj_heading_.metainfo.is_a = "heading";
- comp_obj_heading_.text = "Blurb";
- comp_obj_heading_.metainfo.ocn = 0;
- comp_obj_heading_.metainfo.identifier = "";
- comp_obj_heading_.metainfo.dummy_heading = false;
- comp_obj_heading_.metainfo.object_number_off = false;
- comp_obj_heading_.metainfo.object_number_type = 0;
- 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_.tags.anchor_tags = ["section_blurb"];
- comp_obj_heading_.metainfo.heading_lev_markup = 1;
- comp_obj_heading_.metainfo.heading_lev_collapsed = 1;
- comp_obj_heading_.metainfo.parent_ocn = 1;
- comp_obj_heading_.metainfo.parent_lev_markup = 0;
- comp_obj_heading_.metainfo.dom_structure_markedup_tags_status = [ 1, 1, 0, 0, 0, 0, 0, 0];
- comp_obj_heading_.metainfo.dom_structure_collapsed_tags_status = [ 1, 1, 0, 0, 0, 0, 0, 0];
- the_document_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_lv1to4"] = 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";
- comp_obj_heading_.metainfo.is_of_type = "para";
- comp_obj_heading_.metainfo.is_a = "heading";
- comp_obj_heading_.text = "Blurb";
- comp_obj_heading_.metainfo.ocn = 0;
- comp_obj_heading_.metainfo.identifier = "";
- comp_obj_heading_.metainfo.dummy_heading = true;
- comp_obj_heading_.metainfo.object_number_off = true;
- comp_obj_heading_.metainfo.object_number_type = 0;
- comp_obj_heading_.tags.segment_anchor_tag_epub = "blurb";
- 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 = ["blurb"];
- comp_obj_heading_.metainfo.dom_structure_markedup_tags_status = [ 1, 1, 0, 0, 1, 0, 0, 0];
- comp_obj_heading_.metainfo.dom_structure_collapsed_tags_status = [ 1, 1, 1, 0, 0, 0, 0, 0];
- the_document_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_lv1to4"] = comp_obj_heading_.tags.segment_anchor_tag_epub;
- }
- } else if (line.matchFirst(rgx.headings)
- && (opt_action.backmatter && opt_action.section_blurb)) {
+ } else if (auto m = line.matchFirst(rgx.para_bullet_indent)) {
+ debug(parabulletindent) { writeln(line); }
+ indent = [
+ "hang_position" : (m["indent"]).to!int,
+ "base_position" : (m["indent"]).to!int,
+ ];
+ bullet = true;
+ }
+ pith["txt_is"] = eN.txt_is.para;
+ line_occur["para"] = eN.bi.off;
+ an_object_key = "blurb_nugget";
+ if (line.matchFirst(rgx.heading_blurb)) {
+ {
comp_obj_heading_ = comp_obj_heading_.init;
comp_obj_heading_.metainfo.is_of_part = "backmatter";
comp_obj_heading_.metainfo.is_of_section = "blurb";
comp_obj_heading_.metainfo.is_of_type = "para";
comp_obj_heading_.metainfo.is_a = "heading";
- comp_obj_heading_.text = line.to!string;
+ comp_obj_heading_.text = "Blurb";
comp_obj_heading_.metainfo.ocn = 0;
comp_obj_heading_.metainfo.identifier = "";
comp_obj_heading_.metainfo.dummy_heading = false;
+ comp_obj_heading_.metainfo.object_number_off = false;
+ comp_obj_heading_.metainfo.object_number_type = 0;
+ 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_.tags.anchor_tags = ["section_blurb"];
+ comp_obj_heading_.metainfo.heading_lev_markup = 1;
+ comp_obj_heading_.metainfo.heading_lev_collapsed = 1;
+ comp_obj_heading_.metainfo.parent_ocn = 1;
+ comp_obj_heading_.metainfo.parent_lev_markup = 0;
+ comp_obj_heading_.metainfo.dom_structure_markedup_tags_status = [ 1, 1, 0, 0, 0, 0, 0, 0];
+ comp_obj_heading_.metainfo.dom_structure_collapsed_tags_status = [ 1, 1, 0, 0, 0, 0, 0, 0];
+ the_document_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_lv1to4"] = 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";
+ comp_obj_heading_.metainfo.is_of_type = "para";
+ comp_obj_heading_.metainfo.is_a = "heading";
+ comp_obj_heading_.text = "Blurb";
+ comp_obj_heading_.metainfo.ocn = 0;
+ comp_obj_heading_.metainfo.identifier = "";
+ comp_obj_heading_.metainfo.dummy_heading = true;
comp_obj_heading_.metainfo.object_number_off = true;
comp_obj_heading_.metainfo.object_number_type = 0;
comp_obj_heading_.tags.segment_anchor_tag_epub = "blurb";
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.heading_lev_markup = 4;
+ comp_obj_heading_.metainfo.heading_lev_collapsed = 2;
comp_obj_heading_.metainfo.parent_ocn = 1;
comp_obj_heading_.metainfo.parent_lev_markup = 0;
+ comp_obj_heading_.tags.anchor_tags = ["blurb"];
+ comp_obj_heading_.metainfo.dom_structure_markedup_tags_status = [ 1, 1, 0, 0, 1, 0, 0, 0];
+ comp_obj_heading_.metainfo.dom_structure_collapsed_tags_status = [ 1, 1, 1, 0, 0, 0, 0, 0];
the_document_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_lv1to4"] = comp_obj_heading_.tags.segment_anchor_tag_epub;
- } else if (!(line.empty)) {
+ }
+ } else if (line.matchFirst(rgx.headings)
+ && (opt_action.backmatter && opt_action.section_blurb)) {
+ comp_obj_heading_ = comp_obj_heading_.init;
+ comp_obj_heading_.metainfo.is_of_part = "backmatter";
+ comp_obj_heading_.metainfo.is_of_section = "blurb";
+ comp_obj_heading_.metainfo.is_of_type = "para";
+ comp_obj_heading_.metainfo.is_a = "heading";
+ comp_obj_heading_.text = line.to!string;
+ comp_obj_heading_.metainfo.ocn = 0;
+ comp_obj_heading_.metainfo.identifier = "";
+ comp_obj_heading_.metainfo.dummy_heading = false;
+ comp_obj_heading_.metainfo.object_number_off = true;
+ comp_obj_heading_.metainfo.object_number_type = 0;
+ comp_obj_heading_.tags.segment_anchor_tag_epub = "blurb";
+ 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_document_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_lv1to4"] = comp_obj_heading_.tags.segment_anchor_tag_epub;
+ } else if (!(line.empty)) {
+ {
+ auto _get = line.flow_para_match_(an_object, an_object_key, indent, bullet, pith, line_occur);
{
- auto _get = line.flow_para_match_(an_object, an_object_key, indent, bullet, pith, line_occur);
- {
- an_object = _get.this_object;
- an_object_key = _get.this_object_key;
- pith = _get.pith;
- indent = _get.indent;
- bullet = _get.bullet;
- line_occur = _get.line_occur;
- }
+ an_object = _get.this_object;
+ an_object_key = _get.this_object_key;
+ pith = _get.pith;
+ indent = _get.indent;
+ bullet = _get.bullet;
+ line_occur = _get.line_occur;
}
- comp_obj_para = comp_obj_para.init;
- comp_obj_para.metainfo.is_of_part = "backmatter";
- comp_obj_para.metainfo.is_of_section = "blurb";
- comp_obj_para.metainfo.is_of_type = "para";
- comp_obj_para.metainfo.is_a = "blurb";
- comp_obj_para.text = links_and_images(line.to!string.strip).replaceFirst(rgx.para_attribs, "");
- comp_obj_para.metainfo.ocn = 0;
- comp_obj_para.metainfo.identifier = "";
- comp_obj_para.metainfo.object_number_off = true;
- comp_obj_para.metainfo.object_number_type = 0;
- comp_obj_para.attrib.indent_hang = indent["hang_position"];
- comp_obj_para.attrib.indent_base = indent["base_position"];
- comp_obj_para.has.inline_links = true;
- comp_obj_para.attrib.bullet = bullet;
- the_document_blurb_section ~= comp_obj_para;
}
- pith["ocn"] = eN.ocn.on;
+ comp_obj_para = comp_obj_para.init;
+ comp_obj_para.metainfo.is_of_part = "backmatter";
+ comp_obj_para.metainfo.is_of_section = "blurb";
+ comp_obj_para.metainfo.is_of_type = "para";
+ comp_obj_para.metainfo.is_a = "blurb";
+ comp_obj_para.text = links_and_images(line.to!string.strip).replaceFirst(rgx.para_attribs, "");
+ comp_obj_para.metainfo.ocn = 0;
+ comp_obj_para.metainfo.identifier = "";
+ comp_obj_para.metainfo.object_number_off = true;
+ comp_obj_para.metainfo.object_number_type = 0;
+ comp_obj_para.attrib.indent_hang = indent["hang_position"];
+ comp_obj_para.attrib.indent_base = indent["base_position"];
+ comp_obj_para.has.inline_links = true;
+ comp_obj_para.attrib.bullet = bullet;
+ the_document_blurb_section ~= comp_obj_para;
}
- continue;
- } else if (pith["block_state"] == eN.blk_state.on) {
- if (pith["block_is"] == eN.blk_is.quote) {
- line = line
- ._doc_header_and_make_substitutions_(conf_make_meta)
- ._doc_header_and_make_substitutions_fontface_(conf_make_meta);
+ pith["ocn"] = eN.ocn.on;
+ }
+ continue;
+ } else if (pith["block_state"] == eN.blk_state.on) {
+ if (pith["block_is"] == eN.blk_is.quote) {
+ line = line
+ ._doc_header_and_make_substitutions_(conf_make_meta)
+ ._doc_header_and_make_substitutions_fontface_(conf_make_meta);
+ {
+ auto _get = line.txt_by_line_block_quote(an_object, pith);
{
- auto _get = line.txt_by_line_block_quote(an_object, pith);
- {
- an_object = _get.this_object;
- pith = _get.pith;
- }
+ an_object = _get.this_object;
+ pith = _get.pith;
}
- continue;
- } else if (pith["block_is"] == eN.blk_is.group) {
- line = line
- ._doc_header_and_make_substitutions_(conf_make_meta)
- ._doc_header_and_make_substitutions_fontface_(conf_make_meta)
- .replaceAll(rgx.para_delimiter, mkup.br_line_spaced ~ "$1");
+ }
+ continue;
+ } else if (pith["block_is"] == eN.blk_is.group) {
+ line = line
+ ._doc_header_and_make_substitutions_(conf_make_meta)
+ ._doc_header_and_make_substitutions_fontface_(conf_make_meta)
+ .replaceAll(rgx.para_delimiter, mkup.br_line_spaced ~ "$1");
+ {
+ auto _get = line.txt_by_line_block_group(an_object, pith);
{
- auto _get = line.txt_by_line_block_group(an_object, pith);
- {
- an_object = _get.this_object;
- pith = _get.pith;
- }
+ an_object = _get.this_object;
+ pith = _get.pith;
}
- continue;
- } else if (pith["block_is"] == eN.blk_is.block) {
+ }
+ continue;
+ } else if (pith["block_is"] == eN.blk_is.block) {
+ line = line
+ ._doc_header_and_make_substitutions_(conf_make_meta)
+ ._doc_header_and_make_substitutions_fontface_(conf_make_meta);
+ if (auto m = line.match(rgx.spaces_keep)) {
line = line
- ._doc_header_and_make_substitutions_(conf_make_meta)
- ._doc_header_and_make_substitutions_fontface_(conf_make_meta);
- if (auto m = line.match(rgx.spaces_keep)) {
- line = line
- .replaceAll(rgx.spaces_keep, (m.captures[1]).translate([ ' ' : mkup.nbsp ]));
+ .replaceAll(rgx.spaces_keep, (m.captures[1]).translate([ ' ' : mkup.nbsp ]));
+ }
+ {
+ auto _get = line.txt_by_line_block_block(an_object, pith);
+ {
+ an_object = _get.this_object;
+ pith = _get.pith;
}
+ }
+ continue;
+ } else if (pith["block_is"] == eN.blk_is.poem) {
+ {
+ auto _get = line.txt_by_line_block_poem(an_object, pith, cntr, object_number_poem, conf_make_meta, tag_in_seg);
{
- auto _get = line.txt_by_line_block_block(an_object, pith);
- {
- an_object = _get.this_object;
- pith = _get.pith;
- }
+ an_object = _get.this_object;
+ pith = _get.pith;
+ cntr = _get.cntr;
}
- continue;
- } else if (pith["block_is"] == eN.blk_is.poem) {
+ }
+ continue;
+ } else if (pith["block_is"] == eN.blk_is.table) {
+ {
+ auto _get = line.txt_by_line_block_table(an_object, pith, conf_make_meta);
{
- auto _get = line.txt_by_line_block_poem(an_object, pith, cntr, object_number_poem, conf_make_meta, tag_in_seg);
- {
- an_object = _get.this_object;
- pith = _get.pith;
- cntr = _get.cntr;
- }
+ an_object = _get.this_object;
+ pith = _get.pith;
+ conf_make_meta = _get.conf_make_meta;
}
- continue;
- } else if (pith["block_is"] == eN.blk_is.table) {
+ }
+ continue;
+ }
+ } else {
+ // not within a block group
+ assert(
+ (pith["block_state"] == eN.blk_state.off)
+ || (pith["block_state"] == eN.blk_state.closing),
+ "block status: none or closed"
+ );
+ if (line.matchFirst(rgx.block_open)) {
+ if (line.matchFirst(rgx.block_poem_open)) {
+ // poem to verse exceptions!
+ object_reset(an_object);
+ processing.remove("verse");
+ object_number_poem["start"] = obj_cite_digits.object_number.to!string;
+ }
+ {
+ auto _get = line.txt_by_line_block_start(pith, dochas, object_number_poem);
{
- auto _get = line.txt_by_line_block_table(an_object, pith, conf_make_meta);
- {
- an_object = _get.this_object;
- pith = _get.pith;
- conf_make_meta = _get.conf_make_meta;
- }
+ pith = _get.pith;
+ dochas = _get.dochas;
+ object_number_poem = _get.object_number_poem;
}
- continue;
}
- } else {
- // not within a block group
+ continue;
+ } else if (!line.empty) {
+ // line not empty - non blocks (headings, paragraphs) & closed blocks
+ assert(
+ !line.empty,
+ "line tested, line not empty surely:\n \"" ~ line ~ "\""
+ );
assert(
(pith["block_state"] == eN.blk_state.off)
|| (pith["block_state"] == eN.blk_state.closing),
- "block status: none or closed"
+ "code block status: none or closed"
);
- if (line.matchFirst(rgx.block_open)) {
- if (line.matchFirst(rgx.block_poem_open)) {
- // poem to verse exceptions!
- object_reset(an_object);
- processing.remove("verse");
- object_number_poem["start"] = obj_cite_digits.object_number.to!string;
- }
- {
- auto _get = line.txt_by_line_block_start(pith, dochas, object_number_poem);
- {
- pith = _get.pith;
- dochas = _get.dochas;
- object_number_poem = _get.object_number_poem;
- }
- }
- continue;
- } else if (!line.empty) {
- // line not empty - non blocks (headings, paragraphs) & closed blocks
- assert(
- !line.empty,
- "line tested, line not empty surely:\n \"" ~ line ~ "\""
- );
+ if (pith["block_state"] == eN.blk_state.closing) {
+ debug(check) { writeln(__LINE__); writeln(line); }
assert(
- (pith["block_state"] == eN.blk_state.off)
- || (pith["block_state"] == eN.blk_state.closing),
- "code block status: none or closed"
+ line.matchFirst(rgx.book_index_item)
+ || line.matchFirst(rgx.book_index_item_open)
+ || pith["section"] == eN.sect.book_index,
+ "\nblocks closed, unless followed by book index, non-matching line:\n \""
+ ~ line ~ "\""
);
- if (pith["block_state"] == eN.blk_state.closing) {
- debug(check) { writeln(__LINE__); writeln(line); }
- assert(
- line.matchFirst(rgx.book_index_item)
- || line.matchFirst(rgx.book_index_item_open)
- || pith["section"] == eN.sect.book_index,
- "\nblocks closed, unless followed by book index, non-matching line:\n \""
- ~ line ~ "\""
- );
+ }
+ if (line.matchFirst(rgx.book_index_item)
+ || line.matchFirst(rgx.book_index_item_open)
+ || pith["section"] == eN.sect.book_index) {
+ { // book_index
+ auto _get = line.flow_book_index_(an_object, book_idx_tmp, pith, opt_action);
+ {
+ an_object = _get.this_object;
+ pith = _get.pith;
+ book_idx_tmp = _get.book_idx_tmp;
+ }
}
- if (line.matchFirst(rgx.book_index_item)
- || line.matchFirst(rgx.book_index_item_open)
- || pith["section"] == eN.sect.book_index) {
- // book_index
+ } else {
+ // not book_index
+ an_object_key = "body_nugget";
+ if (auto m = line.matchFirst(rgx.comment)) {
+ // matched comment
+ debug(comment) { writeln(line); }
+ an_object[an_object_key] ~= line ~= "\n";
+ comp_obj_comment = comp_obj_comment.init;
+ comp_obj_comment.metainfo.is_of_part = "comment"; // breaks flow
+ comp_obj_comment.metainfo.is_of_section = "comment"; // breaks flow
+ comp_obj_comment.metainfo.is_of_type = "comment";
+ comp_obj_comment.metainfo.is_a = "comment";
+ comp_obj_comment.text = an_object[an_object_key].strip;
+ the_document_body_section ~= comp_obj_comment;
{
- auto _get = line.flow_book_index_(an_object, book_idx_tmp, pith, opt_action);
+ auto _get = txt_by_line_common_reset_(line_occur, an_object, pith);
{
- an_object = _get.this_object;
- pith = _get.pith;
- book_idx_tmp = _get.book_idx_tmp;
+ line_occur = _get.line_occur;
+ an_object = _get.this_object;
+ pith = _get.pith;
}
}
- } else {
- // not book_index
- an_object_key = "body_nugget";
- if (auto m = line.matchFirst(rgx.comment)) {
- // matched comment
- debug(comment) { writeln(line); }
- an_object[an_object_key] ~= line ~= "\n";
- comp_obj_comment = comp_obj_comment.init;
- comp_obj_comment.metainfo.is_of_part = "comment"; // breaks flow
- comp_obj_comment.metainfo.is_of_section = "comment"; // breaks flow
- comp_obj_comment.metainfo.is_of_type = "comment";
- comp_obj_comment.metainfo.is_a = "comment";
- comp_obj_comment.text = an_object[an_object_key].strip;
- the_document_body_section ~= comp_obj_comment;
+ processing.remove("verse");
+ ++cntr;
+ } else if ((line_occur["para"] == eN.bi.off
+ && line_occur["heading"] == eN.bi.off)
+ && pith["txt_is"] == eN.txt_is.off
+ ) { // heading or para but neither flag nor line exists
+ if ((conf_make_meta.make.headings.length > 2)
+ && (pith["make_headings"] == eN.bi.off)) {
+ // heading found
{
- auto _get = txt_by_line_common_reset_(line_occur, an_object, pith);
+ auto _get = line.flow_heading_found_(heading_match_str, conf_make_meta.make.headings, heading_match_rgx, pith);
{
- line_occur = _get.line_occur;
- an_object = _get.this_object;
- pith = _get.pith;
+ heading_match_str = _get.heading_match_str;
+ heading_match_rgx = _get.heading_match_rgx;
+ pith = _get.pith;
}
}
- processing.remove("verse");
- ++cntr;
- } else if ((line_occur["para"] == eN.bi.off
+ }
+ if (pith["make_headings"] == eN.bi.on
+ && (line_occur["para"] == eN.bi.off
&& line_occur["heading"] == eN.bi.off)
&& pith["txt_is"] == eN.txt_is.off
- ) { // heading or para but neither flag nor line exists
- if ((conf_make_meta.make.headings.length > 2)
- && (pith["make_headings"] == eN.bi.off)) {
- // heading found
- {
- auto _get = line.flow_heading_found_(heading_match_str, conf_make_meta.make.headings, heading_match_rgx, pith);
- {
- heading_match_str = _get.heading_match_str;
- heading_match_rgx = _get.heading_match_rgx;
- pith = _get.pith;
- }
- }
- }
- if (pith["make_headings"] == eN.bi.on
- && (line_occur["para"] == eN.bi.off
- && line_occur["heading"] == eN.bi.off)
- && pith["txt_is"] == eN.txt_is.off
- ) {
- // heading make set
+ ) {
+ // heading make set
+ {
+ auto _get = line.flow_heading_make_set_(line_occur, heading_match_rgx, pith);
{
- auto _get = line.flow_heading_make_set_(line_occur, heading_match_rgx, pith);
- {
- line = _get.line;
- an_object = _get.this_object;
- pith = _get.pith;
- }
+ line = _get.line;
+ an_object = _get.this_object;
+ pith = _get.pith;
}
}
- // TODO node info: all headings identified at this point,
- // - extract node info here??
- // - how long can it wait?
- // - should be incorporated in composite objects
- // - should happen before endnote links set (they need to be moved down?)
- if (line.matchFirst(rgx.headings)) {
- // heading match
- line = line._doc_header_and_make_substitutions_(conf_make_meta);
- {
- auto _get = line.flow_heading_matched_(
- an_object,
- line_occur,
- an_object_key,
- lv,
- collapsed_lev,
- pith,
- conf_make_meta,
- );
- {
- an_object = _get.this_object;
- pith = _get.pith;
- }
- }
- } else if (line_occur["para"] == eN.bi.off) {
- // para match
- an_object_key = "body_nugget";
- line = line
- ._doc_header_and_make_substitutions_(conf_make_meta)
- ._doc_header_and_make_substitutions_fontface_(conf_make_meta);
+ }
+ // TODO node info: all headings identified at this point,
+ // - extract node info here??
+ // - how long can it wait?
+ // - should be incorporated in composite objects
+ // - should happen before endnote links set (they need to be moved down?)
+ if (line.matchFirst(rgx.headings)) {
+ // heading match
+ line = line._doc_header_and_make_substitutions_(conf_make_meta);
+ {
+ auto _get = line.flow_heading_matched_(
+ an_object,
+ line_occur,
+ an_object_key,
+ lv,
+ collapsed_lev,
+ pith,
+ conf_make_meta,
+ );
{
- auto _get = line.flow_para_match_(an_object, an_object_key, indent, bullet, pith, line_occur);
- {
- an_object = _get.this_object;
- an_object_key = _get.this_object_key;
- pith = _get.pith;
- indent = _get.indent;
- bullet = _get.bullet;
- line_occur = _get.line_occur;
- }
+ an_object = _get.this_object;
+ pith = _get.pith;
}
}
- } else if (line_occur["heading"] > eN.bi.off) {
- // heading
- debug(heading) { writeln(line); }
- an_object[an_object_key] ~= line ~= "\n";
- ++line_occur["heading"];
- } else if (line_occur["para"] > eN.bi.off) {
- // paragraph
- debug(para) { writeln(an_object_key, "-> ", line); }
+ } else if (line_occur["para"] == eN.bi.off) {
+ // para match
+ an_object_key = "body_nugget";
line = line
._doc_header_and_make_substitutions_(conf_make_meta)
._doc_header_and_make_substitutions_fontface_(conf_make_meta);
- an_object[an_object_key] ~= " " ~ line;
- ++line_occur["para"];
+ {
+ auto _get = line.flow_para_match_(an_object, an_object_key, indent, bullet, pith, line_occur);
+ {
+ an_object = _get.this_object;
+ an_object_key = _get.this_object_key;
+ pith = _get.pith;
+ indent = _get.indent;
+ bullet = _get.bullet;
+ line_occur = _get.line_occur;
+ }
+ }
}
+ } else if (line_occur["heading"] > eN.bi.off) {
+ // heading
+ debug(heading) { writeln(line); }
+ an_object[an_object_key] ~= line ~= "\n";
+ ++line_occur["heading"];
+ } else if (line_occur["para"] > eN.bi.off) {
+ // paragraph
+ debug(para) { writeln(an_object_key, "-> ", line); }
+ line = line
+ ._doc_header_and_make_substitutions_(conf_make_meta)
+ ._doc_header_and_make_substitutions_fontface_(conf_make_meta);
+ an_object[an_object_key] ~= " " ~ line;
+ ++line_occur["para"];
}
- } else if (pith["block_state"] == eN.blk_state.closing) {
- // line empty, with blocks flag
+ }
+ } else if (pith["block_state"] == eN.blk_state.closing) {
+ // line empty, with blocks flag
+ {
+ auto _get = line.flow_block_flag_line_empty_(
+ an_object,
+ bookindex_extract_hash,
+ the_document_body_section,
+ bookindex_unordered_hashes,
+ obj_cite_digits,
+ comp_obj_heading,
+ cntr,
+ pith,
+ object_number_poem,
+ conf_make_meta,
+ tag_in_seg,
+ );
{
- auto _get = line.flow_block_flag_line_empty_(
- an_object,
- bookindex_extract_hash,
- the_document_body_section,
- bookindex_unordered_hashes,
- obj_cite_digits,
- comp_obj_heading,
- cntr,
- pith,
- object_number_poem,
- conf_make_meta,
- tag_in_seg,
- );
- {
- an_object = _get.this_object;
- the_document_body_section = _get.the_document_body_section;
- bookindex_unordered_hashes = _get.bookindex_unordered_hashes;
- obj_cite_digits = _get.obj_cite_digits;
- comp_obj_heading = _get.comp_obj_heading;
- cntr = _get.cntr;
- pith = _get.pith;
- }
+ an_object = _get.this_object;
+ the_document_body_section = _get.the_document_body_section;
+ bookindex_unordered_hashes = _get.bookindex_unordered_hashes;
+ obj_cite_digits = _get.obj_cite_digits;
+ comp_obj_heading = _get.comp_obj_heading;
+ cntr = _get.cntr;
+ pith = _get.pith;
}
- } else {
- // line.empty, post contents, empty variables:
- assert(
- line.empty,
- "\nline should be empty:\n \""
- ~ line ~ "\""
- );
- assert(
- (pith["block_state"] == eN.blk_state.off),
- "code block status: none"
- );
+ }
+ } else {
+ // line.empty, post contents, empty variables:
+ assert(
+ line.empty,
+ "\nline should be empty:\n \""
+ ~ line ~ "\""
+ );
+ assert(
+ (pith["block_state"] == eN.blk_state.off),
+ "code block status: none"
+ );
+ if (_new_doc) {
+ tag_assoc = tag_assoc.init;
+ lv0to3_tags = lv0to3_tags.init;
+ tag_in_seg = tag_in_seg.init;
+ }
+ if (pith["txt_is"] == eN.txt_is.heading
+ && line_occur["heading"] > eN.bi.off
+ ) {
+ // heading object (current line empty)
+ obj_cite_digits = (an_object["lev_markup_number"].to!int == 0)
+ ? ocn_emit(eN.ocn.reset)
+ : ocn_emit(pith["ocn"]);
+ an_object["is"] = "heading";
+ an_object_key = "body_nugget";
+ ST_txtAndAnchorTagPlusHasFootnotesUrlsImages substantive_object_and_anchor_tags_struct
+ = obj_im.obj_inline_markup_and_anchor_tags_and_misc(an_object, an_object_key, conf_make_meta, ((_new_doc) ? Yes._new_doc : No._new_doc));
+ an_object["substantive"] = substantive_object_and_anchor_tags_struct.obj_txt;
+ anchor_tag = substantive_object_and_anchor_tags_struct.anchor_tag;
if (_new_doc) {
- tag_assoc = tag_assoc.init;
- lv0to3_tags = lv0to3_tags.init;
- tag_in_seg = tag_in_seg.init;
+ cnt1 = 1;
+ cnt2 = 1;
+ cnt3 = 1;
+ _new_doc = false;
}
- if (pith["txt_is"] == eN.txt_is.heading
- && line_occur["heading"] > eN.bi.off
+ if (
+ an_object["lev_markup_number"].to!int == 4
+ && (!(anchor_tag.empty)
+ || (lv0to3_tags.length > 0))
) {
- // heading object (current line empty)
- obj_cite_digits = (an_object["lev_markup_number"].to!int == 0)
- ? ocn_emit(eN.ocn.reset)
- : ocn_emit(pith["ocn"]);
- an_object["is"] = "heading";
- an_object_key = "body_nugget";
- ST_txtAndAnchorTagPlusHasFootnotesUrlsImages substantive_object_and_anchor_tags_struct
- = obj_im.obj_inline_markup_and_anchor_tags_and_misc(an_object, an_object_key, conf_make_meta, ((_new_doc) ? Yes._new_doc : No._new_doc));
- an_object["substantive"] = substantive_object_and_anchor_tags_struct.obj_txt;
- anchor_tag = substantive_object_and_anchor_tags_struct.anchor_tag;
- if (_new_doc) {
- cnt1 = 1;
- cnt2 = 1;
- cnt3 = 1;
- _new_doc = false;
- }
- if (
- an_object["lev_markup_number"].to!int == 4
- && (!(anchor_tag.empty)
- || (lv0to3_tags.length > 0))
- ) {
- tag_in_seg["seg_lv4"] = anchor_tag;
- tag_in_seg["seg_lv1to4"] = anchor_tag;
- lev_anchor_tag = anchor_tag;
- tag_assoc[anchor_tag]["seg_lv4"] = tag_in_seg["seg_lv4"];
- tag_assoc[anchor_tag]["seg_lv1to4"] = tag_in_seg["seg_lv1to4"];
- if (lv0to3_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; lv0to3_tags) {
- tag_assoc[lv0_to_lv3_html_tag]["seg_lv4"] = anchor_tag;
- }
- }
- anchor_tag_ = anchor_tag;
- lv0to3_tags = lv0to3_tags.init;
- } else if (an_object["lev_markup_number"].to!int > 4) {
- tag_in_seg["seg_lv4"] = anchor_tag_;
- tag_in_seg["seg_lv1to4"] = anchor_tag_;
- lev_anchor_tag = anchor_tag;
- tag_assoc[anchor_tag]["seg_lv4"] = tag_in_seg["seg_lv4"];
- tag_assoc[anchor_tag]["seg_lv1to4"] = tag_in_seg["seg_lv1to4"];
- } else if (an_object["lev_markup_number"].to!int < 4) {
- string segn;
- switch (an_object["lev_markup_number"].to!int) {
- // names used for epub markup segments A to D
- case 0:
- segn = "_the_title";
- goto default;
- case 1:
- segn = "_part_" ~ cnt1.to!string;
- ++cnt1;
- goto default;
- case 2:
- segn = "_part_" ~ cnt1.to!string ~ "_" ~ cnt2.to!string;
- ++cnt2;
- goto default;
- case 3:
- segn = "_part_" ~ cnt1.to!string ~ "_" ~ cnt2.to!string ~ "_" ~ cnt3.to!string;
- ++cnt3;
- goto default;
- default:
- lv0to3_tags ~= obj_cite_digits.object_number.to!string;
- lv0to3_tags ~= segn;
- tag_in_seg["seg_lv4"] = segn; // for html segname need following lv4 not yet known
- tag_in_seg["seg_lv1to4"] = segn;
- break;
+ tag_in_seg["seg_lv4"] = anchor_tag;
+ tag_in_seg["seg_lv1to4"] = anchor_tag;
+ lev_anchor_tag = anchor_tag;
+ tag_assoc[anchor_tag]["seg_lv4"] = tag_in_seg["seg_lv4"];
+ tag_assoc[anchor_tag]["seg_lv1to4"] = tag_in_seg["seg_lv1to4"];
+ if (lv0to3_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; lv0to3_tags) {
+ tag_assoc[lv0_to_lv3_html_tag]["seg_lv4"] = anchor_tag;
}
}
- 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, tag_in_seg);
- _anchor_tag = obj_cite_digits.identifier;
- // (incrementally build toc) table of contents here!
- {
- auto _get = obj_im.flow_table_of_contents_gather_headings(
- an_object,
- conf_make_meta,
- tag_in_seg,
- _anchor_tag,
- lev4_subtoc,
- the_document_toc_section,
- );
- {
- the_document_toc_section = _get.the_document_toc_section;
- lev4_subtoc = _get.lev4_subtoc;
- }
- }
- if (an_object["lev_markup_number"] == "4") {
- 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_lv1to4"];
- }
- auto comp_obj_heading = node_construct.node_emitter_heading(
- an_object["substantive"],
- an_object["lev_markup_number"],
- an_object["lev_collapsed_number"],
- an_object["dummy_heading_status"],
- tag_in_seg,
- lev_anchor_tag,
- tag_assoc,
- obj_cite_digits, // OCNset
- cntr, // int
- heading_ptr, // int
- lv_ancestors_txt, // string[]
- an_object["is"], // string
- html_segnames_ptr, // int
- substantive_object_and_anchor_tags_struct.has_notes_reg,
- substantive_object_and_anchor_tags_struct.has_notes_star,
- substantive_object_and_anchor_tags_struct.has_links,
- );
- ++heading_ptr;
- debug(segments) {
- writeln(an_object["lev_markup_number"]);
- writeln(tag_in_seg["seg_lv4"]);
- writeln(tag_in_seg["seg_lv1to4"]);
+ anchor_tag_ = anchor_tag;
+ lv0to3_tags = lv0to3_tags.init;
+ } else if (an_object["lev_markup_number"].to!int > 4) {
+ tag_in_seg["seg_lv4"] = anchor_tag_;
+ tag_in_seg["seg_lv1to4"] = anchor_tag_;
+ lev_anchor_tag = anchor_tag;
+ tag_assoc[anchor_tag]["seg_lv4"] = tag_in_seg["seg_lv4"];
+ tag_assoc[anchor_tag]["seg_lv1to4"] = tag_in_seg["seg_lv1to4"];
+ } else if (an_object["lev_markup_number"].to!int < 4) {
+ string segn;
+ switch (an_object["lev_markup_number"].to!int) {
+ // names used for epub markup segments A to D
+ case 0:
+ segn = "_the_title";
+ goto default;
+ case 1:
+ segn = "_part_" ~ cnt1.to!string;
+ ++cnt1;
+ goto default;
+ case 2:
+ segn = "_part_" ~ cnt1.to!string ~ "_" ~ cnt2.to!string;
+ ++cnt2;
+ goto default;
+ case 3:
+ segn = "_part_" ~ cnt1.to!string ~ "_" ~ cnt2.to!string ~ "_" ~ cnt3.to!string;
+ ++cnt3;
+ goto default;
+ default:
+ lv0to3_tags ~= obj_cite_digits.object_number.to!string;
+ lv0to3_tags ~= segn;
+ tag_in_seg["seg_lv4"] = segn; // for html segname need following lv4 not yet known
+ tag_in_seg["seg_lv1to4"] = segn;
+ break;
}
- the_document_body_section ~= comp_obj_heading;
- debug(objectrelated1) { writeln(line); } // check
+ }
+ 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, tag_in_seg);
+ _anchor_tag = obj_cite_digits.identifier;
+ // (incrementally build toc) table of contents here!
+ {
+ auto _get = obj_im.flow_table_of_contents_gather_headings(
+ an_object,
+ conf_make_meta,
+ tag_in_seg,
+ _anchor_tag,
+ lev4_subtoc,
+ the_document_toc_section,
+ );
{
- auto _get = txt_by_line_common_reset_(line_occur, an_object, pith);
- {
- line_occur = _get.line_occur;
- an_object = _get.this_object;
- pith = _get.pith;
- }
- }
- an_object.remove("lev");
- an_object.remove("lev_markup_number");
- processing.remove("verse");
- ++cntr;
- } else if (pith["txt_is"] == eN.txt_is.para
- && line_occur["para"] > eN.bi.off
- ) { // paragraph object (current line empty) - repeated character paragraph separator
- if ((an_object[an_object_key].to!string).matchFirst(rgx.repeated_character_line_separator)) {
- pith["ocn"] = eN.ocn.off;
+ the_document_toc_section = _get.the_document_toc_section;
+ lev4_subtoc = _get.lev4_subtoc;
}
- obj_cite_digits = ocn_emit(pith["ocn"]);
- 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, tag_in_seg);
- an_object["is"] = "para";
- auto comp_obj_heading = node_construct.node_location_emitter(
- content_non_header,
- tag_in_seg,
- lev_anchor_tag,
- tag_assoc,
- obj_cite_digits,
- cntr,
- heading_ptr-1,
- an_object["is"],
- );
- ST_txtAndAnchorTagPlusHasFootnotesUrlsImages substantive_obj_misc_struct
- = obj_im.obj_inline_markup_and_anchor_tags_and_misc(an_object, an_object_key, conf_make_meta, No._new_doc);
- an_object["substantive"] = substantive_obj_misc_struct.obj_txt;
- anchor_tag = substantive_obj_misc_struct.anchor_tag;
- 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.html_segment_anchor_tag_is = tag_in_seg["seg_lv4"];
- comp_obj_para.tags.epub_segment_anchor_tag_is = tag_in_seg["seg_lv1to4"];
- comp_obj_para.metainfo.ocn = obj_cite_digits.object_number;
- comp_obj_para.metainfo.identifier = obj_cite_digits.identifier;
- comp_obj_para.metainfo.object_number_off = (obj_cite_digits.off == 0) ? true : false; // TODO
- comp_obj_para.metainfo.o_n_book_index = obj_cite_digits.bkidx;
- comp_obj_para.metainfo.object_number_type = obj_cite_digits.type;
- comp_obj_para.attrib.indent_hang = indent["hang_position"];
- comp_obj_para.attrib.indent_base = indent["base_position"];
- comp_obj_para.attrib.bullet = bullet;
- comp_obj_para.tags.anchor_tags = [anchor_tag]; anchor_tag="";
- comp_obj_para.has.inline_notes_reg = substantive_obj_misc_struct.has_notes_reg;
- comp_obj_para.has.inline_notes_star = substantive_obj_misc_struct.has_notes_star;
- comp_obj_para.has.inline_links = substantive_obj_misc_struct.has_links;
- comp_obj_para.has.image_without_dimensions = substantive_obj_misc_struct.has_images_without_dimensions;
- the_document_body_section ~= comp_obj_para;
- tag_assoc = an_object.inline_para_link_anchor(tag_in_seg, tag_assoc);
+ }
+ if (an_object["lev_markup_number"] == "4") {
+ 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_lv1to4"];
+ }
+ auto comp_obj_heading = node_construct.node_emitter_heading(
+ an_object["substantive"],
+ an_object["lev_markup_number"],
+ an_object["lev_collapsed_number"],
+ an_object["dummy_heading_status"],
+ tag_in_seg,
+ lev_anchor_tag,
+ tag_assoc,
+ obj_cite_digits, // OCNset
+ cntr, // int
+ heading_ptr, // int
+ lv_ancestors_txt, // string[]
+ an_object["is"], // string
+ html_segnames_ptr, // int
+ substantive_object_and_anchor_tags_struct.has_notes_reg,
+ substantive_object_and_anchor_tags_struct.has_notes_star,
+ substantive_object_and_anchor_tags_struct.has_links,
+ );
+ ++heading_ptr;
+ debug(segments) {
+ writeln(an_object["lev_markup_number"]);
+ writeln(tag_in_seg["seg_lv4"]);
+ writeln(tag_in_seg["seg_lv1to4"]);
+ }
+ the_document_body_section ~= comp_obj_heading;
+ debug(objectrelated1) { writeln(line); } // check
+ {
+ auto _get = txt_by_line_common_reset_(line_occur, an_object, pith);
{
- auto _get = txt_by_line_common_reset_(line_occur, an_object, pith);
- {
- line_occur = _get.line_occur;
- an_object = _get.this_object;
- pith = _get.pith;
- }
+ line_occur = _get.line_occur;
+ an_object = _get.this_object;
+ pith = _get.pith;
}
- indent = [
- "hang_position" : 0,
- "base_position" : 0,
- ];
- bullet = false;
- processing.remove("verse");
- ++cntr;
- // } else { // could be useful to test line variable should be empty and never null
}
- } // close else for line empty
- } // close else for not the above
- } // close after non code, other blocks or regular text
- // unless (the_document_body_section.length == 0) ?
- if (the_document_body_section.length > 0) {
- if (((the_document_body_section[$-1].metainfo.is_a == "para")
- || (the_document_body_section[$-1].metainfo.is_a == "heading")
- || (the_document_body_section[$-1].metainfo.is_a == "quote")
- || (the_document_body_section[$-1].metainfo.is_a == "group")
- || (the_document_body_section[$-1].metainfo.is_a == "block")
- || (the_document_body_section[$-1].metainfo.is_a == "verse"))
- && (the_document_body_section.length > previous_length)) {
- if ((the_document_body_section[$-1].metainfo.is_a == "heading")
- && (the_document_body_section[$-1].metainfo.heading_lev_markup < 5)) {
- pith["section"] = eN.sect.unset;
- }
- if (the_document_body_section[$-1].metainfo.is_a == "verse") {
- // scan for endnotes for whole poem (each verse in poem)
- foreach (i; previous_length .. the_document_body_section.length) {
- if (the_document_body_section[i].metainfo.is_a == "verse") {
- if ((the_document_body_section[i].text).match(
- rgx.inline_notes_al_all_note
- )) {
- object_notes = note_section.gather_notes_for_endnote_section(
- the_document_body_section,
- tag_in_seg,
- (i).to!int,
- );
- }
- }
+ an_object.remove("lev");
+ an_object.remove("lev_markup_number");
+ processing.remove("verse");
+ ++cntr;
+ } else if (pith["txt_is"] == eN.txt_is.para
+ && line_occur["para"] > eN.bi.off
+ ) { // paragraph object (current line empty) - repeated character paragraph separator
+ if ((an_object[an_object_key].to!string).matchFirst(rgx.repeated_character_line_separator)) {
+ pith["ocn"] = eN.ocn.off;
}
- } else {
- // scan object for endnotes
- previous_length = the_document_body_section.length.to!int;
- if ((the_document_body_section[$-1].text).match(
- rgx.inline_notes_al_all_note
- )) {
- previous_count = (the_document_body_section.length -1).to!int;
- object_notes = note_section.gather_notes_for_endnote_section(
- the_document_body_section,
+ obj_cite_digits = ocn_emit(pith["ocn"]);
+ 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, tag_in_seg);
+ an_object["is"] = "para";
+ auto comp_obj_heading = node_construct.node_location_emitter(
+ content_non_header,
tag_in_seg,
- (the_document_body_section.length-1).to!int,
+ lev_anchor_tag,
+ tag_assoc,
+ obj_cite_digits,
+ cntr,
+ heading_ptr-1,
+ an_object["is"],
);
+ ST_txtAndAnchorTagPlusHasFootnotesUrlsImages substantive_obj_misc_struct
+ = obj_im.obj_inline_markup_and_anchor_tags_and_misc(an_object, an_object_key, conf_make_meta, No._new_doc);
+ an_object["substantive"] = substantive_obj_misc_struct.obj_txt;
+ anchor_tag = substantive_obj_misc_struct.anchor_tag;
+ 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.html_segment_anchor_tag_is = tag_in_seg["seg_lv4"];
+ comp_obj_para.tags.epub_segment_anchor_tag_is = tag_in_seg["seg_lv1to4"];
+ comp_obj_para.metainfo.ocn = obj_cite_digits.object_number;
+ comp_obj_para.metainfo.identifier = obj_cite_digits.identifier;
+ comp_obj_para.metainfo.object_number_off = (obj_cite_digits.off == 0) ? true : false; // TODO
+ comp_obj_para.metainfo.o_n_book_index = obj_cite_digits.bkidx;
+ comp_obj_para.metainfo.object_number_type = obj_cite_digits.type;
+ comp_obj_para.attrib.indent_hang = indent["hang_position"];
+ comp_obj_para.attrib.indent_base = indent["base_position"];
+ comp_obj_para.attrib.bullet = bullet;
+ comp_obj_para.tags.anchor_tags = [anchor_tag]; anchor_tag="";
+ comp_obj_para.has.inline_notes_reg = substantive_obj_misc_struct.has_notes_reg;
+ comp_obj_para.has.inline_notes_star = substantive_obj_misc_struct.has_notes_star;
+ comp_obj_para.has.inline_links = substantive_obj_misc_struct.has_links;
+ comp_obj_para.has.image_without_dimensions = substantive_obj_misc_struct.has_images_without_dimensions;
+ the_document_body_section ~= comp_obj_para;
+ tag_assoc = an_object.inline_para_link_anchor(tag_in_seg, tag_assoc);
+ {
+ auto _get = txt_by_line_common_reset_(line_occur, an_object, pith);
+ {
+ line_occur = _get.line_occur;
+ an_object = _get.this_object;
+ pith = _get.pith;
+ }
}
+ indent = [
+ "hang_position" : 0,
+ "base_position" : 0,
+ ];
+ bullet = false;
+ processing.remove("verse");
+ ++cntr;
+ // } else { // could be useful to test line variable should be empty and never null
}
+ } // close else for line empty
+ } // close else for not the above
+ } // close after non code, other blocks or regular text
+ // unless (the_document_body_section.length == 0) ?
+ if (the_document_body_section.length > 0) {
+ if (((the_document_body_section[$-1].metainfo.is_a == "para")
+ || (the_document_body_section[$-1].metainfo.is_a == "heading")
+ || (the_document_body_section[$-1].metainfo.is_a == "quote")
+ || (the_document_body_section[$-1].metainfo.is_a == "group")
+ || (the_document_body_section[$-1].metainfo.is_a == "block")
+ || (the_document_body_section[$-1].metainfo.is_a == "verse"))
+ && (the_document_body_section.length > previous_length)) {
+ if ((the_document_body_section[$-1].metainfo.is_a == "heading")
+ && (the_document_body_section[$-1].metainfo.heading_lev_markup < 5)) {
+ pith["section"] = eN.sect.unset;
+ }
+ if (the_document_body_section[$-1].metainfo.is_a == "verse") {
+ // scan for endnotes for whole poem (each verse in poem)
+ foreach (i; previous_length .. the_document_body_section.length) {
+ if (the_document_body_section[i].metainfo.is_a == "verse") {
+ if ((the_document_body_section[i].text).match(
+ rgx.inline_notes_al_all_note
+ )) {
+ object_notes = note_section.gather_notes_for_endnote_section(
+ the_document_body_section,
+ tag_in_seg,
+ (i).to!int,
+ );
+ }
+ }
+ }
+ } else {
+ // scan object for endnotes
previous_length = the_document_body_section.length.to!int;
+ if ((the_document_body_section[$-1].text).match(
+ rgx.inline_notes_al_all_note
+ )) {
+ previous_count = (the_document_body_section.length -1).to!int;
+ object_notes = note_section.gather_notes_for_endnote_section(
+ the_document_body_section,
+ tag_in_seg,
+ (the_document_body_section.length-1).to!int,
+ );
+ }
}
+ previous_length = the_document_body_section.length.to!int;
}
}
- ret.toc = the_document_toc_section;
- ret.body = the_document_body_section;
- ret.glossary = the_document_glossary_section;
- ret.blurb = the_document_blurb_section;
- ret.object_notes = object_notes;
- ret.segnames = segnames;
- return ret;
}
- { // loopMarkupSrcByLine
- auto _doc_by_line = loopMarkupSrcByLine(markup_sourcefile_content, an_object, pith);
- the_document_toc_section = _doc_by_line.toc;
- the_document_body_section = _doc_by_line.body;
- the_document_glossary_section = _doc_by_line.glossary;
- the_document_blurb_section = _doc_by_line.blurb;
- segnames = _doc_by_line.segnames;
- object_notes = _doc_by_line.object_notes; // endnotes, compare, not sure is used
- destroy(_doc_by_line);
- }
- { // EOF
- comp_obj_heading_ = comp_obj_heading_.init;
- comp_obj_heading_.metainfo.is_of_part = "backmatter";
- comp_obj_heading_.metainfo.is_of_section = "tail";
- comp_obj_heading_.metainfo.is_of_type = "para";
- comp_obj_heading_.metainfo.is_a = "heading";
- comp_obj_heading_.text = "";
- comp_obj_heading_.metainfo.ocn = 0;
- comp_obj_heading_.metainfo.identifier = "";
- comp_obj_heading_.metainfo.dummy_heading = false;
- comp_obj_heading_.metainfo.object_number_off = false;
- comp_obj_heading_.metainfo.object_number_type = 0;
- comp_obj_heading_.tags.segment_anchor_tag_epub = "_part_eof";
- comp_obj_heading_.tags.anchor_tag_html = comp_obj_heading_.tags.segment_anchor_tag_epub;
- comp_obj_heading_.tags.in_segment_html = "tail";
- comp_obj_heading_.tags.anchor_tags = ["section_eof"];
- comp_obj_heading_.metainfo.heading_lev_markup = 1;
- comp_obj_heading_.metainfo.heading_lev_collapsed = 1;
- comp_obj_heading_.metainfo.parent_ocn = 1;
- comp_obj_heading_.metainfo.parent_lev_markup = 0;
- comp_obj_heading_.metainfo.dom_structure_markedup_tags_status = [ 0, 0, 0, 0, 0, 0, 0, 0];
- comp_obj_heading_.metainfo.dom_structure_collapsed_tags_status = [ 0, 0, 0, 0, 0, 0, 0, 0];
- the_document_xml_dom_tail_section ~= comp_obj_heading_;
+ ret.toc = the_document_toc_section;
+ ret.body = the_document_body_section;
+ ret.glossary = the_document_glossary_section;
+ ret.blurb = the_document_blurb_section;
+ ret.object_notes = object_notes;
+ ret.segnames = segnames;
+ return ret;
+}
+{ // loopMarkupSrcByLine
+ auto _doc_by_line = loopMarkupSrcByLine(markup_sourcefile_content, an_object, pith);
+ the_document_toc_section = _doc_by_line.toc;
+ the_document_body_section = _doc_by_line.body;
+ the_document_glossary_section = _doc_by_line.glossary;
+ the_document_blurb_section = _doc_by_line.blurb;
+ segnames = _doc_by_line.segnames;
+ object_notes = _doc_by_line.object_notes; // endnotes, compare, not sure is used
+ destroy(_doc_by_line);
+}
+#+END_SRC
+
+*** post loop (consider and segment/break up further in code & org)
+
+#+NAME: docAbstractionPostMainLoop
+#+HEADER: :noweb yes
+#+BEGIN_SRC d
+{ // EOF backMatter
+ comp_obj_heading_ = comp_obj_heading_.init;
+ comp_obj_heading_.metainfo.is_of_part = "backmatter";
+ comp_obj_heading_.metainfo.is_of_section = "tail";
+ comp_obj_heading_.metainfo.is_of_type = "para";
+ comp_obj_heading_.metainfo.is_a = "heading";
+ comp_obj_heading_.text = "";
+ comp_obj_heading_.metainfo.ocn = 0;
+ comp_obj_heading_.metainfo.identifier = "";
+ comp_obj_heading_.metainfo.dummy_heading = false;
+ comp_obj_heading_.metainfo.object_number_off = false;
+ comp_obj_heading_.metainfo.object_number_type = 0;
+ comp_obj_heading_.tags.segment_anchor_tag_epub = "_part_eof";
+ comp_obj_heading_.tags.anchor_tag_html = comp_obj_heading_.tags.segment_anchor_tag_epub;
+ comp_obj_heading_.tags.in_segment_html = "tail";
+ comp_obj_heading_.tags.anchor_tags = ["section_eof"];
+ comp_obj_heading_.metainfo.heading_lev_markup = 1;
+ comp_obj_heading_.metainfo.heading_lev_collapsed = 1;
+ comp_obj_heading_.metainfo.parent_ocn = 1;
+ comp_obj_heading_.metainfo.parent_lev_markup = 0;
+ comp_obj_heading_.metainfo.dom_structure_markedup_tags_status = [ 0, 0, 0, 0, 0, 0, 0, 0];
+ comp_obj_heading_.metainfo.dom_structure_collapsed_tags_status = [ 0, 0, 0, 0, 0, 0, 0, 0];
+ the_document_xml_dom_tail_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_lv1to4"] = comp_obj_heading_.tags.segment_anchor_tag_epub;
+}
+// endNotes
+auto en_tuple = note_section.endnote_objects(obj_cite_digits, opt_action); // endnotes, check
+auto the_document_endnotes_section = en_tuple[0];
+obj_cite_digits = en_tuple[1];
+debug(endnotes) {
+ writefln("%s %s", __LINE__, the_document_endnotes_section.length);
+ foreach (o; the_document_endnotes_section) { writeln(o); }
+}
+// glossary
+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.identifier = "";
+ comp_obj_heading_.metainfo.dummy_heading = true;
+ comp_obj_heading_.metainfo.object_number_off = true;
+ comp_obj_heading_.metainfo.object_number_type = 0;
+ comp_obj_heading_.metainfo.heading_lev_markup = 1;
+ comp_obj_heading_.metainfo.heading_lev_collapsed = 1;
+ comp_obj_heading_.metainfo.parent_ocn = 1;
+ comp_obj_heading_.metainfo.parent_lev_markup = 0;
+ the_document_glossary_section ~= comp_obj_heading_;
+}
+debug(glossary) { foreach (gloss; the_document_glossary_section) { writeln(gloss.text); } }
+// bibliography
+auto biblio_unsorted_incomplete = biblio_arr_json.dup;
+auto biblio = Bibliography();
+JSONValue[] biblio_ordered;
+{
+ auto _get = biblio.flow_bibliography_(biblio_unsorted_incomplete, bib_arr_json);
+ {
+ biblio_ordered = _get.biblio_sorted;
+ bib_arr_json = _get.bib_arr_json;
+ biblio_unsorted_incomplete = _get.biblio_unsorted_incomplete;
+ }
+}
+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.identifier = "";
+ comp_obj_heading_.metainfo.dummy_heading = false;
+ comp_obj_heading_.metainfo.object_number_off = false;
+ 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_.tags.anchor_tags = ["section_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;
+ 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_document_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_lv1to4"] = comp_obj_heading_.tags.segment_anchor_tag_epub;
}
- auto en_tuple = note_section.endnote_objects(obj_cite_digits, opt_action); // endnotes, check
- auto the_document_endnotes_section = en_tuple[0];
- obj_cite_digits = en_tuple[1];
- debug(endnotes) {
- writefln("%s %s", __LINE__, the_document_endnotes_section.length);
- foreach (o; the_document_endnotes_section) { writeln(o); }
- }
- 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.identifier = "";
- comp_obj_heading_.metainfo.dummy_heading = true;
- comp_obj_heading_.metainfo.object_number_off = true;
- comp_obj_heading_.metainfo.object_number_type = 0;
- comp_obj_heading_.metainfo.heading_lev_markup = 1;
- comp_obj_heading_.metainfo.heading_lev_collapsed = 1;
- comp_obj_heading_.metainfo.parent_ocn = 1;
- comp_obj_heading_.metainfo.parent_lev_markup = 0;
- the_document_glossary_section ~= comp_obj_heading_;
- }
- debug(glossary) { foreach (gloss; the_document_glossary_section) { writeln(gloss.text); } }
- auto biblio_unsorted_incomplete = biblio_arr_json.dup;
- auto biblio = Bibliography();
- JSONValue[] biblio_ordered;
{
- auto _get = biblio.flow_bibliography_(biblio_unsorted_incomplete, bib_arr_json);
- {
- biblio_ordered = _get.biblio_sorted;
- bib_arr_json = _get.bib_arr_json;
- biblio_unsorted_incomplete = _get.biblio_unsorted_incomplete;
+ 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.identifier = "";
+ comp_obj_heading_.metainfo.dummy_heading = true;
+ comp_obj_heading_.metainfo.object_number_off = true;
+ comp_obj_heading_.metainfo.object_number_type = 0;
+ comp_obj_heading_.tags.segment_anchor_tag_epub = "bibliography";
+ 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_.metainfo.dom_structure_markedup_tags_status = [ 1, 1, 0, 0, 1, 0, 0, 0];
+ comp_obj_heading_.metainfo.dom_structure_collapsed_tags_status = [ 1, 1, 1, 0, 0, 0, 0, 0];
+ comp_obj_heading_.tags.anchor_tags = ["bibliography"];
+ the_document_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_lv1to4"] = comp_obj_heading_.tags.segment_anchor_tag_epub;
+ }
+ {
+ string out_;
+ foreach (entry; biblio_ordered) {
+ out_ = format("%s \"%s\"%s%s%s%s%s%s%s%s%s.",
+ ((entry["author"].str.empty) ? entry["editor"].str : entry["author"].str),
+ entry["fulltitle"].str,
+ ((entry["journal"].str.empty) ? "" : ", " ~ mkup.ff_i ~ mkup.italic ~ mkup.ff_o ~ entry["journal"].str ~ mkup.ff_c ~ mkup.italic),
+ ((entry["volume"].str.empty) ? "" : ", " ~ entry["volume"].str),
+ ((entry["in"].str.empty) ? "" : ", " ~ entry["in"].str),
+ ((!(entry["author"].str.empty) && (!(entry["editor"].str.empty))) ? entry["editor"].str : ""),
+ ", " ~ entry["year"].str,
+ ((entry["pages"].str.empty) ? "" : ", " ~ entry["pages"].str),
+ ((entry["publisher"].str.empty) ? "" : ", " ~ entry["publisher"].str),
+ ((entry["place"].str.empty) ? "" : ", " ~ entry["place"].str),
+ ((entry["url"].str.empty) ? "" : ", [" ~ entry["url"].str ~ "]"),
+ );
+ comp_obj_para = comp_obj_para.init;
+ comp_obj_para.metainfo.is_of_part = "backmatter";
+ comp_obj_para.metainfo.is_of_section = "bibliography";
+ comp_obj_para.metainfo.is_of_type = "para";
+ comp_obj_para.metainfo.is_a = "bibliography";
+ comp_obj_para.text = out_.to!string.strip;
+ comp_obj_para.metainfo.ocn = 0;
+ comp_obj_para.metainfo.identifier = "";
+ comp_obj_para.metainfo.object_number_off = true;
+ comp_obj_para.metainfo.object_number_type = 0;
+ comp_obj_para.attrib.indent_hang = 0;
+ comp_obj_para.attrib.indent_base = 1;
+ comp_obj_para.attrib.bullet = bullet;
+ comp_obj_para.tags.anchor_tags = [anchor_tag];
+ the_document_bibliography_section ~= comp_obj_para;
+ }
+ }
+} 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.identifier = "";
+ comp_obj_heading_.metainfo.dummy_heading = true;
+ comp_obj_heading_.metainfo.object_number_off = true;
+ comp_obj_heading_.metainfo.object_number_type = 0;
+ comp_obj_heading_.metainfo.heading_lev_markup = 1;
+ comp_obj_heading_.metainfo.heading_lev_collapsed = 1;
+ comp_obj_heading_.metainfo.parent_ocn = 1;
+ comp_obj_heading_.metainfo.parent_lev_markup = 0;
+ the_document_bibliography_section ~= comp_obj_heading_;
+}
+debug(bibliosection) { foreach (o; the_document_bibliography_section) { writeln(o.text); } }
+auto bi = BookIndexReportSection();
+auto bi_tuple
+ = bi.bookindex_build_abstraction_section(
+ bookindex_unordered_hashes,
+ obj_cite_digits,
+ opt_action,
+ );
+// bookindex
+destroy(bookindex_unordered_hashes);
+auto the_document_bookindex_section = bi_tuple[0];
+obj_cite_digits = bi_tuple[1];
+debug(bookindex) { foreach (bi_entry; the_document_bookindex_section) { writeln(bi_entry); } }
+if (an_object["blurb_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 Blurb section";
+ comp_obj_heading_.metainfo.ocn = 0;
+ comp_obj_heading_.metainfo.identifier = "";
+ comp_obj_para.metainfo.object_number_off = true;
+ comp_obj_para.metainfo.object_number_type = 0;
+ comp_obj_heading_.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;
+ comp_obj_heading_.metainfo.parent_lev_markup = 0;
+ the_document_blurb_section ~= comp_obj_heading_;
+}
+// blurb
+debug(blurb) { foreach (blurb; the_document_blurb_section) { writeln(blurb.text); } }
+indent = [
+ "hang_position" : 1,
+ "base_position" : 1,
+];
+comp_obj_toc = comp_obj_toc.init;
+comp_obj_toc.metainfo.is_of_part = "frontmatter";
+comp_obj_toc.metainfo.is_of_section = "toc";
+comp_obj_toc.metainfo.is_of_type = "para";
+comp_obj_toc.metainfo.is_a = "toc";
+comp_obj_toc.metainfo.ocn = 0;
+comp_obj_toc.metainfo.identifier = "";
+comp_obj_toc.metainfo.object_number_off = true;
+comp_obj_toc.metainfo.object_number_type = 0;
+comp_obj_toc.attrib.indent_hang = indent["hang_position"];
+comp_obj_toc.attrib.indent_base = indent["base_position"];
+comp_obj_toc.attrib.bullet = false;
+// use gathered
+if (the_document_endnotes_section.length > 1) {
+ toc_txt_ = format("%s%s%s%s#%s%s",
+ mkup.lnk_o,
+ "Endnotes",
+ mkup.lnk_c,
+ mkup.url_o,
+ "endnotes",
+ mkup.url_c,
+ );
+ toc_txt_= toc_txt_.links_and_images;
+ comp_obj_toc.text = toc_txt_.to!string.strip;
+ comp_obj_toc.has.inline_links = true;
+ the_document_toc_section ~= comp_obj_toc;
+}
+if (the_document_glossary_section.length > 1) {
+ toc_txt_ = format("%s%s%s%s#%s%s",
+ mkup.lnk_o,
+ "Glossary",
+ mkup.lnk_c,
+ mkup.url_o,
+ "glossary",
+ mkup.url_c,
+ );
+ toc_txt_= toc_txt_.links_and_images;
+ comp_obj_toc.text = toc_txt_.to!string.strip;
+ comp_obj_toc.has.inline_links = true;
+ the_document_toc_section ~= comp_obj_toc;
+}
+if (the_document_bibliography_section.length > 1){
+ toc_txt_ = format("%s%s%s%s#%s%s",
+ mkup.lnk_o,
+ "Bibliography",
+ mkup.lnk_c,
+ mkup.url_o,
+ "bibliography",
+ mkup.url_c,
+ );
+ toc_txt_= toc_txt_.links_and_images;
+ comp_obj_toc.text = toc_txt_.to!string.strip;
+ comp_obj_toc.has.inline_links = true;
+ the_document_toc_section ~= comp_obj_toc;
+}
+if (the_document_bookindex_section.length > 1) {
+ toc_txt_ = format("%s%s%s%s#%s%s",
+ mkup.lnk_o,
+ "Book Index",
+ mkup.lnk_c,
+ mkup.url_o,
+ "bookindex",
+ mkup.url_c,
+ );
+ toc_txt_= toc_txt_.links_and_images;
+ comp_obj_toc.text = toc_txt_.to!string.strip;
+ comp_obj_toc.has.inline_links = true;
+ the_document_toc_section ~= comp_obj_toc;
+}
+if (the_document_blurb_section.length > 1) {
+ toc_txt_ = format("%s%s%s%s#%s%s",
+ mkup.lnk_o,
+ "Blurb",
+ mkup.lnk_c,
+ mkup.url_o,
+ "blurb",
+ mkup.url_c,
+ );
+ toc_txt_= toc_txt_.links_and_images;
+ comp_obj_toc.has.inline_links = true;
+ comp_obj_toc.text = toc_txt_.to!string.strip;
+ the_document_toc_section ~= comp_obj_toc;
+}
+debug(toc) {
+ writefln( "%s %s", __LINE__,);
+ foreach (toc_linked_heading; the_document_toc_section) {
+ writeln(mkup.indent_by_spaces_provided(toc_linked_heading.attrib.indent_hang), toc_linked_heading.text);
+ }
+}
+// document head and body
+the_document_head_section ~= the_document_body_section[0];
+the_document_body_section = the_document_body_section[1..$];
+// document ancestors
+@safe int[] _get_ancestors_markup(O)(O obj, ref int[] _ancestors_markup) {
+ if (obj.metainfo.is_a == "heading") {
+ debug(dom) { writeln(obj.text); }
+ if (obj.metainfo.heading_lev_markup == 1) {
+ _ancestors_markup = [
+ _ancestors_markup[0],
+ 0,0,0,0,0,0,0
+ ];
+ }
+ if (obj.metainfo.heading_lev_markup == 2) {
+ _ancestors_markup = [
+ _ancestors_markup[0],
+ _ancestors_markup[1],
+ 0,0,0,0,0,0
+ ];
+ }
+ if (obj.metainfo.heading_lev_markup == 3) {
+ _ancestors_markup = [
+ _ancestors_markup[0],
+ _ancestors_markup[1],
+ _ancestors_markup[2],
+ 0,0,0,0,0
+ ];
+ }
+ if (obj.metainfo.heading_lev_markup == 4) {
+ _ancestors_markup = [
+ _ancestors_markup[0],
+ _ancestors_markup[1],
+ _ancestors_markup[2],
+ _ancestors_markup[3],
+ 0,0,0,0
+ ];
+ }
+ if (obj.metainfo.heading_lev_markup == 5) {
+ _ancestors_markup = [
+ _ancestors_markup[0],
+ _ancestors_markup[1],
+ _ancestors_markup[2],
+ _ancestors_markup[3],
+ _ancestors_markup[4],
+ 0,0,0
+ ];
+ }
+ if (obj.metainfo.heading_lev_markup == 6) {
+ _ancestors_markup = [
+ _ancestors_markup[0],
+ _ancestors_markup[1],
+ _ancestors_markup[2],
+ _ancestors_markup[3],
+ _ancestors_markup[4],
+ _ancestors_markup[5],
+ 0,0
+ ];
+ }
+ if (obj.metainfo.heading_lev_markup == 7) {
+ _ancestors_markup = [
+ _ancestors_markup[0],
+ _ancestors_markup[1],
+ _ancestors_markup[2],
+ _ancestors_markup[3],
+ _ancestors_markup[4],
+ _ancestors_markup[5],
+ _ancestors_markup[6],
+ 0
+ ];
+ }
+ if (obj.metainfo.heading_lev_markup == 8) {
+ _ancestors_markup = [
+ _ancestors_markup[0],
+ _ancestors_markup[1],
+ _ancestors_markup[2],
+ _ancestors_markup[3],
+ _ancestors_markup[4],
+ _ancestors_markup[5],
+ _ancestors_markup[6],
+ _ancestors_markup[7]
+ ];
}
+ _ancestors_markup[obj.metainfo.heading_lev_markup] = obj.metainfo.ocn;
}
- 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.identifier = "";
- comp_obj_heading_.metainfo.dummy_heading = false;
- comp_obj_heading_.metainfo.object_number_off = false;
- 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_.tags.anchor_tags = ["section_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;
- 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_document_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_lv1to4"] = comp_obj_heading_.tags.segment_anchor_tag_epub;
+ debug(ancestor_markup) { writeln("marked up: ", _ancestors_markup); }
+ return _ancestors_markup;
+}
+@safe int[] _get_ancestors_collapsed(O)(O obj, ref int[] _ancestors_collapsed) {
+ if (obj.metainfo.is_a == "heading") {
+ if (obj.metainfo.heading_lev_collapsed == 1) {
+ _ancestors_collapsed = [
+ _ancestors_collapsed[0],
+ 0,0,0,0,0,0,0
+ ];
}
- {
- 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.identifier = "";
- comp_obj_heading_.metainfo.dummy_heading = true;
- comp_obj_heading_.metainfo.object_number_off = true;
- comp_obj_heading_.metainfo.object_number_type = 0;
- comp_obj_heading_.tags.segment_anchor_tag_epub = "bibliography";
- 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_.metainfo.dom_structure_markedup_tags_status = [ 1, 1, 0, 0, 1, 0, 0, 0];
- comp_obj_heading_.metainfo.dom_structure_collapsed_tags_status = [ 1, 1, 1, 0, 0, 0, 0, 0];
- comp_obj_heading_.tags.anchor_tags = ["bibliography"];
- the_document_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_lv1to4"] = comp_obj_heading_.tags.segment_anchor_tag_epub;
+ if (obj.metainfo.heading_lev_collapsed == 2) {
+ _ancestors_collapsed = [
+ _ancestors_collapsed[0],
+ _ancestors_collapsed[1],
+ 0,0,0,0,0,0
+ ];
}
- {
- string out_;
- foreach (entry; biblio_ordered) {
- out_ = format("%s \"%s\"%s%s%s%s%s%s%s%s%s.",
- ((entry["author"].str.empty) ? entry["editor"].str : entry["author"].str),
- entry["fulltitle"].str,
- ((entry["journal"].str.empty) ? "" : ", " ~ mkup.ff_i ~ mkup.italic ~ mkup.ff_o ~ entry["journal"].str ~ mkup.ff_c ~ mkup.italic),
- ((entry["volume"].str.empty) ? "" : ", " ~ entry["volume"].str),
- ((entry["in"].str.empty) ? "" : ", " ~ entry["in"].str),
- ((!(entry["author"].str.empty) && (!(entry["editor"].str.empty))) ? entry["editor"].str : ""),
- ", " ~ entry["year"].str,
- ((entry["pages"].str.empty) ? "" : ", " ~ entry["pages"].str),
- ((entry["publisher"].str.empty) ? "" : ", " ~ entry["publisher"].str),
- ((entry["place"].str.empty) ? "" : ", " ~ entry["place"].str),
- ((entry["url"].str.empty) ? "" : ", [" ~ entry["url"].str ~ "]"),
- );
- comp_obj_para = comp_obj_para.init;
- comp_obj_para.metainfo.is_of_part = "backmatter";
- comp_obj_para.metainfo.is_of_section = "bibliography";
- comp_obj_para.metainfo.is_of_type = "para";
- comp_obj_para.metainfo.is_a = "bibliography";
- comp_obj_para.text = out_.to!string.strip;
- comp_obj_para.metainfo.ocn = 0;
- comp_obj_para.metainfo.identifier = "";
- comp_obj_para.metainfo.object_number_off = true;
- comp_obj_para.metainfo.object_number_type = 0;
- comp_obj_para.attrib.indent_hang = 0;
- comp_obj_para.attrib.indent_base = 1;
- comp_obj_para.attrib.bullet = bullet;
- comp_obj_para.tags.anchor_tags = [anchor_tag];
- the_document_bibliography_section ~= comp_obj_para;
- }
+ if (obj.metainfo.heading_lev_collapsed == 3) {
+ _ancestors_collapsed = [
+ _ancestors_collapsed[0],
+ _ancestors_collapsed[1],
+ _ancestors_collapsed[2],
+ 0,0,0,0,0
+ ];
}
- } 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.identifier = "";
- comp_obj_heading_.metainfo.dummy_heading = true;
- comp_obj_heading_.metainfo.object_number_off = true;
- comp_obj_heading_.metainfo.object_number_type = 0;
- comp_obj_heading_.metainfo.heading_lev_markup = 1;
- comp_obj_heading_.metainfo.heading_lev_collapsed = 1;
- comp_obj_heading_.metainfo.parent_ocn = 1;
- comp_obj_heading_.metainfo.parent_lev_markup = 0;
- the_document_bibliography_section ~= comp_obj_heading_;
- }
- debug(bibliosection) { foreach (o; the_document_bibliography_section) { writeln(o.text); } }
- auto bi = BookIndexReportSection();
- auto bi_tuple
- = bi.bookindex_build_abstraction_section(
- bookindex_unordered_hashes,
- obj_cite_digits,
- opt_action,
- );
- destroy(bookindex_unordered_hashes);
- auto the_document_bookindex_section = bi_tuple[0];
- obj_cite_digits = bi_tuple[1];
- debug(bookindex) { foreach (bi_entry; the_document_bookindex_section) { writeln(bi_entry); } }
- if (an_object["blurb_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 Blurb section";
- comp_obj_heading_.metainfo.ocn = 0;
- comp_obj_heading_.metainfo.identifier = "";
- comp_obj_para.metainfo.object_number_off = true;
- comp_obj_para.metainfo.object_number_type = 0;
- comp_obj_heading_.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;
- comp_obj_heading_.metainfo.parent_lev_markup = 0;
- the_document_blurb_section ~= comp_obj_heading_;
- }
- debug(blurb) { foreach (blurb; the_document_blurb_section) { writeln(blurb.text); } }
- indent = [
- "hang_position" : 1,
- "base_position" : 1,
- ];
- comp_obj_toc = comp_obj_toc.init;
- comp_obj_toc.metainfo.is_of_part = "frontmatter";
- comp_obj_toc.metainfo.is_of_section = "toc";
- comp_obj_toc.metainfo.is_of_type = "para";
- comp_obj_toc.metainfo.is_a = "toc";
- comp_obj_toc.metainfo.ocn = 0;
- comp_obj_toc.metainfo.identifier = "";
- comp_obj_toc.metainfo.object_number_off = true;
- comp_obj_toc.metainfo.object_number_type = 0;
- comp_obj_toc.attrib.indent_hang = indent["hang_position"];
- comp_obj_toc.attrib.indent_base = indent["base_position"];
- comp_obj_toc.attrib.bullet = false;
- if (the_document_endnotes_section.length > 1) {
- toc_txt_ = format("%s%s%s%s#%s%s",
- mkup.lnk_o,
- "Endnotes",
- mkup.lnk_c,
- mkup.url_o,
- "endnotes",
- mkup.url_c,
- );
- toc_txt_= toc_txt_.links_and_images;
- comp_obj_toc.text = toc_txt_.to!string.strip;
- comp_obj_toc.has.inline_links = true;
- the_document_toc_section ~= comp_obj_toc;
+ if (obj.metainfo.heading_lev_collapsed == 4) {
+ _ancestors_collapsed = [
+ _ancestors_collapsed[0],
+ _ancestors_collapsed[1],
+ _ancestors_collapsed[2],
+ _ancestors_collapsed[3],
+ 0,0,0,0
+ ];
+ }
+ if (obj.metainfo.heading_lev_collapsed == 5) {
+ _ancestors_collapsed = [
+ _ancestors_collapsed[0],
+ _ancestors_collapsed[1],
+ _ancestors_collapsed[2],
+ _ancestors_collapsed[3],
+ _ancestors_collapsed[4],
+ 0,0,0
+ ];
+ }
+ if (obj.metainfo.heading_lev_collapsed == 6) {
+ _ancestors_collapsed = [
+ _ancestors_collapsed[0],
+ _ancestors_collapsed[1],
+ _ancestors_collapsed[2],
+ _ancestors_collapsed[3],
+ _ancestors_collapsed[4],
+ _ancestors_collapsed[5],
+ 0,0
+ ];
+ }
+ if (obj.metainfo.heading_lev_collapsed == 7) {
+ _ancestors_collapsed = [
+ _ancestors_collapsed[0],
+ _ancestors_collapsed[1],
+ _ancestors_collapsed[2],
+ _ancestors_collapsed[3],
+ _ancestors_collapsed[4],
+ _ancestors_collapsed[5],
+ _ancestors_collapsed[6],
+ 0
+ ];
+ }
+ if (obj.metainfo.heading_lev_collapsed == 8) {
+ _ancestors_collapsed = [
+ _ancestors_collapsed[0],
+ _ancestors_collapsed[1],
+ _ancestors_collapsed[2],
+ _ancestors_collapsed[3],
+ _ancestors_collapsed[4],
+ _ancestors_collapsed[5],
+ _ancestors_collapsed[6],
+ _ancestors_collapsed[7]
+ ];
+ }
+ _ancestors_collapsed[obj.metainfo.heading_lev_collapsed] = obj.metainfo.ocn;
}
- if (the_document_glossary_section.length > 1) {
- toc_txt_ = format("%s%s%s%s#%s%s",
- mkup.lnk_o,
- "Glossary",
- mkup.lnk_c,
- mkup.url_o,
- "glossary",
- mkup.url_c,
- );
- toc_txt_= toc_txt_.links_and_images;
- comp_obj_toc.text = toc_txt_.to!string.strip;
- comp_obj_toc.has.inline_links = true;
- the_document_toc_section ~= comp_obj_toc;
- }
- if (the_document_bibliography_section.length > 1){
- toc_txt_ = format("%s%s%s%s#%s%s",
- mkup.lnk_o,
- "Bibliography",
- mkup.lnk_c,
- mkup.url_o,
- "bibliography",
- mkup.url_c,
- );
- toc_txt_= toc_txt_.links_and_images;
- comp_obj_toc.text = toc_txt_.to!string.strip;
- comp_obj_toc.has.inline_links = true;
- the_document_toc_section ~= comp_obj_toc;
+ debug(ancestor_collapsed) { writeln("collapsed: ", _ancestors_collapsed); }
+ return _ancestors_collapsed;
+}
+// multiple 1~ levels, loop through document body
+if (the_document_body_section.length > 1) {
+ int[] _ancestors_markup = [0,0,0,0,0,0,0,0];
+ int[][] _ancestors_markup_;
+ _ancestors_markup = [1,0,0,0,0,0,0,0];
+ _ancestors_markup_ ~= _ancestors_markup;
+ int[] _ancestors_collapsed = [0,0,0,0,0,0,0,0];
+ int[][] _ancestors_collapsed_;
+ _ancestors_collapsed = [1,0,0,0,0,0,0,0];
+ _ancestors_collapsed_ ~= _ancestors_collapsed;
+ foreach (ref obj; the_document_body_section) {
+ if (obj.metainfo.is_a == "heading") {
+ obj.metainfo.markedup_ancestors = _get_ancestors_markup(obj, _ancestors_markup);
+ obj.metainfo.collapsed_ancestors = _get_ancestors_collapsed(obj, _ancestors_collapsed);
+ obj.metainfo.parent_ocn = obj.metainfo.markedup_ancestors[obj.metainfo.parent_lev_markup];
+ }
}
- if (the_document_bookindex_section.length > 1) {
- toc_txt_ = format("%s%s%s%s#%s%s",
- mkup.lnk_o,
- "Book Index",
- mkup.lnk_c,
- mkup.url_o,
- "bookindex",
- mkup.url_c,
- );
- toc_txt_= toc_txt_.links_and_images;
- comp_obj_toc.text = toc_txt_.to!string.strip;
- comp_obj_toc.has.inline_links = true;
- the_document_toc_section ~= comp_obj_toc;
+ debug(ancestors) {
+ writeln("ancestors markup o_n: ", obj.metainfo.markedup_ancestors);
+ writeln("ancestors collapsed o_n: ", obj.metainfo.markedup_ancestors);
}
- if (the_document_blurb_section.length > 1) {
- toc_txt_ = format("%s%s%s%s#%s%s",
- mkup.lnk_o,
- "Blurb",
- mkup.lnk_c,
- mkup.url_o,
- "blurb",
- mkup.url_c,
- );
- toc_txt_= toc_txt_.links_and_images;
- comp_obj_toc.has.inline_links = true;
- comp_obj_toc.text = toc_txt_.to!string.strip;
- the_document_toc_section ~= comp_obj_toc;
+}
+// segnames
+if (the_document_endnotes_section.length > 1) {
+ segnames["html"] ~= "endnotes";
+ segnames["epub"] ~= "endnotes";
+ html_segnames_ptr = html_segnames_ptr_cntr;
+ foreach (ref obj; the_document_endnotes_section) {
+ if (obj.metainfo.is_a == "heading") {
+ obj.metainfo.parent_ocn = obj.metainfo.markedup_ancestors[obj.metainfo.parent_lev_markup];
+ }
+ if (obj.metainfo.heading_lev_markup == 4) {
+ obj.ptr.html_segnames = html_segnames_ptr;
+ break;
+ }
}
- debug(toc) {
- writefln( "%s %s", __LINE__,);
- foreach (toc_linked_heading; the_document_toc_section) {
- writeln(mkup.indent_by_spaces_provided(toc_linked_heading.attrib.indent_hang), toc_linked_heading.text);
+ html_segnames_ptr_cntr++;
+}
+if (the_document_glossary_section.length > 1) {
+ segnames["html"] ~= "glossary";
+ segnames["epub"] ~= "glossary";
+ html_segnames_ptr = html_segnames_ptr_cntr;
+ foreach (ref obj; the_document_glossary_section) {
+ if (obj.metainfo.is_a == "heading") {
+ obj.metainfo.parent_ocn = obj.metainfo.markedup_ancestors[obj.metainfo.parent_lev_markup];
+ }
+ if (obj.metainfo.heading_lev_markup == 4) {
+ obj.ptr.html_segnames = html_segnames_ptr;
+ break;
}
}
- the_document_head_section ~= the_document_body_section[0];
- the_document_body_section = the_document_body_section[1..$];
- @safe int[] _get_ancestors_markup(O)(O obj, ref int[] _ancestors_markup) {
+ html_segnames_ptr_cntr++;
+}
+if (the_document_bibliography_section.length > 1) {
+ segnames["html"] ~= "bibliography";
+ segnames["epub"] ~= "bibliography";
+ html_segnames_ptr = html_segnames_ptr_cntr;
+ foreach (ref obj; the_document_bibliography_section) {
if (obj.metainfo.is_a == "heading") {
- debug(dom) { writeln(obj.text); }
- if (obj.metainfo.heading_lev_markup == 1) {
- _ancestors_markup = [
- _ancestors_markup[0],
- 0,0,0,0,0,0,0
- ];
- }
- if (obj.metainfo.heading_lev_markup == 2) {
- _ancestors_markup = [
- _ancestors_markup[0],
- _ancestors_markup[1],
- 0,0,0,0,0,0
- ];
- }
- if (obj.metainfo.heading_lev_markup == 3) {
- _ancestors_markup = [
- _ancestors_markup[0],
- _ancestors_markup[1],
- _ancestors_markup[2],
- 0,0,0,0,0
- ];
- }
- if (obj.metainfo.heading_lev_markup == 4) {
- _ancestors_markup = [
- _ancestors_markup[0],
- _ancestors_markup[1],
- _ancestors_markup[2],
- _ancestors_markup[3],
- 0,0,0,0
- ];
- }
- if (obj.metainfo.heading_lev_markup == 5) {
- _ancestors_markup = [
- _ancestors_markup[0],
- _ancestors_markup[1],
- _ancestors_markup[2],
- _ancestors_markup[3],
- _ancestors_markup[4],
- 0,0,0
- ];
- }
- if (obj.metainfo.heading_lev_markup == 6) {
- _ancestors_markup = [
- _ancestors_markup[0],
- _ancestors_markup[1],
- _ancestors_markup[2],
- _ancestors_markup[3],
- _ancestors_markup[4],
- _ancestors_markup[5],
- 0,0
- ];
- }
- if (obj.metainfo.heading_lev_markup == 7) {
- _ancestors_markup = [
- _ancestors_markup[0],
- _ancestors_markup[1],
- _ancestors_markup[2],
- _ancestors_markup[3],
- _ancestors_markup[4],
- _ancestors_markup[5],
- _ancestors_markup[6],
- 0
- ];
- }
- if (obj.metainfo.heading_lev_markup == 8) {
- _ancestors_markup = [
- _ancestors_markup[0],
- _ancestors_markup[1],
- _ancestors_markup[2],
- _ancestors_markup[3],
- _ancestors_markup[4],
- _ancestors_markup[5],
- _ancestors_markup[6],
- _ancestors_markup[7]
- ];
- }
- _ancestors_markup[obj.metainfo.heading_lev_markup] = obj.metainfo.ocn;
+ obj.metainfo.parent_ocn = obj.metainfo.markedup_ancestors[obj.metainfo.parent_lev_markup];
+ }
+ if (obj.metainfo.heading_lev_markup == 4) {
+ obj.ptr.html_segnames = html_segnames_ptr;
+ break;
}
- debug(ancestor_markup) { writeln("marked up: ", _ancestors_markup); }
- return _ancestors_markup;
}
- @safe int[] _get_ancestors_collapsed(O)(O obj, ref int[] _ancestors_collapsed) {
+ html_segnames_ptr_cntr++;
+}
+if (the_document_bookindex_section.length > 1) {
+ segnames["html"] ~= "bookindex";
+ segnames["epub"] ~= "bookindex";
+ html_segnames_ptr = html_segnames_ptr_cntr;
+ foreach (ref obj; the_document_bookindex_section) {
if (obj.metainfo.is_a == "heading") {
- if (obj.metainfo.heading_lev_collapsed == 1) {
- _ancestors_collapsed = [
- _ancestors_collapsed[0],
- 0,0,0,0,0,0,0
- ];
- }
- if (obj.metainfo.heading_lev_collapsed == 2) {
- _ancestors_collapsed = [
- _ancestors_collapsed[0],
- _ancestors_collapsed[1],
- 0,0,0,0,0,0
- ];
- }
- if (obj.metainfo.heading_lev_collapsed == 3) {
- _ancestors_collapsed = [
- _ancestors_collapsed[0],
- _ancestors_collapsed[1],
- _ancestors_collapsed[2],
- 0,0,0,0,0
- ];
- }
- if (obj.metainfo.heading_lev_collapsed == 4) {
- _ancestors_collapsed = [
- _ancestors_collapsed[0],
- _ancestors_collapsed[1],
- _ancestors_collapsed[2],
- _ancestors_collapsed[3],
- 0,0,0,0
- ];
- }
- if (obj.metainfo.heading_lev_collapsed == 5) {
- _ancestors_collapsed = [
- _ancestors_collapsed[0],
- _ancestors_collapsed[1],
- _ancestors_collapsed[2],
- _ancestors_collapsed[3],
- _ancestors_collapsed[4],
- 0,0,0
- ];
- }
- if (obj.metainfo.heading_lev_collapsed == 6) {
- _ancestors_collapsed = [
- _ancestors_collapsed[0],
- _ancestors_collapsed[1],
- _ancestors_collapsed[2],
- _ancestors_collapsed[3],
- _ancestors_collapsed[4],
- _ancestors_collapsed[5],
- 0,0
- ];
- }
- if (obj.metainfo.heading_lev_collapsed == 7) {
- _ancestors_collapsed = [
- _ancestors_collapsed[0],
- _ancestors_collapsed[1],
- _ancestors_collapsed[2],
- _ancestors_collapsed[3],
- _ancestors_collapsed[4],
- _ancestors_collapsed[5],
- _ancestors_collapsed[6],
- 0
- ];
- }
- if (obj.metainfo.heading_lev_collapsed == 8) {
- _ancestors_collapsed = [
- _ancestors_collapsed[0],
- _ancestors_collapsed[1],
- _ancestors_collapsed[2],
- _ancestors_collapsed[3],
- _ancestors_collapsed[4],
- _ancestors_collapsed[5],
- _ancestors_collapsed[6],
- _ancestors_collapsed[7]
- ];
- }
- _ancestors_collapsed[obj.metainfo.heading_lev_collapsed] = obj.metainfo.ocn;
+ obj.metainfo.parent_ocn = obj.metainfo.markedup_ancestors[obj.metainfo.parent_lev_markup];
+ }
+ if (obj.metainfo.heading_lev_markup == 4) {
+ obj.ptr.html_segnames = html_segnames_ptr;
+ break;
}
- debug(ancestor_collapsed) { writeln("collapsed: ", _ancestors_collapsed); }
- return _ancestors_collapsed;
}
- // multiple 1~ levels, loop through document body
- if (the_document_body_section.length > 1) {
- int[] _ancestors_markup = [0,0,0,0,0,0,0,0];
- int[][] _ancestors_markup_;
- _ancestors_markup = [1,0,0,0,0,0,0,0];
- _ancestors_markup_ ~= _ancestors_markup;
- int[] _ancestors_collapsed = [0,0,0,0,0,0,0,0];
- int[][] _ancestors_collapsed_;
- _ancestors_collapsed = [1,0,0,0,0,0,0,0];
- _ancestors_collapsed_ ~= _ancestors_collapsed;
- foreach (ref obj; the_document_body_section) {
- if (obj.metainfo.is_a == "heading") {
- obj.metainfo.markedup_ancestors = _get_ancestors_markup(obj, _ancestors_markup);
- obj.metainfo.collapsed_ancestors = _get_ancestors_collapsed(obj, _ancestors_collapsed);
- obj.metainfo.parent_ocn = obj.metainfo.markedup_ancestors[obj.metainfo.parent_lev_markup];
- }
+ html_segnames_ptr_cntr++;
+}
+if (the_document_blurb_section.length > 1) {
+ segnames["html"] ~= "blurb";
+ segnames["epub"] ~= "blurb";
+ html_segnames_ptr = html_segnames_ptr_cntr;
+ foreach (ref obj; the_document_blurb_section) {
+ if (obj.metainfo.is_a == "heading") {
+ obj.metainfo.parent_ocn = obj.metainfo.markedup_ancestors[obj.metainfo.parent_lev_markup];
}
- debug(ancestors) {
- writeln("ancestors markup o_n: ", obj.metainfo.markedup_ancestors);
- writeln("ancestors collapsed o_n: ", obj.metainfo.markedup_ancestors);
+ if (obj.metainfo.heading_lev_markup == 4) {
+ obj.ptr.html_segnames = html_segnames_ptr;
+ break;
}
}
- if (the_document_endnotes_section.length > 1) {
- segnames["html"] ~= "endnotes";
- segnames["epub"] ~= "endnotes";
- html_segnames_ptr = html_segnames_ptr_cntr;
- foreach (ref obj; the_document_endnotes_section) {
- if (obj.metainfo.is_a == "heading") {
- obj.metainfo.parent_ocn = obj.metainfo.markedup_ancestors[obj.metainfo.parent_lev_markup];
- }
- if (obj.metainfo.heading_lev_markup == 4) {
- obj.ptr.html_segnames = html_segnames_ptr;
- break;
+ html_segnames_ptr_cntr++;
+}
+// decendants
+@safe auto get_decendants()(ObjGenericComposite[] document_sections) {
+ int[string] _heading_ocn_decendants;
+ string[] _ocn_open_key = ["","","","","","","",""];
+ auto _doc_sect_length = document_sections.length - 1;
+ int _last_ocn;
+ foreach (_lg, ref obj; document_sections) {
+ if (obj.metainfo.is_a == "heading") {
+ foreach (_dts_lv, dom_tag_status; obj.metainfo.dom_structure_markedup_tags_status) {
+ switch (dom_tag_status) with (DomTags) {
+ case none: break;
+ case open:
+ _ocn_open_key[_dts_lv] = (obj.metainfo.ocn).to!string;
+ _heading_ocn_decendants[_ocn_open_key[_dts_lv]] = obj.metainfo.ocn;
+ break;
+ case close:
+ if (_ocn_open_key[_dts_lv].empty) {
+ _ocn_open_key[_dts_lv] = "0";
+ }
+ _heading_ocn_decendants[_ocn_open_key[_dts_lv]] = obj.metainfo.ocn - 1;
+ _ocn_open_key[_dts_lv] = (0).to!string;
+ break;
+ case close_and_open:
+ if (_ocn_open_key[_dts_lv].empty) {
+ _ocn_open_key[_dts_lv] = "0";
+ }
+ _heading_ocn_decendants[_ocn_open_key[_dts_lv]] = obj.metainfo.ocn - 1;
+ _ocn_open_key[_dts_lv] = (obj.metainfo.ocn).to!string;
+ _heading_ocn_decendants[_ocn_open_key[_dts_lv]] = obj.metainfo.ocn;
+ break;
+ case open_still: break;
+ default: break;
+ }
}
}
- html_segnames_ptr_cntr++;
+ if (obj.metainfo.ocn > 0) {
+ _last_ocn = obj.metainfo.ocn;
+ }
+ if (_lg == _doc_sect_length) {
+ _heading_ocn_decendants["1"] = _last_ocn; // close existing o_n key
+ }
}
- if (the_document_glossary_section.length > 1) {
- segnames["html"] ~= "glossary";
- segnames["epub"] ~= "glossary";
- html_segnames_ptr = html_segnames_ptr_cntr;
- foreach (ref obj; the_document_glossary_section) {
- if (obj.metainfo.is_a == "heading") {
- obj.metainfo.parent_ocn = obj.metainfo.markedup_ancestors[obj.metainfo.parent_lev_markup];
- }
- if (obj.metainfo.heading_lev_markup == 4) {
- obj.ptr.html_segnames = html_segnames_ptr;
- break;
- }
+ Tuple!(int, int)[] pairs;
+ foreach (pair; _heading_ocn_decendants.byPair) {
+ pairs ~= tuple(pair[0].to!int, pair[1]);
+ }
+ return pairs.sort;
+}
+// images
+string[] _images;
+@safe string[] extract_images()(string content_block) {
+ string[] images_;
+ if (auto m = content_block.matchAll(rgx.image)) {
+ images_ ~= m.captures[1];
+ }
+ return images_;
+}
+string[] segnames_0_to_4;
+@system auto _image_dimensions(O,M)(O obj, M manifested) {
+ if (obj.has.image_without_dimensions) {
+ import std.math;
+ import imageformats;
+ int w, h, chans;
+ real _w, _h;
+ int max_width = 640;
+ foreach (img; obj.text.matchAll(rgx.inline_image_without_dimensions)) {
+ try {
+ read_image_info(manifested.src.image_dir_path ~ "/" ~ img["img"], w, h, chans);
+ } catch (Exception ex) {
+ writeln("WARNING, image not found: ", img["img"], "\n ", manifested.src.image_dir_path ~ "/" ~ img["img"]);
+ }
+ // calculate, decide max width and proportionally reduce to keep w & h within it
+ debug(images) { writeln("width: ", w, ", height: ", h); }
+ if (w > max_width) {
+ _w = max_width;
+ _h = round((max_width / w.to!real) * h.to!real);
+ } else {
+ _w = w;
+ _h = h;
+ }
+ obj.text = obj.text.replaceFirst(
+ rgx.inline_image_without_dimensions,
+ format(q"┃%s☼%s,w%sh%s %s┃",
+ "$1",
+ "$3",
+ _w.to!string,
+ _h.to!string,
+ "$6",
+ )
+ );
}
- html_segnames_ptr_cntr++;
+ debug(images) { writeln("image without dimensions: ", obj.text); }
}
- if (the_document_bibliography_section.length > 1) {
- segnames["html"] ~= "bibliography";
- segnames["epub"] ~= "bibliography";
- html_segnames_ptr = html_segnames_ptr_cntr;
- foreach (ref obj; the_document_bibliography_section) {
- if (obj.metainfo.is_a == "heading") {
- obj.metainfo.parent_ocn = obj.metainfo.markedup_ancestors[obj.metainfo.parent_lev_markup];
- }
- if (obj.metainfo.heading_lev_markup == 4) {
- obj.ptr.html_segnames = html_segnames_ptr;
- break;
+ return obj;
+}
+// links
+@safe auto _links(O)(O obj) {
+ if (auto m = obj.text.match(rgx.inline_link_stow_uri)) {
+ debug(links) {
+ writeln("number of link matches to stow: ", (obj.text.match(rgx.inline_link_stow_uri)).count);
+ writeln("links to stow: ", (obj.text.match(rgx.inline_link_stow_uri)));
+ }
+ int _n_matches = (obj.text.match(rgx.inline_link_stow_uri)).count.to!int;
+ for(int i = 0; i < _n_matches; ++i) {
+ if (obj.text.match(rgx.inline_link_stow_uri)) {
+ obj.stow.link ~= obj.text.matchFirst(rgx.inline_link_stow_uri)[2];
+ obj.text = obj.text.replaceFirst(
+ rgx.inline_link_stow_uri,
+ format(q"┃┥%s┝┤%s├┃", "$1", i)
+ );
}
}
- html_segnames_ptr_cntr++;
}
- if (the_document_bookindex_section.length > 1) {
- segnames["html"] ~= "bookindex";
- segnames["epub"] ~= "bookindex";
- html_segnames_ptr = html_segnames_ptr_cntr;
- foreach (ref obj; the_document_bookindex_section) {
- if (obj.metainfo.is_a == "heading") {
- obj.metainfo.parent_ocn = obj.metainfo.markedup_ancestors[obj.metainfo.parent_lev_markup];
+ return obj;
+}
+// document head
+foreach (ref obj; the_document_head_section) {
+ if (obj.metainfo.is_a == "heading") {
+ debug(dom) { writeln(obj.text); }
+ if (obj.metainfo.heading_lev_markup <= 4) {
+ segnames_0_to_4 ~= obj.tags.segment_anchor_tag_epub;
+ }
+ if (obj.metainfo.heading_lev_markup == 0) {
+ // TODO second hit (of two) with same assertion failure, check, fix and reinstate
+ // assert( obj.metainfo.ocn == 1,
+ // "Title OCN should be 1 not: " ~ obj.metainfo.ocn.to!string); // bug introduced 0.18.1
+ obj.metainfo.ocn = 1;
+ obj.metainfo.identifier = "1";
+ obj.metainfo.object_number_type = OCNtype.ocn;
+ }
+ // dom structure (marked up & collapsed)
+ if (opt_action.meta_processing_xml_dom) {
+ obj = obj.obj_dom_structure_set_markup_tags(dom_structure_markedup_tags_status, obj.metainfo.heading_lev_markup);
+ obj = obj.obj_dom_set_collapsed_tags(dom_structure_collapsed_tags_status, obj.metainfo.heading_lev_collapsed);
+ }
+ obj = obj.obj_heading_ancestors(lv_ancestors_txt);
+ }
+ obj = _links(obj);
+}
+if (the_document_toc_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_document_toc_section) {
+ if (obj.metainfo.is_a == "heading") {
+ if (obj.metainfo.heading_lev_markup <= 4) {
+ segnames_0_to_4 ~= obj.tags.segment_anchor_tag_epub;
+ if (obj.metainfo.heading_lev_markup == 4) {
+ obj.tags.segname_next = segnames["html"][obj.ptr.html_segnames + 1];
+ assert(obj.tags.anchor_tag_html == segnames["html"][obj.ptr.html_segnames],
+ obj.tags.anchor_tag_html ~ "!=" ~ segnames["html"][obj.ptr.html_segnames]);
+ }
}
- if (obj.metainfo.heading_lev_markup == 4) {
- obj.ptr.html_segnames = html_segnames_ptr;
- break;
+ // dom structure (marked up & collapsed)
+ if (opt_action.meta_processing_xml_dom) {
+ obj = obj.obj_dom_structure_set_markup_tags(dom_structure_markedup_tags_status, obj.metainfo.heading_lev_markup);
+ obj = obj.obj_dom_set_collapsed_tags(dom_structure_collapsed_tags_status, obj.metainfo.heading_lev_collapsed);
}
+ obj = obj.obj_heading_ancestors(lv_ancestors_txt);
}
- html_segnames_ptr_cntr++;
+ obj = _links(obj);
}
- if (the_document_blurb_section.length > 1) {
- segnames["html"] ~= "blurb";
- segnames["epub"] ~= "blurb";
- html_segnames_ptr = html_segnames_ptr_cntr;
- foreach (ref obj; the_document_blurb_section) {
- if (obj.metainfo.is_a == "heading") {
- obj.metainfo.parent_ocn = obj.metainfo.markedup_ancestors[obj.metainfo.parent_lev_markup];
+}
+// multiple 1~ levels, loop through document body
+if (the_document_body_section.length > 1) {
+ foreach (ref obj; the_document_body_section) {
+ if (!(obj.metainfo.identifier.empty)) {
+ if (!(((obj.metainfo.identifier) in tag_assoc)
+ && ("seg_lv4" in tag_assoc[(obj.metainfo.identifier)]))
+ ) {
+ tag_assoc[(obj.metainfo.identifier)]["seg_lv4"]
+ = obj.tags.html_segment_anchor_tag_is;
+ }
+ tag_assoc[(obj.metainfo.identifier)]["seg_lv1to4"]
+ = obj.tags.epub_segment_anchor_tag_is;
+ }
+ if (obj.metainfo.is_a == "heading") {
+ debug(dom) { writeln(obj.text); }
+ if (obj.metainfo.heading_lev_markup <= 4) {
+ segnames_0_to_4 ~= obj.tags.segment_anchor_tag_epub;
+ if (obj.metainfo.heading_lev_markup == 4) {
+ obj.tags.lev4_subtoc = lev4_subtoc[obj.tags.anchor_tag_html];
+ obj.tags.segname_prev = segnames["html"][obj.ptr.html_segnames - 1];
+ if (segnames["html"].length > obj.ptr.html_segnames + 1) {
+ 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]);
+ }
}
- if (obj.metainfo.heading_lev_markup == 4) {
- obj.ptr.html_segnames = html_segnames_ptr;
- break;
+ // dom structure (marked up & collapsed)
+ if (opt_action.meta_processing_xml_dom) {
+ obj = obj.obj_dom_structure_set_markup_tags(dom_structure_markedup_tags_status, obj.metainfo.heading_lev_markup);
+ obj = obj.obj_dom_set_collapsed_tags(dom_structure_collapsed_tags_status, obj.metainfo.heading_lev_collapsed);
}
+ obj = obj.obj_heading_ancestors(lv_ancestors_txt);
+ } else if (obj.metainfo.is_a == "para") {
+ _images ~= extract_images(obj.text);
+ obj = _image_dimensions(obj, manifested);
}
- html_segnames_ptr_cntr++;
+ obj = _links(obj);
}
- @safe auto get_decendants()(ObjGenericComposite[] document_sections) {
- int[string] _heading_ocn_decendants;
- string[] _ocn_open_key = ["","","","","","","",""];
- auto _doc_sect_length = document_sections.length - 1;
- int _last_ocn;
- foreach (_lg, ref obj; document_sections) {
- if (obj.metainfo.is_a == "heading") {
- foreach (_dts_lv, dom_tag_status; obj.metainfo.dom_structure_markedup_tags_status) {
- switch (dom_tag_status) with (DomTags) {
- case none: break;
- case open:
- _ocn_open_key[_dts_lv] = (obj.metainfo.ocn).to!string;
- _heading_ocn_decendants[_ocn_open_key[_dts_lv]] = obj.metainfo.ocn;
- break;
- case close:
- if (_ocn_open_key[_dts_lv].empty) {
- _ocn_open_key[_dts_lv] = "0";
- }
- _heading_ocn_decendants[_ocn_open_key[_dts_lv]] = obj.metainfo.ocn - 1;
- _ocn_open_key[_dts_lv] = (0).to!string;
- break;
- case close_and_open:
- if (_ocn_open_key[_dts_lv].empty) {
- _ocn_open_key[_dts_lv] = "0";
- }
- _heading_ocn_decendants[_ocn_open_key[_dts_lv]] = obj.metainfo.ocn - 1;
- _ocn_open_key[_dts_lv] = (obj.metainfo.ocn).to!string;
- _heading_ocn_decendants[_ocn_open_key[_dts_lv]] = obj.metainfo.ocn;
- break;
- case open_still: break;
- default: break;
+}
+auto image_list = (_images.sort()).uniq;
+// endnotes optional only one 1~ level
+if (the_document_endnotes_section.length > 1) {
+ dom_structure_markedup_tags_status_buffer = dom_structure_markedup_tags_status.dup;
+ dom_structure_collapsed_tags_status_buffer = dom_structure_collapsed_tags_status.dup;
+ dom_structure_markedup_tags_status = dom_structure_markedup_tags_status_buffer.dup;
+ dom_structure_collapsed_tags_status = dom_structure_collapsed_tags_status_buffer.dup;
+ foreach (ref obj; the_document_endnotes_section) {
+ if (obj.metainfo.is_a == "heading") {
+ debug(dom) { writeln(obj.text); }
+ if (obj.metainfo.heading_lev_markup == 1) {
+ obj_cite_digits = ocn_emit(eN.ocn.on);
+ obj.metainfo.ocn = obj_cite_digits.object_number;
+ obj.metainfo.identifier = obj_cite_digits.identifier;
+ }
+ if (obj.metainfo.heading_lev_markup <= 4) {
+ segnames_0_to_4 ~= obj.tags.segment_anchor_tag_epub;
+ if (obj.metainfo.heading_lev_markup == 4) {
+ obj.tags.segname_prev = segnames["html"][obj.ptr.html_segnames - 1];
+ if (segnames["html"].length > obj.ptr.html_segnames + 1) {
+ 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]);
}
}
- if (obj.metainfo.ocn > 0) {
- _last_ocn = obj.metainfo.ocn;
- }
- if (_lg == _doc_sect_length) {
- _heading_ocn_decendants["1"] = _last_ocn; // close existing o_n key
+ // dom structure (marked up & collapsed)
+ if (opt_action.meta_processing_xml_dom) {
+ obj = obj.obj_dom_structure_set_markup_tags(dom_structure_markedup_tags_status, obj.metainfo.heading_lev_markup);
+ obj = obj.obj_dom_set_collapsed_tags(dom_structure_collapsed_tags_status, obj.metainfo.heading_lev_collapsed);
}
+ obj = obj.obj_heading_ancestors(lv_ancestors_txt);
}
- Tuple!(int, int)[] pairs;
- foreach (pair; _heading_ocn_decendants.byPair) {
- pairs ~= tuple(pair[0].to!int, pair[1]);
- }
- return pairs.sort;
- }
- string[] _images;
- @safe string[] extract_images()(string content_block) {
- string[] images_;
- if (auto m = content_block.matchAll(rgx.image)) {
- images_ ~= m.captures[1];
- }
- return images_;
- }
- string[] segnames_0_to_4;
- @system auto _image_dimensions(O,M)(O obj, M manifested) {
- if (obj.has.image_without_dimensions) {
- import std.math;
- import imageformats;
- int w, h, chans;
- real _w, _h;
- int max_width = 640;
- foreach (img; obj.text.matchAll(rgx.inline_image_without_dimensions)) {
- try {
- read_image_info(manifested.src.image_dir_path ~ "/" ~ img["img"], w, h, chans);
- } catch (Exception ex) {
- writeln("WARNING, image not found: ", img["img"], "\n ", manifested.src.image_dir_path ~ "/" ~ img["img"]);
- }
- // calculate, decide max width and proportionally reduce to keep w & h within it
- debug(images) { writeln("width: ", w, ", height: ", h); }
- if (w > max_width) {
- _w = max_width;
- _h = round((max_width / w.to!real) * h.to!real);
- } else {
- _w = w;
- _h = h;
+ obj = _links(obj);
+ }
+}
+// glossary optional only one 1~ level
+if (the_document_glossary_section.length > 1) {
+ foreach (ref obj; the_document_glossary_section) {
+ if (obj.metainfo.is_a == "heading") {
+ debug(dom) { writeln(obj.text); }
+ if (obj.metainfo.heading_lev_markup == 1) {
+ obj_cite_digits = ocn_emit(eN.ocn.on);
+ obj.metainfo.ocn = obj_cite_digits.object_number;
+ obj.metainfo.identifier = obj_cite_digits.identifier;
+ }
+ if (obj.metainfo.heading_lev_markup <= 4) {
+ segnames_0_to_4 ~= obj.tags.segment_anchor_tag_epub;
+ if (obj.metainfo.heading_lev_markup == 4) {
+ obj.tags.segname_prev = segnames["html"][obj.ptr.html_segnames - 1];
+ if (segnames["html"].length > obj.ptr.html_segnames + 1) {
+ 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]);
}
- obj.text = obj.text.replaceFirst(
- rgx.inline_image_without_dimensions,
- format(q"┃%s☼%s,w%sh%s %s┃",
- "$1",
- "$3",
- _w.to!string,
- _h.to!string,
- "$6",
- )
- );
}
- debug(images) { writeln("image without dimensions: ", obj.text); }
+ // dom structure (marked up & collapsed)
+ if (opt_action.meta_processing_xml_dom) {
+ obj = obj.obj_dom_structure_set_markup_tags(dom_structure_markedup_tags_status, obj.metainfo.heading_lev_markup);
+ obj = obj.obj_dom_set_collapsed_tags(dom_structure_collapsed_tags_status, obj.metainfo.heading_lev_collapsed);
+ }
+ obj = obj.obj_heading_ancestors(lv_ancestors_txt);
+ } else if (obj.metainfo.is_a == "glossary" && !(obj.text.empty)) {
+ obj_cite_digits = ocn_emit(eN.ocn.on);
+ obj.metainfo.ocn = obj_cite_digits.object_number;
+ obj.metainfo.identifier = obj_cite_digits.identifier;
}
- return obj;
+ obj = _links(obj);
}
- @safe auto _links(O)(O obj) {
- if (auto m = obj.text.match(rgx.inline_link_stow_uri)) {
- debug(links) {
- writeln("number of link matches to stow: ", (obj.text.match(rgx.inline_link_stow_uri)).count);
- writeln("links to stow: ", (obj.text.match(rgx.inline_link_stow_uri)));
+}
+// bibliography optional only one 1~ level
+if (the_document_bibliography_section.length > 1) {
+ foreach (ref obj; the_document_bibliography_section) {
+ if (obj.metainfo.is_a == "heading") {
+ debug(dom) { writeln(obj.text); }
+ if (obj.metainfo.heading_lev_markup == 1) {
+ obj_cite_digits = ocn_emit(eN.ocn.on);
+ obj.metainfo.ocn = obj_cite_digits.object_number;
+ obj.metainfo.identifier = obj_cite_digits.identifier;
}
- int _n_matches = (obj.text.match(rgx.inline_link_stow_uri)).count.to!int;
- for(int i = 0; i < _n_matches; ++i) {
- if (obj.text.match(rgx.inline_link_stow_uri)) {
- obj.stow.link ~= obj.text.matchFirst(rgx.inline_link_stow_uri)[2];
- obj.text = obj.text.replaceFirst(
- rgx.inline_link_stow_uri,
- format(q"┃┥%s┝┤%s├┃", "$1", i)
- );
+ if (obj.metainfo.heading_lev_markup <= 4) {
+ segnames_0_to_4 ~= obj.tags.segment_anchor_tag_epub;
+ if (obj.metainfo.heading_lev_markup == 4) {
+ obj.tags.segname_prev = segnames["html"][obj.ptr.html_segnames - 1];
+ if (segnames["html"].length > obj.ptr.html_segnames + 1) {
+ 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)
+ if (opt_action.meta_processing_xml_dom) {
+ obj = obj.obj_dom_structure_set_markup_tags(dom_structure_markedup_tags_status, obj.metainfo.heading_lev_markup);
+ obj = obj.obj_dom_set_collapsed_tags(dom_structure_collapsed_tags_status, obj.metainfo.heading_lev_collapsed);
+ }
+ obj = obj.obj_heading_ancestors(lv_ancestors_txt);
+ } else if (obj.metainfo.is_a == "bibliography") {
+ obj_cite_digits = ocn_emit(eN.ocn.on);
+ obj.metainfo.ocn = obj_cite_digits.object_number;
+ obj.metainfo.identifier = obj_cite_digits.identifier;
}
- return obj;
+ obj = _links(obj);
}
- foreach (ref obj; the_document_head_section) {
+}
+// book index, optional only one 1~ level
+int ocn_ = obj_cite_digits.object_number;
+int ocn_bkidx_ = 0;
+int ocn_bidx_;
+if (the_document_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_document_bookindex_section) {
if (obj.metainfo.is_a == "heading") {
- debug(dom) { writeln(obj.text); }
+ // debug(dom) { }
if (obj.metainfo.heading_lev_markup <= 4) {
segnames_0_to_4 ~= obj.tags.segment_anchor_tag_epub;
}
- if (obj.metainfo.heading_lev_markup == 0) {
- // TODO second hit (of two) with same assertion failure, check, fix and reinstate
- // assert( obj.metainfo.ocn == 1,
- // "Title OCN should be 1 not: " ~ obj.metainfo.ocn.to!string); // bug introduced 0.18.1
- obj.metainfo.ocn = 1;
- obj.metainfo.identifier = "1";
- obj.metainfo.object_number_type = OCNtype.ocn;
+ if (obj.metainfo.heading_lev_markup == 1) {
+ obj_cite_digits = ocn_emit(eN.ocn.on);
+ obj.metainfo.ocn = obj_cite_digits.object_number;
+ obj.metainfo.identifier = obj_cite_digits.identifier;
+ }
+ if (obj.metainfo.heading_lev_markup <= 4) {
+ if (obj.metainfo.heading_lev_markup == 4) {
+ obj.tags.segname_prev = segnames["html"][obj.ptr.html_segnames - 1];
+ if (segnames["html"].length > obj.ptr.html_segnames + 1) {
+ 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)
if (opt_action.meta_processing_xml_dom) {
@@ -2232,278 +2486,148 @@ struct ST_flow_table_substantive_munge {
obj = obj.obj_dom_set_collapsed_tags(dom_structure_collapsed_tags_status, obj.metainfo.heading_lev_collapsed);
}
obj = obj.obj_heading_ancestors(lv_ancestors_txt);
+ } else if (obj.metainfo.is_a == "bookindex") {
+ obj_cite_digits = ocn_emit(eN.ocn.bkidx);
+ obj.metainfo.ocn = obj_cite_digits.object_number;
+ obj.metainfo.identifier = obj_cite_digits.identifier;
+ obj.metainfo.o_n_book_index = obj_cite_digits.bkidx;
+ obj.metainfo.object_number_type = OCNtype.bkidx;
}
obj = _links(obj);
}
- if (the_document_toc_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_document_toc_section) {
- if (obj.metainfo.is_a == "heading") {
- if (obj.metainfo.heading_lev_markup <= 4) {
- segnames_0_to_4 ~= obj.tags.segment_anchor_tag_epub;
- if (obj.metainfo.heading_lev_markup == 4) {
+ // TODO assert failure, reinstate
+ // assert(obj_cite_digit_bkidx == ocn_bidx_ obj_cite_digit_bkidx ~ " == ocn_" ~ ocn_ ~ "?");
+}
+// blurb optional only one 1~ level
+if (the_document_blurb_section.length > 1) {
+ foreach (ref obj; the_document_blurb_section) {
+ if (obj.metainfo.is_a == "heading") {
+ debug(dom) { writeln(obj.text); }
+ if (obj.metainfo.heading_lev_markup == 1) {
+ obj_cite_digits = ocn_emit(eN.ocn.on);
+ obj.metainfo.ocn = obj_cite_digits.object_number;
+ obj.metainfo.identifier = obj_cite_digits.identifier;
+ }
+ if (obj.metainfo.heading_lev_markup <= 4) {
+ segnames_0_to_4 ~= obj.tags.segment_anchor_tag_epub;
+ if (obj.metainfo.heading_lev_markup == 4) {
+ obj.tags.segname_prev = segnames["html"][obj.ptr.html_segnames - 1];
+ if (segnames["html"].length > obj.ptr.html_segnames + 1) {
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]);
}
+ 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)
- if (opt_action.meta_processing_xml_dom) {
- obj = obj.obj_dom_structure_set_markup_tags(dom_structure_markedup_tags_status, obj.metainfo.heading_lev_markup);
- obj = obj.obj_dom_set_collapsed_tags(dom_structure_collapsed_tags_status, obj.metainfo.heading_lev_collapsed);
+ }
+ // dom structure (marked up & collapsed)
+ if (opt_action.meta_processing_xml_dom) {
+ obj = obj.obj_dom_structure_set_markup_tags(dom_structure_markedup_tags_status, obj.metainfo.heading_lev_markup);
+ obj = obj.obj_dom_set_collapsed_tags(dom_structure_collapsed_tags_status, obj.metainfo.heading_lev_collapsed);
+ }
+ obj = obj.obj_heading_ancestors(lv_ancestors_txt);
+ } else if (obj.metainfo.is_a == "blurb") {
+ obj_cite_digits = ocn_emit(eN.ocn.off);
+ obj.metainfo.object_number_off = obj_cite_digits.off;
+ obj.metainfo.object_number_type = OCNtype.non;
+ }
+ obj = _links(obj);
+ }
+}
+// get decendants
+if (the_document_body_section.length > 1) {
+ auto pairs = get_decendants(
+ the_document_head_section ~
+ the_document_body_section ~
+ the_document_endnotes_section ~
+ the_document_glossary_section ~
+ the_document_bibliography_section ~
+ the_document_bookindex_section ~
+ the_document_blurb_section ~
+ the_document_xml_dom_tail_section
+ );
+ debug(decendants_tuple) {
+ pairs = pairs.sort();
+ foreach (pair; pairs) { // (pair; pairs.sort())
+ writeln(pair[0], "..", pair[1]);
+ }
+ }
+ foreach (ref obj; the_document_head_section) {
+ if (obj.metainfo.is_a == "heading") {
+ foreach (pair; pairs) {
+ if (obj.metainfo.ocn == pair[0]) {
+ obj.metainfo.last_decendant_ocn = pair[1];
}
- obj = obj.obj_heading_ancestors(lv_ancestors_txt);
}
- obj = _links(obj);
}
}
- // multiple 1~ levels, loop through document body
if (the_document_body_section.length > 1) {
foreach (ref obj; the_document_body_section) {
- if (!(obj.metainfo.identifier.empty)) {
- if (!(((obj.metainfo.identifier) in tag_assoc)
- && ("seg_lv4" in tag_assoc[(obj.metainfo.identifier)]))
- ) {
- tag_assoc[(obj.metainfo.identifier)]["seg_lv4"]
- = obj.tags.html_segment_anchor_tag_is;
- }
- tag_assoc[(obj.metainfo.identifier)]["seg_lv1to4"]
- = obj.tags.epub_segment_anchor_tag_is;
- }
if (obj.metainfo.is_a == "heading") {
- debug(dom) { writeln(obj.text); }
- if (obj.metainfo.heading_lev_markup <= 4) {
- segnames_0_to_4 ~= obj.tags.segment_anchor_tag_epub;
- if (obj.metainfo.heading_lev_markup == 4) {
- obj.tags.lev4_subtoc = lev4_subtoc[obj.tags.anchor_tag_html];
- obj.tags.segname_prev = segnames["html"][obj.ptr.html_segnames - 1];
- if (segnames["html"].length > obj.ptr.html_segnames + 1) {
- 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]);
+ foreach (pair; pairs) {
+ if (obj.metainfo.ocn == pair[0]) {
+ obj.metainfo.last_decendant_ocn = pair[1];
}
}
- // dom structure (marked up & collapsed)
- if (opt_action.meta_processing_xml_dom) {
- obj = obj.obj_dom_structure_set_markup_tags(dom_structure_markedup_tags_status, obj.metainfo.heading_lev_markup);
- obj = obj.obj_dom_set_collapsed_tags(dom_structure_collapsed_tags_status, obj.metainfo.heading_lev_collapsed);
- }
- obj = obj.obj_heading_ancestors(lv_ancestors_txt);
- } else if (obj.metainfo.is_a == "para") {
- _images ~= extract_images(obj.text);
- obj = _image_dimensions(obj, manifested);
}
- obj = _links(obj);
}
}
- auto image_list = (_images.sort()).uniq;
- // optional only one 1~ level
if (the_document_endnotes_section.length > 1) {
- dom_structure_markedup_tags_status_buffer = dom_structure_markedup_tags_status.dup;
- dom_structure_collapsed_tags_status_buffer = dom_structure_collapsed_tags_status.dup;
- dom_structure_markedup_tags_status = dom_structure_markedup_tags_status_buffer.dup;
- dom_structure_collapsed_tags_status = dom_structure_collapsed_tags_status_buffer.dup;
foreach (ref obj; the_document_endnotes_section) {
if (obj.metainfo.is_a == "heading") {
- debug(dom) { writeln(obj.text); }
- if (obj.metainfo.heading_lev_markup == 1) {
- obj_cite_digits = ocn_emit(eN.ocn.on);
- obj.metainfo.ocn = obj_cite_digits.object_number;
- obj.metainfo.identifier = obj_cite_digits.identifier;
- }
- if (obj.metainfo.heading_lev_markup <= 4) {
- segnames_0_to_4 ~= obj.tags.segment_anchor_tag_epub;
- if (obj.metainfo.heading_lev_markup == 4) {
- obj.tags.segname_prev = segnames["html"][obj.ptr.html_segnames - 1];
- if (segnames["html"].length > obj.ptr.html_segnames + 1) {
- 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]);
+ foreach (pair; pairs) {
+ if (obj.metainfo.ocn == pair[0]) {
+ obj.metainfo.last_decendant_ocn = pair[1];
}
}
- // dom structure (marked up & collapsed)
- if (opt_action.meta_processing_xml_dom) {
- obj = obj.obj_dom_structure_set_markup_tags(dom_structure_markedup_tags_status, obj.metainfo.heading_lev_markup);
- obj = obj.obj_dom_set_collapsed_tags(dom_structure_collapsed_tags_status, obj.metainfo.heading_lev_collapsed);
- }
- obj = obj.obj_heading_ancestors(lv_ancestors_txt);
}
- obj = _links(obj);
}
}
- // optional only one 1~ level
if (the_document_glossary_section.length > 1) {
foreach (ref obj; the_document_glossary_section) {
if (obj.metainfo.is_a == "heading") {
- debug(dom) { writeln(obj.text); }
- if (obj.metainfo.heading_lev_markup == 1) {
- obj_cite_digits = ocn_emit(eN.ocn.on);
- obj.metainfo.ocn = obj_cite_digits.object_number;
- obj.metainfo.identifier = obj_cite_digits.identifier;
- }
- if (obj.metainfo.heading_lev_markup <= 4) {
- segnames_0_to_4 ~= obj.tags.segment_anchor_tag_epub;
- if (obj.metainfo.heading_lev_markup == 4) {
- obj.tags.segname_prev = segnames["html"][obj.ptr.html_segnames - 1];
- if (segnames["html"].length > obj.ptr.html_segnames + 1) {
- 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]);
+ foreach (pair; pairs) {
+ if (obj.metainfo.ocn == pair[0]) {
+ obj.metainfo.last_decendant_ocn = pair[1];
}
}
- // dom structure (marked up & collapsed)
- if (opt_action.meta_processing_xml_dom) {
- obj = obj.obj_dom_structure_set_markup_tags(dom_structure_markedup_tags_status, obj.metainfo.heading_lev_markup);
- obj = obj.obj_dom_set_collapsed_tags(dom_structure_collapsed_tags_status, obj.metainfo.heading_lev_collapsed);
- }
- obj = obj.obj_heading_ancestors(lv_ancestors_txt);
- } else if (obj.metainfo.is_a == "glossary" && !(obj.text.empty)) {
- obj_cite_digits = ocn_emit(eN.ocn.on);
- obj.metainfo.ocn = obj_cite_digits.object_number;
- obj.metainfo.identifier = obj_cite_digits.identifier;
}
- obj = _links(obj);
}
}
- // optional only one 1~ level
if (the_document_bibliography_section.length > 1) {
foreach (ref obj; the_document_bibliography_section) {
if (obj.metainfo.is_a == "heading") {
- debug(dom) { writeln(obj.text); }
- if (obj.metainfo.heading_lev_markup == 1) {
- obj_cite_digits = ocn_emit(eN.ocn.on);
- obj.metainfo.ocn = obj_cite_digits.object_number;
- obj.metainfo.identifier = obj_cite_digits.identifier;
- }
- if (obj.metainfo.heading_lev_markup <= 4) {
- segnames_0_to_4 ~= obj.tags.segment_anchor_tag_epub;
- if (obj.metainfo.heading_lev_markup == 4) {
- obj.tags.segname_prev = segnames["html"][obj.ptr.html_segnames - 1];
- if (segnames["html"].length > obj.ptr.html_segnames + 1) {
- 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]);
+ foreach (pair; pairs) {
+ if (obj.metainfo.ocn == pair[0]) {
+ obj.metainfo.last_decendant_ocn = pair[1];
}
}
- // dom structure (marked up & collapsed)
- if (opt_action.meta_processing_xml_dom) {
- obj = obj.obj_dom_structure_set_markup_tags(dom_structure_markedup_tags_status, obj.metainfo.heading_lev_markup);
- obj = obj.obj_dom_set_collapsed_tags(dom_structure_collapsed_tags_status, obj.metainfo.heading_lev_collapsed);
- }
- obj = obj.obj_heading_ancestors(lv_ancestors_txt);
- } else if (obj.metainfo.is_a == "bibliography") {
- obj_cite_digits = ocn_emit(eN.ocn.on);
- obj.metainfo.ocn = obj_cite_digits.object_number;
- obj.metainfo.identifier = obj_cite_digits.identifier;
}
- obj = _links(obj);
}
}
- // optional only one 1~ level
- int ocn_ = obj_cite_digits.object_number;
- int ocn_bkidx_ = 0;
- int ocn_bidx_;
- if (the_document_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;
+ if (the_document_bookindex_section.length > 1) {
foreach (ref obj; the_document_bookindex_section) {
if (obj.metainfo.is_a == "heading") {
- // debug(dom) { }
- if (obj.metainfo.heading_lev_markup <= 4) {
- segnames_0_to_4 ~= obj.tags.segment_anchor_tag_epub;
- }
- if (obj.metainfo.heading_lev_markup == 1) {
- obj_cite_digits = ocn_emit(eN.ocn.on);
- obj.metainfo.ocn = obj_cite_digits.object_number;
- obj.metainfo.identifier = obj_cite_digits.identifier;
- }
- if (obj.metainfo.heading_lev_markup <= 4) {
- if (obj.metainfo.heading_lev_markup == 4) {
- obj.tags.segname_prev = segnames["html"][obj.ptr.html_segnames - 1];
- if (segnames["html"].length > obj.ptr.html_segnames + 1) {
- 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]);
+ foreach (pair; pairs) {
+ if (obj.metainfo.ocn == pair[0]) {
+ obj.metainfo.last_decendant_ocn = pair[1];
}
}
- // dom structure (marked up & collapsed)
- if (opt_action.meta_processing_xml_dom) {
- obj = obj.obj_dom_structure_set_markup_tags(dom_structure_markedup_tags_status, obj.metainfo.heading_lev_markup);
- obj = obj.obj_dom_set_collapsed_tags(dom_structure_collapsed_tags_status, obj.metainfo.heading_lev_collapsed);
- }
- obj = obj.obj_heading_ancestors(lv_ancestors_txt);
- } else if (obj.metainfo.is_a == "bookindex") {
- obj_cite_digits = ocn_emit(eN.ocn.bkidx);
- obj.metainfo.ocn = obj_cite_digits.object_number;
- obj.metainfo.identifier = obj_cite_digits.identifier;
- obj.metainfo.o_n_book_index = obj_cite_digits.bkidx;
- obj.metainfo.object_number_type = OCNtype.bkidx;
}
- obj = _links(obj);
}
- // TODO assert failure, reinstate
- // assert(obj_cite_digit_bkidx == ocn_bidx_ obj_cite_digit_bkidx ~ " == ocn_" ~ ocn_ ~ "?");
}
- // optional only one 1~ level
if (the_document_blurb_section.length > 1) {
foreach (ref obj; the_document_blurb_section) {
if (obj.metainfo.is_a == "heading") {
- debug(dom) { writeln(obj.text); }
- if (obj.metainfo.heading_lev_markup == 1) {
- obj_cite_digits = ocn_emit(eN.ocn.on);
- obj.metainfo.ocn = obj_cite_digits.object_number;
- obj.metainfo.identifier = obj_cite_digits.identifier;
- }
- if (obj.metainfo.heading_lev_markup <= 4) {
- segnames_0_to_4 ~= obj.tags.segment_anchor_tag_epub;
- if (obj.metainfo.heading_lev_markup == 4) {
- obj.tags.segname_prev = segnames["html"][obj.ptr.html_segnames - 1];
- if (segnames["html"].length > obj.ptr.html_segnames + 1) {
- 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]);
+ foreach (pair; pairs) {
+ if (obj.metainfo.ocn == pair[0]) {
+ obj.metainfo.last_decendant_ocn = pair[1];
}
}
- // dom structure (marked up & collapsed)
- if (opt_action.meta_processing_xml_dom) {
- obj = obj.obj_dom_structure_set_markup_tags(dom_structure_markedup_tags_status, obj.metainfo.heading_lev_markup);
- obj = obj.obj_dom_set_collapsed_tags(dom_structure_collapsed_tags_status, obj.metainfo.heading_lev_collapsed);
- }
- obj = obj.obj_heading_ancestors(lv_ancestors_txt);
- } else if (obj.metainfo.is_a == "blurb") {
- obj_cite_digits = ocn_emit(eN.ocn.off);
- obj.metainfo.object_number_off = obj_cite_digits.off;
- obj.metainfo.object_number_type = OCNtype.non;
}
- obj = _links(obj);
}
}
- if (the_document_body_section.length > 1) {
- auto pairs = get_decendants(
- the_document_head_section ~
- the_document_body_section ~
- the_document_endnotes_section ~
- the_document_glossary_section ~
- the_document_bibliography_section ~
- the_document_bookindex_section ~
- the_document_blurb_section ~
- the_document_xml_dom_tail_section
- );
- debug(decendants_tuple) {
- pairs = pairs.sort();
- foreach (pair; pairs) { // (pair; pairs.sort())
- writeln(pair[0], "..", pair[1]);
- }
- }
- foreach (ref obj; the_document_head_section) {
+ if (the_document_xml_dom_tail_section.length > 1) {
+ foreach (ref obj; the_document_xml_dom_tail_section) {
if (obj.metainfo.is_a == "heading") {
foreach (pair; pairs) {
if (obj.metainfo.ocn == pair[0]) {
@@ -2512,266 +2636,202 @@ struct ST_flow_table_substantive_munge {
}
}
}
- if (the_document_body_section.length > 1) {
- foreach (ref obj; the_document_body_section) {
- if (obj.metainfo.is_a == "heading") {
- foreach (pair; pairs) {
- if (obj.metainfo.ocn == pair[0]) {
- obj.metainfo.last_decendant_ocn = pair[1];
- }
- }
- }
- }
- }
- if (the_document_endnotes_section.length > 1) {
- foreach (ref obj; the_document_endnotes_section) {
- if (obj.metainfo.is_a == "heading") {
- foreach (pair; pairs) {
- if (obj.metainfo.ocn == pair[0]) {
- obj.metainfo.last_decendant_ocn = pair[1];
- }
- }
- }
- }
- }
- if (the_document_glossary_section.length > 1) {
- foreach (ref obj; the_document_glossary_section) {
- if (obj.metainfo.is_a == "heading") {
- foreach (pair; pairs) {
- if (obj.metainfo.ocn == pair[0]) {
- obj.metainfo.last_decendant_ocn = pair[1];
- }
- }
- }
- }
- }
- if (the_document_bibliography_section.length > 1) {
- foreach (ref obj; the_document_bibliography_section) {
- if (obj.metainfo.is_a == "heading") {
- foreach (pair; pairs) {
- if (obj.metainfo.ocn == pair[0]) {
- obj.metainfo.last_decendant_ocn = pair[1];
- }
- }
- }
- }
- }
- if (the_document_bookindex_section.length > 1) {
- foreach (ref obj; the_document_bookindex_section) {
- if (obj.metainfo.is_a == "heading") {
- foreach (pair; pairs) {
- if (obj.metainfo.ocn == pair[0]) {
- obj.metainfo.last_decendant_ocn = pair[1];
- }
- }
- }
- }
- }
- if (the_document_blurb_section.length > 1) {
- foreach (ref obj; the_document_blurb_section) {
- if (obj.metainfo.is_a == "heading") {
- foreach (pair; pairs) {
- if (obj.metainfo.ocn == pair[0]) {
- obj.metainfo.last_decendant_ocn = pair[1];
- }
- }
- }
- }
- }
- if (the_document_xml_dom_tail_section.length > 1) {
- foreach (ref obj; the_document_xml_dom_tail_section) {
- if (obj.metainfo.is_a == "heading") {
- foreach (pair; pairs) {
- if (obj.metainfo.ocn == pair[0]) {
- obj.metainfo.last_decendant_ocn = pair[1];
- }
- }
- }
- }
- }
- }
- // TODO
- // - note create/insert heading object sole purpose eof close all open tags
- // sort out:
- // - 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_heading_.metainfo.identifier = "";
- comp_obj_heading_.metainfo.dummy_heading = true;
- comp_obj_heading_.metainfo.object_number_off = true;
- comp_obj_heading_.metainfo.object_number_type = 0;
- comp_obj_heading_.tags.segment_anchor_tag_epub = "";
- 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_ = comp_obj_heading_.obj_dom_structure_set_markup_tags(dom_structure_markedup_tags_status, 0);
- comp_obj_heading_ = comp_obj_heading_.obj_dom_set_collapsed_tags(dom_structure_collapsed_tags_status, 0);
- comp_obj_heading_ = comp_obj_heading_.obj_heading_ancestors(lv_ancestors_txt);
- // the_dom_tail_section ~= comp_obj_heading_; // remove tail for now, decide on later
- ObjGenericComposite[][string] document_the = [
- "head": the_document_head_section,
- "toc": the_document_toc_section,
- // substantive/body:
- "body": the_document_body_section,
- // backmatter:
- "endnotes": the_document_endnotes_section,
- "glossary": the_document_glossary_section,
- "bibliography": the_document_bibliography_section,
- "bookindex": the_document_bookindex_section,
- "blurb": the_document_blurb_section,
- // dom tail only
- "tail": the_document_xml_dom_tail_section,
- ];
- string[][string] document_section_keys_sequenced = [
- "scroll": ["head", "toc", "body",],
- "seg": ["head", "toc", "body",],
- "sql": ["head", "body",],
- "latex": ["head", "toc", "body",]
- ];
- if (document_the["endnotes"].length > 1) {
- document_section_keys_sequenced["scroll"] ~= "endnotes";
- document_section_keys_sequenced["seg"] ~= "endnotes";
- document_section_keys_sequenced["latex"] ~= "endnotes";
- }
- if (document_the["glossary"].length > 1) {
- document_section_keys_sequenced["scroll"] ~= "glossary";
- document_section_keys_sequenced["seg"] ~= "glossary";
- document_section_keys_sequenced["sql"] ~= "glossary";
- document_section_keys_sequenced["latex"] ~= "glossary";
- }
- if (document_the["bibliography"].length > 1) {
- document_section_keys_sequenced["scroll"] ~= "bibliography";
- document_section_keys_sequenced["seg"] ~= "bibliography";
- document_section_keys_sequenced["sql"] ~= "bibliography";
- document_section_keys_sequenced["latex"] ~= "bibliography";
- }
- if (document_the["bookindex"].length > 1) {
- document_section_keys_sequenced["scroll"] ~= "bookindex";
- document_section_keys_sequenced["seg"] ~= "bookindex";
- document_section_keys_sequenced["sql"] ~= "bookindex";
- document_section_keys_sequenced["latex"] ~= "bookindex";
- }
- if (document_the["blurb"].length > 1) {
- document_section_keys_sequenced["scroll"] ~= "blurb";
- document_section_keys_sequenced["seg"] ~= "blurb";
- document_section_keys_sequenced["sql"] ~= "blurb";
- document_section_keys_sequenced["latex"] ~= "blurb";
- }
- if ((opt_action.html)
- || (opt_action.html_scroll)
- || (opt_action.html_seg)
- || (opt_action.epub)) {
- document_section_keys_sequenced["scroll"] ~= "tail";
- document_section_keys_sequenced["seg"] ~= "tail";
- }
- string[] segnames_4 = segnames["html"].dup;
- string[] segnames_lv1to4 = segnames["epub"].dup;
- debug(segnames) {
- writeln("segnames_lv4: ", segnames_4);
- writeln("segnames_lv1to4: ", segnames_lv1to4);
- }
- destroy(the_document_head_section);
- destroy(the_document_toc_section);
- destroy(the_document_body_section);
- destroy(the_document_endnotes_section);
- destroy(the_document_glossary_section);
- destroy(the_document_bibliography_section);
- destroy(the_document_bookindex_section);
- destroy(the_document_blurb_section);
- destroy(the_document_xml_dom_tail_section);
- destroy(segnames);
- destroy(bookindex_unordered_hashes);
- destroy(an_object);
- obj_cite_digits = ocn_emit(eN.ocn.reset);
- biblio_arr_json = [];
- obj_cite_digit_ = 0;
- html_segnames_ptr = 0;
- html_segnames_ptr_cntr = 0;
- content_non_header = "8";
- dom_structure_markedup_tags_status = [ 0, 0, 0, 0, 0, 0, 0, 0,];
- dom_structure_markedup_tags_status_buffer = [ 0, 0, 0, 0, 0, 0, 0, 0,];
- dom_structure_collapsed_tags_status = [ 0, 0, 0, 0, 0, 0, 0, 0,];
- dom_structure_collapsed_tags_status_buffer = [ 0, 0, 0, 0, 0, 0, 0, 0,];
- lev_anchor_tag = "";
- anchor_tag = "";
- struct DocHas_ {
- uint inline_links() {
- return dochas["inline_links"];
- }
- uint inline_notes_reg() {
- return dochas["inline_notes"];
- }
- uint inline_notes_star() {
- return dochas["inline_notes_star"];
- }
- uint codeblocks() {
- return dochas["codeblock"];
- }
- uint tables() {
- return dochas["table"];
- }
- uint blocks() {
- return dochas["block"];
- }
- uint groups() {
- return dochas["group"];
- }
- uint poems() {
- return dochas["poem"];
- }
- uint quotes() {
- return dochas["quote"];
- }
- ulong images() { // TODO not ideal rethink
- return (image_list.to!string.strip("[","]").split(",").length);
- }
- auto imagelist() {
- return image_list;
- }
- auto keys_seq() {
- return docSectKeysSeq!()(document_section_keys_sequenced);
- }
- string[] segnames_lv4() {
- return segnames_4;
- }
- string[] segnames_lv_0_to_4() {
- return segnames_0_to_4;
- }
- string[string][string] tag_associations() {
- return tag_assoc;
- }
- }
- @safe auto doc_has() {
- return DocHas_();
}
- struct ST_docAbstraction {
- ObjGenericComposite[][string] document_the;
- DocHas_ doc_has;
- }
- ST_docAbstraction ret;
- {
- ret.document_the = document_the;
- ret.doc_has = doc_has;
+}
+// TODO
+// - note create/insert heading object sole purpose eof close all open tags
+// sort out:
+// - 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_heading_.metainfo.identifier = "";
+comp_obj_heading_.metainfo.dummy_heading = true;
+comp_obj_heading_.metainfo.object_number_off = true;
+comp_obj_heading_.metainfo.object_number_type = 0;
+comp_obj_heading_.tags.segment_anchor_tag_epub = "";
+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_ = comp_obj_heading_.obj_dom_structure_set_markup_tags(dom_structure_markedup_tags_status, 0);
+comp_obj_heading_ = comp_obj_heading_.obj_dom_set_collapsed_tags(dom_structure_collapsed_tags_status, 0);
+comp_obj_heading_ = comp_obj_heading_.obj_heading_ancestors(lv_ancestors_txt);
+// the_dom_tail_section ~= comp_obj_heading_; // remove tail for now, decide on later
+// the doc
+ObjGenericComposite[][string] document_the = [
+ "head": the_document_head_section,
+ "toc": the_document_toc_section,
+ // substantive/body:
+ "body": the_document_body_section,
+ // backmatter:
+ "endnotes": the_document_endnotes_section,
+ "glossary": the_document_glossary_section,
+ "bibliography": the_document_bibliography_section,
+ "bookindex": the_document_bookindex_section,
+ "blurb": the_document_blurb_section,
+ // dom tail only
+ "tail": the_document_xml_dom_tail_section,
+];
+// document parts keys as needed
+string[][string] document_section_keys_sequenced = [
+ "scroll": ["head", "toc", "body",],
+ "seg": ["head", "toc", "body",],
+ "sql": ["head", "body",],
+ "latex": ["head", "toc", "body",]
+];
+if (document_the["endnotes"].length > 1) {
+ document_section_keys_sequenced["scroll"] ~= "endnotes";
+ document_section_keys_sequenced["seg"] ~= "endnotes";
+ document_section_keys_sequenced["latex"] ~= "endnotes";
+}
+if (document_the["glossary"].length > 1) {
+ document_section_keys_sequenced["scroll"] ~= "glossary";
+ document_section_keys_sequenced["seg"] ~= "glossary";
+ document_section_keys_sequenced["sql"] ~= "glossary";
+ document_section_keys_sequenced["latex"] ~= "glossary";
+}
+if (document_the["bibliography"].length > 1) {
+ document_section_keys_sequenced["scroll"] ~= "bibliography";
+ document_section_keys_sequenced["seg"] ~= "bibliography";
+ document_section_keys_sequenced["sql"] ~= "bibliography";
+ document_section_keys_sequenced["latex"] ~= "bibliography";
+}
+if (document_the["bookindex"].length > 1) {
+ document_section_keys_sequenced["scroll"] ~= "bookindex";
+ document_section_keys_sequenced["seg"] ~= "bookindex";
+ document_section_keys_sequenced["sql"] ~= "bookindex";
+ document_section_keys_sequenced["latex"] ~= "bookindex";
+}
+if (document_the["blurb"].length > 1) {
+ document_section_keys_sequenced["scroll"] ~= "blurb";
+ document_section_keys_sequenced["seg"] ~= "blurb";
+ document_section_keys_sequenced["sql"] ~= "blurb";
+ document_section_keys_sequenced["latex"] ~= "blurb";
+}
+if ((opt_action.html)
+|| (opt_action.html_scroll)
+|| (opt_action.html_seg)
+|| (opt_action.epub)) {
+ document_section_keys_sequenced["scroll"] ~= "tail";
+ document_section_keys_sequenced["seg"] ~= "tail";
+}
+// segnames
+string[] segnames_4 = segnames["html"].dup;
+string[] segnames_lv1to4 = segnames["epub"].dup;
+debug(segnames) {
+ writeln("segnames_lv4: ", segnames_4);
+ writeln("segnames_lv1to4: ", segnames_lv1to4);
+}
+// restart
+destroy(the_document_head_section);
+destroy(the_document_toc_section);
+destroy(the_document_body_section);
+destroy(the_document_endnotes_section);
+destroy(the_document_glossary_section);
+destroy(the_document_bibliography_section);
+destroy(the_document_bookindex_section);
+destroy(the_document_blurb_section);
+destroy(the_document_xml_dom_tail_section);
+destroy(segnames);
+destroy(bookindex_unordered_hashes);
+destroy(an_object);
+obj_cite_digits = ocn_emit(eN.ocn.reset);
+biblio_arr_json = [];
+obj_cite_digit_ = 0;
+html_segnames_ptr = 0;
+html_segnames_ptr_cntr = 0;
+content_non_header = "8";
+dom_structure_markedup_tags_status = [ 0, 0, 0, 0, 0, 0, 0, 0,];
+dom_structure_markedup_tags_status_buffer = [ 0, 0, 0, 0, 0, 0, 0, 0,];
+dom_structure_collapsed_tags_status = [ 0, 0, 0, 0, 0, 0, 0, 0,];
+dom_structure_collapsed_tags_status_buffer = [ 0, 0, 0, 0, 0, 0, 0, 0,];
+lev_anchor_tag = "";
+anchor_tag = "";
+// identify parts
+struct DocHas_ {
+ uint inline_links() {
+ return dochas["inline_links"];
+ }
+ uint inline_notes_reg() {
+ return dochas["inline_notes"];
+ }
+ uint inline_notes_star() {
+ return dochas["inline_notes_star"];
+ }
+ uint codeblocks() {
+ return dochas["codeblock"];
+ }
+ uint tables() {
+ return dochas["table"];
+ }
+ uint blocks() {
+ return dochas["block"];
+ }
+ uint groups() {
+ return dochas["group"];
+ }
+ uint poems() {
+ return dochas["poem"];
+ }
+ uint quotes() {
+ return dochas["quote"];
+ }
+ ulong images() { // TODO not ideal rethink
+ return (image_list.to!string.strip("[","]").split(",").length);
+ }
+ auto imagelist() {
+ return image_list;
+ }
+ auto keys_seq() {
+ return docSectKeysSeq!()(document_section_keys_sequenced);
+ }
+ string[] segnames_lv4() {
+ return segnames_4;
+ }
+ string[] segnames_lv_0_to_4() {
+ return segnames_0_to_4;
+ }
+ string[string][string] tag_associations() {
+ return tag_assoc;
}
- return ret;
-} // ← closed: abstract doc source
+}
+@safe auto doc_has() {
+ return DocHas_();
+}
+#+END_SRC
+
+*** return structure
+
+#+NAME: docAbstractionReturnsStruct
+#+HEADER: :noweb yes
+#+BEGIN_SRC d
+// the doc to be returned
+struct ST_docAbstraction {
+ ObjGenericComposite[][string] document_the;
+ DocHas_ doc_has;
+}
+ST_docAbstraction ret;
+{
+ ret.document_the = document_the;
+ ret.doc_has = doc_has;
+}
+return ret;
#+END_SRC
-** sort
+** docAbstraction related Functions
-#+NAME: docSortOut
+#+NAME: docAbstractionRelatedFunctions
#+HEADER: :noweb yes
#+BEGIN_SRC d
@system ST_txt_by_line_common_reset txt_by_line_common_reset_()(
diff --git a/src/doc_reform/meta/metadoc_from_src.d b/src/doc_reform/meta/metadoc_from_src.d
index e1779ad..7374c76 100644
--- a/src/doc_reform/meta/metadoc_from_src.d
+++ b/src/doc_reform/meta/metadoc_from_src.d
@@ -1115,8 +1115,7 @@ template docAbstraction() {
if (line.matchFirst(rgx.book_index_item)
|| line.matchFirst(rgx.book_index_item_open)
|| pith["section"] == eN.sect.book_index) {
- // book_index
- {
+ { // book_index
auto _get = line.flow_book_index_(an_object, book_idx_tmp, pith, opt_action);
{
an_object = _get.this_object;
@@ -1544,7 +1543,7 @@ template docAbstraction() {
object_notes = _doc_by_line.object_notes; // endnotes, compare, not sure is used
destroy(_doc_by_line);
}
- { // EOF
+ { // EOF backMatter
comp_obj_heading_ = comp_obj_heading_.init;
comp_obj_heading_.metainfo.is_of_part = "backmatter";
comp_obj_heading_.metainfo.is_of_section = "tail";
@@ -1570,6 +1569,7 @@ template docAbstraction() {
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_lv1to4"] = comp_obj_heading_.tags.segment_anchor_tag_epub;
}
+ // endNotes
auto en_tuple = note_section.endnote_objects(obj_cite_digits, opt_action); // endnotes, check
auto the_document_endnotes_section = en_tuple[0];
obj_cite_digits = en_tuple[1];
@@ -1577,6 +1577,7 @@ template docAbstraction() {
writefln("%s %s", __LINE__, the_document_endnotes_section.length);
foreach (o; the_document_endnotes_section) { writeln(o); }
}
+ // glossary
if (an_object["glossary_nugget"].length == 0) {
comp_obj_heading_ = comp_obj_heading_.init;
comp_obj_heading_.metainfo.is_of_part = "empty";
@@ -1596,6 +1597,7 @@ template docAbstraction() {
the_document_glossary_section ~= comp_obj_heading_;
}
debug(glossary) { foreach (gloss; the_document_glossary_section) { writeln(gloss.text); } }
+ // bibliography
auto biblio_unsorted_incomplete = biblio_arr_json.dup;
auto biblio = Bibliography();
JSONValue[] biblio_ordered;
@@ -1719,6 +1721,7 @@ template docAbstraction() {
obj_cite_digits,
opt_action,
);
+ // bookindex
destroy(bookindex_unordered_hashes);
auto the_document_bookindex_section = bi_tuple[0];
obj_cite_digits = bi_tuple[1];
@@ -1743,6 +1746,7 @@ template docAbstraction() {
comp_obj_heading_.metainfo.parent_lev_markup = 0;
the_document_blurb_section ~= comp_obj_heading_;
}
+ // blurb
debug(blurb) { foreach (blurb; the_document_blurb_section) { writeln(blurb.text); } }
indent = [
"hang_position" : 1,
@@ -1760,6 +1764,7 @@ template docAbstraction() {
comp_obj_toc.attrib.indent_hang = indent["hang_position"];
comp_obj_toc.attrib.indent_base = indent["base_position"];
comp_obj_toc.attrib.bullet = false;
+ // use gathered
if (the_document_endnotes_section.length > 1) {
toc_txt_ = format("%s%s%s%s#%s%s",
mkup.lnk_o,
@@ -1836,8 +1841,10 @@ template docAbstraction() {
writeln(mkup.indent_by_spaces_provided(toc_linked_heading.attrib.indent_hang), toc_linked_heading.text);
}
}
+ // document head and body
the_document_head_section ~= the_document_body_section[0];
the_document_body_section = the_document_body_section[1..$];
+ // document ancestors
@safe int[] _get_ancestors_markup(O)(O obj, ref int[] _ancestors_markup) {
if (obj.metainfo.is_a == "heading") {
debug(dom) { writeln(obj.text); }
@@ -2025,6 +2032,7 @@ template docAbstraction() {
writeln("ancestors collapsed o_n: ", obj.metainfo.markedup_ancestors);
}
}
+ // segnames
if (the_document_endnotes_section.length > 1) {
segnames["html"] ~= "endnotes";
segnames["epub"] ~= "endnotes";
@@ -2100,6 +2108,7 @@ template docAbstraction() {
}
html_segnames_ptr_cntr++;
}
+ // decendants
@safe auto get_decendants()(ObjGenericComposite[] document_sections) {
int[string] _heading_ocn_decendants;
string[] _ocn_open_key = ["","","","","","","",""];
@@ -2147,6 +2156,7 @@ template docAbstraction() {
}
return pairs.sort;
}
+ // images
string[] _images;
@safe string[] extract_images()(string content_block) {
string[] images_;
@@ -2193,6 +2203,7 @@ template docAbstraction() {
}
return obj;
}
+ // links
@safe auto _links(O)(O obj) {
if (auto m = obj.text.match(rgx.inline_link_stow_uri)) {
debug(links) {
@@ -2212,6 +2223,7 @@ template docAbstraction() {
}
return obj;
}
+ // document head
foreach (ref obj; the_document_head_section) {
if (obj.metainfo.is_a == "heading") {
debug(dom) { writeln(obj.text); }
@@ -2300,7 +2312,7 @@ template docAbstraction() {
}
}
auto image_list = (_images.sort()).uniq;
- // optional only one 1~ level
+ // endnotes optional only one 1~ level
if (the_document_endnotes_section.length > 1) {
dom_structure_markedup_tags_status_buffer = dom_structure_markedup_tags_status.dup;
dom_structure_collapsed_tags_status_buffer = dom_structure_collapsed_tags_status.dup;
@@ -2335,7 +2347,7 @@ template docAbstraction() {
obj = _links(obj);
}
}
- // optional only one 1~ level
+ // glossary optional only one 1~ level
if (the_document_glossary_section.length > 1) {
foreach (ref obj; the_document_glossary_section) {
if (obj.metainfo.is_a == "heading") {
@@ -2370,7 +2382,7 @@ template docAbstraction() {
obj = _links(obj);
}
}
- // optional only one 1~ level
+ // bibliography optional only one 1~ level
if (the_document_bibliography_section.length > 1) {
foreach (ref obj; the_document_bibliography_section) {
if (obj.metainfo.is_a == "heading") {
@@ -2405,7 +2417,7 @@ template docAbstraction() {
obj = _links(obj);
}
}
- // optional only one 1~ level
+ // book index, optional only one 1~ level
int ocn_ = obj_cite_digits.object_number;
int ocn_bkidx_ = 0;
int ocn_bidx_;
@@ -2451,7 +2463,7 @@ template docAbstraction() {
// TODO assert failure, reinstate
// assert(obj_cite_digit_bkidx == ocn_bidx_ obj_cite_digit_bkidx ~ " == ocn_" ~ ocn_ ~ "?");
}
- // optional only one 1~ level
+ // blurb optional only one 1~ level
if (the_document_blurb_section.length > 1) {
foreach (ref obj; the_document_blurb_section) {
if (obj.metainfo.is_a == "heading") {
@@ -2486,6 +2498,7 @@ template docAbstraction() {
obj = _links(obj);
}
}
+ // get decendants
if (the_document_body_section.length > 1) {
auto pairs = get_decendants(
the_document_head_section ~
@@ -2620,6 +2633,7 @@ template docAbstraction() {
comp_obj_heading_ = comp_obj_heading_.obj_dom_set_collapsed_tags(dom_structure_collapsed_tags_status, 0);
comp_obj_heading_ = comp_obj_heading_.obj_heading_ancestors(lv_ancestors_txt);
// the_dom_tail_section ~= comp_obj_heading_; // remove tail for now, decide on later
+ // the doc
ObjGenericComposite[][string] document_the = [
"head": the_document_head_section,
"toc": the_document_toc_section,
@@ -2634,6 +2648,7 @@ template docAbstraction() {
// dom tail only
"tail": the_document_xml_dom_tail_section,
];
+ // document parts keys as needed
string[][string] document_section_keys_sequenced = [
"scroll": ["head", "toc", "body",],
"seg": ["head", "toc", "body",],
@@ -2676,12 +2691,14 @@ template docAbstraction() {
document_section_keys_sequenced["scroll"] ~= "tail";
document_section_keys_sequenced["seg"] ~= "tail";
}
+ // segnames
string[] segnames_4 = segnames["html"].dup;
string[] segnames_lv1to4 = segnames["epub"].dup;
debug(segnames) {
writeln("segnames_lv4: ", segnames_4);
writeln("segnames_lv1to4: ", segnames_lv1to4);
}
+ // restart
destroy(the_document_head_section);
destroy(the_document_toc_section);
destroy(the_document_body_section);
@@ -2706,6 +2723,7 @@ template docAbstraction() {
dom_structure_collapsed_tags_status_buffer = [ 0, 0, 0, 0, 0, 0, 0, 0,];
lev_anchor_tag = "";
anchor_tag = "";
+ // identify parts
struct DocHas_ {
uint inline_links() {
return dochas["inline_links"];
@@ -2756,6 +2774,7 @@ template docAbstraction() {
@safe auto doc_has() {
return DocHas_();
}
+ // the doc to be returned
struct ST_docAbstraction {
ObjGenericComposite[][string] document_the;
DocHas_ doc_has;