aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/doc_reform/meta
diff options
context:
space:
mode:
Diffstat (limited to 'src/doc_reform/meta')
-rw-r--r--src/doc_reform/meta/metadoc_from_src.d3199
1 files changed, 1558 insertions, 1641 deletions
diff --git a/src/doc_reform/meta/metadoc_from_src.d b/src/doc_reform/meta/metadoc_from_src.d
index ac250a7..03a0286 100644
--- a/src/doc_reform/meta/metadoc_from_src.d
+++ b/src/doc_reform/meta/metadoc_from_src.d
@@ -69,59 +69,6 @@ template docAbstraction() {
mixin ObjectSetter;
mixin InternalMarkup;
mixin spineRgxIn;
- // ↓ abstraction struct init
- @safe static auto eN() {
- struct _e {
- enum bi {
- off,
- on,
- }
- enum ocn {
- off,
- on,
- closing,
- bkidx,
- reset,
- }
- enum sect {
- unset,
- head,
- toc,
- substantive,
- bibliography,
- glossary,
- book_index,
- blurb,
- }
- enum txt_is {
- off,
- para,
- heading,
- }
- enum blk_is {
- off,
- code,
- poem,
- block,
- group,
- table,
- quote,
- }
- enum blk_state {
- off,
- on,
- closing,
- }
- enum blk_delim {
- off,
- curly,
- tic,
- curly_special,
- tic_special,
- }
- }
- return _e();
- }
// initialize
ObjGenericComposite[] the_document_toc_section, the_document_head_section, the_document_body_section, the_document_endnotes_section, the_document_bibliography_section, the_document_bookindex_section, the_document_glossary_section, the_document_blurb_section, the_document_xml_dom_tail_section;
struct _theDoc {
@@ -197,10 +144,27 @@ template docAbstraction() {
ObjGenericComposite[] bookindex;
OCNset ocn;
}
+ struct ST_biblio_section {
+ ObjGenericComposite[] bibliography_section;
+ string[string][string] tag_assoc;
+ }
int[] dom_structure_markedup_tags_status = [ 0, 0, 0, 0, 0, 0, 0, 0, 0,];
int[] dom_structure_markedup_tags_status_buffer = [ 0, 0, 0, 0, 0, 0, 0, 0, 0,];
int[] dom_structure_collapsed_tags_status = [ 0, 0, 0, 0, 0, 0, 0, 0, 0,];
int[] dom_structure_collapsed_tags_status_buffer = [ 0, 0, 0, 0, 0, 0, 0, 0, 0,];
+ struct ST_ancestors {
+ ObjGenericComposite[] the_document_body_section;
+ ObjGenericComposite[] the_document_endnotes_section;
+ ObjGenericComposite[] the_document_glossary_section;
+ ObjGenericComposite[] the_document_bibliography_section;
+ ObjGenericComposite[] the_document_bookindex_section;
+ ObjGenericComposite[] the_document_blurb_section;
+ }
+ struct ST_segnames {
+ string[][string] segnames;
+ int html_segnames_ptr_cntr;
+ int html_segnames_ptr;
+ }
struct ST_txtPlusHasFootnotes {
string obj_txt;
bool has_notes_reg;
@@ -224,208 +188,18 @@ template docAbstraction() {
bool has_links; // use same name
bool has_images_without_dimensions;
}
- enum DomTags { none, open, close, close_and_open, open_still, }
- @safe pure ObjGenericComposite obj_heading_ancestors()(
- ObjGenericComposite obj,
- string[] lv_ancestors_txt,
- ) {
- switch (obj.metainfo.heading_lev_markup) {
- case 0:
- lv_ancestors_txt[0] = obj.text.to!string;
- foreach(k; 1..8) { lv_ancestors_txt[k] = ""; }
- goto default;
- case 1:
- lv_ancestors_txt[1] = obj.text.to!string;
- foreach(k; 2..8) { lv_ancestors_txt[k] = ""; }
- goto default;
- case 2:
- lv_ancestors_txt[2] = obj.text.to!string;
- foreach(k; 3..8) { lv_ancestors_txt[k] = ""; }
- goto default;
- case 3:
- lv_ancestors_txt[3] = obj.text.to!string;
- foreach(k; 4..8) { lv_ancestors_txt[k] = ""; }
- goto default;
- case 4:
- lv_ancestors_txt[4] = obj.text.to!string;
- foreach(k; 5..8) { lv_ancestors_txt[k] = ""; }
- goto default;
- case 5:
- lv_ancestors_txt[5] = obj.text.to!string;
- foreach(k; 6..8) { lv_ancestors_txt[k] = ""; }
- goto default;
- case 6:
- lv_ancestors_txt[6] = obj.text.to!string;
- lv_ancestors_txt[7] = "";
- goto default;
- case 7:
- lv_ancestors_txt[7] = obj.text.to!string;
- goto default;
- default:
- obj.tags.heading_ancestors_text = lv_ancestors_txt.dup;
- }
- return obj;
- }
- @safe pure ObjGenericComposite obj_dom_structure_set_markup_tags()(
- ObjGenericComposite obj,
- int[] dom,
- int lev
- ) {
- foreach (i; 0 .. 8) {
- if (i < lev) {
- if (dom[i] == DomTags.open
- || dom[i] == DomTags.close_and_open
- ) {
- dom[i] = DomTags.open_still;
- } else if (dom[i] == DomTags.close) {
- dom[i] = DomTags.none;
- }
- } else if (i == lev) {
- if (lev == 0
- && dom[i] == DomTags.open_still
- ) {
- dom[i] = DomTags.close;
- } else if (dom[i] == DomTags.open
- || dom[i] == DomTags.open_still
- || dom[i] == DomTags.close_and_open
- ) {
- dom[i] = DomTags.close_and_open;
- } else {
- dom[i] = DomTags.open;
- }
- } else if (i > lev) {
- if (dom[i] == DomTags.close) {
- dom[i] = DomTags.none;
- } else if (dom[i] == DomTags.open
- || dom[i] == DomTags.open_still
- || dom[i] == DomTags.close_and_open
- ) {
- dom[i] = DomTags.close;
- }
- }
- }
- debug(dom_magic_numbers) { writeln("marked up: ", lev, ": ", dom); }
- obj.metainfo.dom_structure_markedup_tags_status = dom.dup;
- return obj;
- }
- @safe pure ObjGenericComposite obj_dom_set_collapsed_tags()(
- ObjGenericComposite obj,
- int[] dom,
- int lev
- ) {
- foreach (i; 0 .. 8) {
- if (i < lev) {
- if (dom[i] == DomTags.open
- || dom[i] == DomTags.close_and_open
- ) {
- dom[i] = DomTags.open_still;
- } else if (dom[i] == DomTags.close) {
- dom[i] = DomTags.none;
- }
- } else if (i == lev) {
- if (lev == 0
- && dom[i] == DomTags.open_still
- ) {
- dom[i] = DomTags.close;
- } else if (dom[i] == DomTags.open
- || dom[i] == DomTags.open_still
- || dom[i] == DomTags.close_and_open
- ) {
- dom[i] = DomTags.close_and_open;
- } else {
- dom[i] = DomTags.open;
- }
- } else if (i > lev) {
- if (dom[i] == DomTags.close) {
- dom[i] = DomTags.none;
- } else if (dom[i] == DomTags.open
- || dom[i] == DomTags.open_still
- || dom[i] == DomTags.close_and_open
- ) {
- dom[i] = DomTags.close;
- }
- }
- }
- debug(dom_magic_numbers) { writeln("collapsed: ", lev, ": ", dom); }
- obj.metainfo.dom_structure_collapsed_tags_status = dom.dup;
- return obj;
- }
- @safe static OCNset ocn_emit(int ocn_status_flag) {
- return object_citation_number.ocn_emitter(ocn_status_flag);
- }
- @safe auto inline_markup_faces(L)(L line) {
- static auto rgx = RgxI();
- static auto mkup = InlineMarkup();
- line = replaceAll!(m => mkup.quote_o ~ m[1] ~ mkup.quote_c)(line, rgx.within_quotes);
- line = replaceAll!(m => mkup.ff_i ~ mkup.mono ~ mkup.ff_o ~ m["text"] ~ mkup.ff_c ~ mkup.mono)(line, rgx.inline_mark_mono);
- line = replaceAll!(m => mkup.ff_i ~ mkup.cite ~ mkup.ff_o ~ m["text"] ~ mkup.ff_c ~ mkup.cite)(line, rgx.inline_mark_cite);
- foreach (regx; [rgx.inline_mark_emphasis, rgx.inline_mark_bold, rgx.inline_mark_underscore, rgx.inline_mark_italics, rgx.inline_mark_superscript, rgx.inline_mark_subscript, rgx.inline_mark_strike, rgx.inline_mark_insert]) {
- line = replaceAll!(m => mkup.ff_i ~ m["mark"] ~ mkup.ff_o ~ m["text"] ~ mkup.ff_c ~ m["mark"])(line, regx);
- }
- return line;
- }
- @safe static string links_and_images()(string obj_txt) {
- static auto rgx = RgxI();
- static auto mkup = InlineMarkup();
- if (obj_txt.match(rgx.smid_inline_url_generic)) {
- if (
- obj_txt.match(rgx.smid_inline_link_endnote_url_helper)
- || obj_txt.match(rgx.smid_inline_link_endnote_url_helper_punctuated)
- ) {
- obj_txt = replaceAll!(m => format("%s%s%s%s%s%s%s %s%s%s%s%s%s %s%s",
- mkup.lnk_o, m["content"].strip, mkup.lnk_c,
- mkup.url_o, m["link"], mkup.url_c,
- mkup.en_a_o,
- mkup.lnk_o, m["link"].strip, mkup.lnk_c,
- mkup.url_o, m["link"], mkup.url_c,
- mkup.en_a_c,
- m[3]
- ))(obj_txt, rgx.smid_inline_link_endnote_url_helper_punctuated);
- obj_txt = replaceAll!(m => format("%s%s%s%s%s%s%s %s%s%s%s%s%s %s",
- mkup.lnk_o, m["content"].strip, mkup.lnk_c,
- mkup.url_o, m["link"], mkup.url_c,
- mkup.en_a_o,
- mkup.lnk_o, m["link"].strip, mkup.lnk_c,
- mkup.url_o, m["link"], mkup.url_c,
- mkup.en_a_c
- ))(obj_txt, rgx.smid_inline_link_endnote_url_helper);
- } else {
- obj_txt = replaceAll!(m => format("%s%s%s%s%s%s%s",
- m["pre"],
- mkup.lnk_o, m["content"].strip, mkup.lnk_c,
- mkup.url_o, m["link"], mkup.url_c
- ))(obj_txt, rgx.smid_inline_link_markup_regular);
- }
- obj_txt = replaceAll!(m => format("%s%s%s%s%s%s%s",
- m["pre"],
- mkup.lnk_o, m["link"].strip, mkup.lnk_c,
- mkup.url_o, m["link"], mkup.url_c
- ))(obj_txt, rgx.smid_inline_link_naked_url); //
- }
- return obj_txt;
+ struct ST_the_section {
+ ObjGenericComposite[] comp_section_obj; // array: the heading has 2 members inserted, paras just 1
+ uint[string] pith;
+ string[string][string] tag_assoc; // only for headings: html & epub
}
+ enum DomTags { none, open, close, close_and_open, open_still, }
// book index variables
string book_idx_tmp;
string[][string][string] bookindex_unordered_hashes;
// node
- ObjGenericComposite comp_obj_heading, comp_obj_location, comp_obj_block, comp_obj_code, comp_obj_poem_ocn, comp_obj_comment;
+ ObjGenericComposite comp_obj_, comp_obj_location, comp_obj_poem_ocn, comp_obj_comment;
auto node_construct = NodeStructureMetadata();
- @safe string[string][string] inline_para_link_anchor()(
- string[string] an_object,
- string[string] tag_in_seg,
- string[string][string] tag_assoc
- ) {
- static auto rgx = RgxI();
- if (auto m = an_object["substantive"].match(rgx.inline_link_anchor)) {
- if (m.captures[1] !in tag_assoc) {
- tag_assoc[(m.captures[1])]["seg_lv4"] = tag_in_seg["seg_lv4"];
- tag_assoc[(m.captures[1])]["seg_lv1to4"] = tag_in_seg["seg_lv1to4"];
- } else {
- writeln("a tag named already exists, check text line\n ", an_object["substantive"]);
- }
- }
- return tag_assoc;
- }
struct ST_txt_by_line_common_reset {
int[string] line_occur;
string[string] this_object;
@@ -491,7 +265,7 @@ template docAbstraction() {
string[string] this_object;
ObjGenericComposite[] the_document_body_section;
OCNset obj_cite_digits;
- ObjGenericComposite _comp_obj_heading;
+ ObjGenericComposite comp_obj_;
int cntr;
uint[string] pith;
}
@@ -500,7 +274,7 @@ template docAbstraction() {
ObjGenericComposite[] the_document_body_section;
string[][string][string] bookindex_unordered_hashes;
OCNset obj_cite_digits;
- ObjGenericComposite comp_obj_heading;
+ ObjGenericComposite comp_obj_;
int cntr;
uint[string] pith;
}
@@ -540,7 +314,7 @@ template docAbstraction() {
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;
+ ObjGenericComposite comp_obj_;
line_occur = [
"heading" : 0,
"para" : 0,
@@ -623,31 +397,19 @@ template docAbstraction() {
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_;
+ comp_obj_ = set_object_heading("lev4", "frontmatter", "toc", "Table of Contents");
+ comp_obj_.metainfo.identifier = "";
+ comp_obj_.metainfo.dummy_heading = false;
+ comp_obj_.metainfo.object_number_off = true;
+ comp_obj_.metainfo.object_number_type = 0;
+ comp_obj_.tags.segment_anchor_tag_epub = "toc";
+ comp_obj_.tags.anchor_tag_html = comp_obj_.tags.segment_anchor_tag_epub;
+ comp_obj_.tags.in_segment_html = comp_obj_.tags.anchor_tag_html;
+ comp_obj_.ptr.html_segnames = html_segnames_ptr;
+ comp_obj_.tags.anchor_tags = ["toc"];
+ tag_assoc[comp_obj_.tags.anchor_tag_html]["seg_lv4"] = comp_obj_.tags.in_segment_html;
+ tag_assoc[comp_obj_.tags.segment_anchor_tag_epub]["seg_lv1to4"] = comp_obj_.tags.segment_anchor_tag_epub;
+ auto toc_head = comp_obj_;
html_segnames_ptr_cntr++;
the_document_toc_section = [toc_head];
static auto mkup = InlineMarkup();
@@ -766,95 +528,13 @@ template docAbstraction() {
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 {
- {
- 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;
- }
- }
- 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;
+ ST_the_section add_to_glossary_sect = line.build_the_glossary_section(pith, tag_assoc);
+ the_document_glossary_section ~= add_to_glossary_sect.comp_section_obj[0];
+ if (add_to_glossary_sect.comp_section_obj.length > 1) { // heading
+ the_document_glossary_section ~= add_to_glossary_sect.comp_section_obj[1];
}
- pith["ocn"] = eN.ocn.on;
+ pith = add_to_glossary_sect.pith;
+ tag_assoc = add_to_glossary_sect.tag_assoc;
}
continue;
} else if (line.matchFirst(rgx.heading_blurb)
@@ -866,141 +546,14 @@ template docAbstraction() {
) {
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" : (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;
+ if ((opt_action.backmatter && opt_action.section_blurb) && !(line.empty)) {
+ ST_the_section add_to_blurb_sect = line.build_the_blurb_section(pith, tag_assoc, opt_action);
+ the_document_blurb_section ~= add_to_blurb_sect.comp_section_obj[0];
+ if (add_to_blurb_sect.comp_section_obj.length > 1) { // heading
+ the_document_blurb_section ~= add_to_blurb_sect.comp_section_obj[1];
}
- 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)) {
- 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);
- {
- 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;
+ pith = add_to_blurb_sect.pith;
+ tag_assoc = add_to_blurb_sect.tag_assoc;
}
continue;
} else if (pith["block_state"] == eN.blk_state.on) {
@@ -1238,7 +791,7 @@ template docAbstraction() {
the_document_body_section,
bookindex_unordered_hashes,
obj_cite_digits,
- comp_obj_heading,
+ comp_obj_,
cntr,
pith,
object_number_poem,
@@ -1250,7 +803,7 @@ template docAbstraction() {
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;
+ comp_obj_ = _get.comp_obj_;
cntr = _get.cntr;
pith = _get.pith;
}
@@ -1369,11 +922,8 @@ template docAbstraction() {
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"],
+ auto comp_obj_ = node_construct.node_emitter_heading(
+ an_object,
tag_in_seg,
lev_anchor_tag,
tag_assoc,
@@ -1381,11 +931,8 @@ template docAbstraction() {
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,
+ substantive_object_and_anchor_tags_struct,
);
++heading_ptr;
debug(segments) {
@@ -1393,7 +940,7 @@ template docAbstraction() {
writeln(tag_in_seg["seg_lv4"]);
writeln(tag_in_seg["seg_lv1to4"]);
}
- the_document_body_section ~= comp_obj_heading;
+ the_document_body_section ~= comp_obj_;
debug(objectrelated1) { writeln(line); } // check
{
auto _get = txt_by_line_common_reset_(line_occur, an_object, pith);
@@ -1417,7 +964,7 @@ template docAbstraction() {
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(
+ auto comp_obj_ = node_construct.node_location_emitter(
content_non_header,
tag_in_seg,
lev_anchor_tag,
@@ -1431,28 +978,22 @@ template docAbstraction() {
= 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;
+ comp_obj_ = set_object_generic("body", "body", "para", "para", an_object["substantive"].to!string.strip, obj_cite_digits.object_number);
+ comp_obj_.tags.html_segment_anchor_tag_is = tag_in_seg["seg_lv4"];
+ comp_obj_.tags.epub_segment_anchor_tag_is = tag_in_seg["seg_lv1to4"];
+ comp_obj_.metainfo.identifier = obj_cite_digits.identifier;
+ comp_obj_.metainfo.object_number_off = (obj_cite_digits.off == 0) ? true : false; // TODO
+ comp_obj_.metainfo.o_n_book_index = obj_cite_digits.bkidx;
+ comp_obj_.metainfo.object_number_type = obj_cite_digits.type;
+ comp_obj_.attrib.indent_hang = indent["hang_position"];
+ comp_obj_.attrib.indent_base = indent["base_position"];
+ comp_obj_.attrib.bullet = bullet;
+ comp_obj_.tags.anchor_tags = [anchor_tag]; anchor_tag="";
+ comp_obj_.has.inline_notes_reg = substantive_obj_misc_struct.has_notes_reg;
+ comp_obj_.has.inline_notes_star = substantive_obj_misc_struct.has_notes_star;
+ comp_obj_.has.inline_links = substantive_obj_misc_struct.has_links;
+ comp_obj_.has.image_without_dimensions = substantive_obj_misc_struct.has_images_without_dimensions;
+ the_document_body_section ~= comp_obj_;
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);
@@ -1539,30 +1080,20 @@ template docAbstraction() {
destroy(_doc_by_line);
}
{ // 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;
+ comp_obj_ = set_object_heading("lev1", "backmatter", "tail", "");
+ comp_obj_.metainfo.identifier = "";
+ comp_obj_.metainfo.dummy_heading = false;
+ comp_obj_.metainfo.object_number_off = false;
+ comp_obj_.metainfo.object_number_type = 0;
+ comp_obj_.tags.segment_anchor_tag_epub = "_part_eof";
+ comp_obj_.tags.anchor_tag_html = comp_obj_.tags.segment_anchor_tag_epub;
+ comp_obj_.tags.in_segment_html = "tail";
+ comp_obj_.tags.anchor_tags = ["section_eof"];
+ comp_obj_.metainfo.dom_structure_markedup_tags_status = [ 0, 0, 0, 0, 0, 0, 0, 0];
+ comp_obj_.metainfo.dom_structure_collapsed_tags_status = [ 0, 0, 0, 0, 0, 0, 0, 0];
+ the_document_xml_dom_tail_section ~= comp_obj_;
+ tag_assoc[comp_obj_.tags.anchor_tag_html]["seg_lv4"] = comp_obj_.tags.in_segment_html;
+ tag_assoc[comp_obj_.tags.segment_anchor_tag_epub]["seg_lv1to4"] = comp_obj_.tags.segment_anchor_tag_epub;
}
// endNotes
ST_endnotes en_st = note_section.backmatter_endnote_objects(obj_cite_digits, opt_action);
@@ -1576,140 +1107,20 @@ template docAbstraction() {
}
{ // 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_;
+ comp_obj_ = set_object_heading("lev1", "empty", "empty", "(skip) there is no Glossary section");
+ comp_obj_.metainfo.identifier = "";
+ comp_obj_.metainfo.dummy_heading = true;
+ comp_obj_.metainfo.object_number_off = true;
+ comp_obj_.metainfo.object_number_type = 0;
+ the_document_glossary_section ~= comp_obj_;
}
debug(glossary) { foreach (gloss; the_document_glossary_section) { writeln(gloss.text); } }
}
{ // bibliography
string[] biblio_unsorted_incomplete = biblio_arr_json.dup;
- Bibliography biblio = Bibliography();
- JSONValue[] biblio_ordered;
- ST_flow_bibliography _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;
- }
- {
- 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); } }
+ ST_biblio_section biblio_section = backmatter_make_the_bibliography_section(biblio_unsorted_incomplete, bib_arr_json);
+ the_document_bibliography_section = biblio_section.bibliography_section;
+ tag_assoc = biblio_section.tag_assoc;
}
{ // bookindex
BookIndexReportSection bi = BookIndexReportSection();
@@ -1722,502 +1133,40 @@ template docAbstraction() {
}
{ // blurb
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_;
+ comp_obj_ = set_object_heading("lev1", "empty", "empty", "(skip) there is no Blurb section");
+ comp_obj_.metainfo.identifier = "";
+ comp_obj_.metainfo.object_number_off = true;
+ comp_obj_.metainfo.object_number_type = 0;
+ comp_obj_.tags.segment_anchor_tag_epub = "";
+ comp_obj_.tags.anchor_tag_html = "";
+ comp_obj_.tags.in_segment_html = "";
+ the_document_blurb_section ~= comp_obj_;
}
debug(blurb) { foreach (blurb; the_document_blurb_section) { writeln(blurb.text); } }
}
{ // toc gather backmatter
- 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 (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);
- }
- }
+ the_document_toc_section ~= backmatter_gather_table_of_contents(the_document_endnotes_section, the_document_glossary_section, the_document_bibliography_section, the_document_bookindex_section, the_document_blurb_section); //
}
{ // 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;
- }
- 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
- ];
- }
- if (obj.metainfo.heading_lev_collapsed == 2) {
- _ancestors_collapsed = [
- _ancestors_collapsed[0],
- _ancestors_collapsed[1],
- 0,0,0,0,0,0
- ];
- }
- if (obj.metainfo.heading_lev_collapsed == 3) {
- _ancestors_collapsed = [
- _ancestors_collapsed[0],
- _ancestors_collapsed[1],
- _ancestors_collapsed[2],
- 0,0,0,0,0
- ];
- }
- if (obj.metainfo.heading_lev_collapsed == 4) {
- _ancestors_collapsed = [
- _ancestors_collapsed[0],
- _ancestors_collapsed[1],
- _ancestors_collapsed[2],
- _ancestors_collapsed[3],
- 0,0,0,0
- ];
- }
- if (obj.metainfo.heading_lev_collapsed == 5) {
- _ancestors_collapsed = [
- _ancestors_collapsed[0],
- _ancestors_collapsed[1],
- _ancestors_collapsed[2],
- _ancestors_collapsed[3],
- _ancestors_collapsed[4],
- 0,0,0
- ];
- }
- if (obj.metainfo.heading_lev_collapsed == 6) {
- _ancestors_collapsed = [
- _ancestors_collapsed[0],
- _ancestors_collapsed[1],
- _ancestors_collapsed[2],
- _ancestors_collapsed[3],
- _ancestors_collapsed[4],
- _ancestors_collapsed[5],
- 0,0
- ];
- }
- if (obj.metainfo.heading_lev_collapsed == 7) {
- _ancestors_collapsed = [
- _ancestors_collapsed[0],
- _ancestors_collapsed[1],
- _ancestors_collapsed[2],
- _ancestors_collapsed[3],
- _ancestors_collapsed[4],
- _ancestors_collapsed[5],
- _ancestors_collapsed[6],
- 0
- ];
- }
- if (obj.metainfo.heading_lev_collapsed == 8) {
- _ancestors_collapsed = [
- _ancestors_collapsed[0],
- _ancestors_collapsed[1],
- _ancestors_collapsed[2],
- _ancestors_collapsed[3],
- _ancestors_collapsed[4],
- _ancestors_collapsed[5],
- _ancestors_collapsed[6],
- _ancestors_collapsed[7]
- ];
- }
- _ancestors_collapsed[obj.metainfo.heading_lev_collapsed] = obj.metainfo.ocn;
- }
- debug(ancestor_collapsed) { writeln("collapsed: ", _ancestors_collapsed); }
- return _ancestors_collapsed;
- }
- // multiple 1~ levels, loop through document body
- if (the_document_body_section.length > 1) {
- int[] _ancestors_markup = [0,0,0,0,0,0,0,0];
- int[][] _ancestors_markup_;
- _ancestors_markup = [1,0,0,0,0,0,0,0];
- _ancestors_markup_ ~= _ancestors_markup;
- int[] _ancestors_collapsed = [0,0,0,0,0,0,0,0];
- int[][] _ancestors_collapsed_;
- _ancestors_collapsed = [1,0,0,0,0,0,0,0];
- _ancestors_collapsed_ ~= _ancestors_collapsed;
- foreach (ref obj; the_document_body_section) {
- if (obj.metainfo.is_a == "heading") {
- obj.metainfo.markedup_ancestors = _get_ancestors_markup(obj, _ancestors_markup);
- obj.metainfo.collapsed_ancestors = _get_ancestors_collapsed(obj, _ancestors_collapsed);
- 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);
- }
- }
- // 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;
- }
- }
- 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;
- }
- }
- 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") {
- 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++;
- }
- 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];
- }
- if (obj.metainfo.heading_lev_markup == 4) {
- obj.ptr.html_segnames = html_segnames_ptr;
- break;
- }
- }
- 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];
- }
- 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;
- }
- }
- }
- 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
- }
- }
- 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_;
- }
- @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",
- )
- );
- }
- debug(images) { writeln("image without dimensions: ", obj.text); }
- }
- 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)
- );
- }
- }
- }
- return obj;
+ { // document ancestors
+ ST_ancestors get_ancestors;
+ get_ancestors = the_document_body_section.after_doc_determine_ancestors(the_document_endnotes_section, the_document_glossary_section, the_document_bibliography_section, the_document_bookindex_section, the_document_blurb_section);
+ the_document_body_section = get_ancestors.the_document_body_section;
+ the_document_endnotes_section = get_ancestors.the_document_endnotes_section;
+ the_document_glossary_section = get_ancestors.the_document_glossary_section;
+ the_document_bibliography_section = get_ancestors.the_document_bibliography_section;
+ the_document_bookindex_section = get_ancestors.the_document_bookindex_section;
+ the_document_blurb_section = get_ancestors.the_document_blurb_section;
+ }
+ { // document segnames
+ ST_segnames get_segnames;
+ get_segnames = the_document_body_section.after_doc_determine_segnames(the_document_endnotes_section, the_document_glossary_section, the_document_bibliography_section, the_document_bookindex_section, the_document_blurb_section, segnames, html_segnames_ptr_cntr, html_segnames_ptr); //
+ segnames = get_segnames.segnames;
+ html_segnames_ptr_cntr = get_segnames.html_segnames_ptr_cntr;
+ html_segnames_ptr = get_segnames.html_segnames_ptr;
}
// document head
string[] segnames_0_to_4;
@@ -2268,6 +1217,8 @@ template docAbstraction() {
obj = _links(obj);
}
}
+ // images
+ string[] _images;
// multiple 1~ levels, loop through document body
if (the_document_body_section.length > 1) {
foreach (ref obj; the_document_body_section) {
@@ -2497,7 +1448,7 @@ template docAbstraction() {
}
// get decendants
if (the_document_body_section.length > 1) {
- auto pairs = get_decendants(
+ auto pairs = after_doc_get_decendants(
the_document_head_section ~
the_document_body_section ~
the_document_endnotes_section ~
@@ -2605,31 +1556,26 @@ template docAbstraction() {
// 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
+ comp_obj_ = set_object_heading("lev1", "empty", "empty", "");
+ comp_obj_.metainfo.identifier = "";
+ comp_obj_.metainfo.dummy_heading = true;
+ comp_obj_.metainfo.object_number_off = true;
+ comp_obj_.metainfo.object_number_type = 0;
+ comp_obj_.tags.segment_anchor_tag_epub = "";
+ comp_obj_.tags.anchor_tag_html = "";
+ comp_obj_.tags.in_segment_html = "";
+ comp_obj_.tags.html_segment_anchor_tag_is = "";
+ comp_obj_.tags.epub_segment_anchor_tag_is = "";
+ comp_obj_.metainfo.heading_lev_markup = 9;
+ comp_obj_.metainfo.heading_lev_collapsed = 9;
+ comp_obj_.metainfo.parent_ocn = 0;
+ comp_obj_.metainfo.parent_lev_markup = 0;
+ comp_obj_.metainfo.dom_structure_markedup_tags_status = dom_structure_markedup_tags_status.dup;
+ comp_obj_.metainfo.dom_structure_collapsed_tags_status = dom_structure_collapsed_tags_status.dup;
+ comp_obj_ = comp_obj_.obj_dom_structure_set_markup_tags(dom_structure_markedup_tags_status, 0);
+ comp_obj_ = comp_obj_.obj_dom_set_collapsed_tags(dom_structure_collapsed_tags_status, 0);
+ comp_obj_ = comp_obj_.obj_heading_ancestors(lv_ancestors_txt);
+ // the_dom_tail_section ~= comp_obj_; // remove tail for now, decide on later
// the doc
ObjGenericComposite[][string] document_the = [
"head": the_document_head_section,
@@ -2783,6 +1729,254 @@ template docAbstraction() {
}
return ret;
} // ← closed: abstract doc source
+ @safe pure ObjGenericComposite obj_heading_ancestors()(
+ ObjGenericComposite obj,
+ string[] lv_ancestors_txt,
+ ) {
+ switch (obj.metainfo.heading_lev_markup) {
+ case 0:
+ lv_ancestors_txt[0] = obj.text.to!string;
+ foreach(k; 1..8) { lv_ancestors_txt[k] = ""; }
+ goto default;
+ case 1:
+ lv_ancestors_txt[1] = obj.text.to!string;
+ foreach(k; 2..8) { lv_ancestors_txt[k] = ""; }
+ goto default;
+ case 2:
+ lv_ancestors_txt[2] = obj.text.to!string;
+ foreach(k; 3..8) { lv_ancestors_txt[k] = ""; }
+ goto default;
+ case 3:
+ lv_ancestors_txt[3] = obj.text.to!string;
+ foreach(k; 4..8) { lv_ancestors_txt[k] = ""; }
+ goto default;
+ case 4:
+ lv_ancestors_txt[4] = obj.text.to!string;
+ foreach(k; 5..8) { lv_ancestors_txt[k] = ""; }
+ goto default;
+ case 5:
+ lv_ancestors_txt[5] = obj.text.to!string;
+ foreach(k; 6..8) { lv_ancestors_txt[k] = ""; }
+ goto default;
+ case 6:
+ lv_ancestors_txt[6] = obj.text.to!string;
+ lv_ancestors_txt[7] = "";
+ goto default;
+ case 7:
+ lv_ancestors_txt[7] = obj.text.to!string;
+ goto default;
+ default:
+ obj.tags.heading_ancestors_text = lv_ancestors_txt.dup;
+ }
+ return obj;
+ }
+ @safe pure ObjGenericComposite obj_dom_structure_set_markup_tags()(
+ ObjGenericComposite obj,
+ int[] dom,
+ int lev
+ ) {
+ foreach (i; 0 .. 8) {
+ if (i < lev) {
+ if (dom[i] == DomTags.open
+ || dom[i] == DomTags.close_and_open
+ ) {
+ dom[i] = DomTags.open_still;
+ } else if (dom[i] == DomTags.close) {
+ dom[i] = DomTags.none;
+ }
+ } else if (i == lev) {
+ if (lev == 0
+ && dom[i] == DomTags.open_still
+ ) {
+ dom[i] = DomTags.close;
+ } else if (dom[i] == DomTags.open
+ || dom[i] == DomTags.open_still
+ || dom[i] == DomTags.close_and_open
+ ) {
+ dom[i] = DomTags.close_and_open;
+ } else {
+ dom[i] = DomTags.open;
+ }
+ } else if (i > lev) {
+ if (dom[i] == DomTags.close) {
+ dom[i] = DomTags.none;
+ } else if (dom[i] == DomTags.open
+ || dom[i] == DomTags.open_still
+ || dom[i] == DomTags.close_and_open
+ ) {
+ dom[i] = DomTags.close;
+ }
+ }
+ }
+ debug(dom_magic_numbers) { writeln("marked up: ", lev, ": ", dom); }
+ obj.metainfo.dom_structure_markedup_tags_status = dom.dup;
+ return obj;
+ }
+ @safe pure ObjGenericComposite obj_dom_set_collapsed_tags()(
+ ObjGenericComposite obj,
+ int[] dom,
+ int lev
+ ) {
+ foreach (i; 0 .. 8) {
+ if (i < lev) {
+ if (dom[i] == DomTags.open
+ || dom[i] == DomTags.close_and_open
+ ) {
+ dom[i] = DomTags.open_still;
+ } else if (dom[i] == DomTags.close) {
+ dom[i] = DomTags.none;
+ }
+ } else if (i == lev) {
+ if (lev == 0
+ && dom[i] == DomTags.open_still
+ ) {
+ dom[i] = DomTags.close;
+ } else if (dom[i] == DomTags.open
+ || dom[i] == DomTags.open_still
+ || dom[i] == DomTags.close_and_open
+ ) {
+ dom[i] = DomTags.close_and_open;
+ } else {
+ dom[i] = DomTags.open;
+ }
+ } else if (i > lev) {
+ if (dom[i] == DomTags.close) {
+ dom[i] = DomTags.none;
+ } else if (dom[i] == DomTags.open
+ || dom[i] == DomTags.open_still
+ || dom[i] == DomTags.close_and_open
+ ) {
+ dom[i] = DomTags.close;
+ }
+ }
+ }
+ debug(dom_magic_numbers) { writeln("collapsed: ", lev, ": ", dom); }
+ obj.metainfo.dom_structure_collapsed_tags_status = dom.dup;
+ return obj;
+ }
+ @safe static OCNset ocn_emit(int ocn_status_flag) {
+ return object_citation_number.ocn_emitter(ocn_status_flag);
+ }
+ @safe auto inline_markup_faces(L)(L line) {
+ static auto rgx = RgxI();
+ static auto mkup = InlineMarkup();
+ line = replaceAll!(m => mkup.quote_o ~ m[1] ~ mkup.quote_c)(line, rgx.within_quotes);
+ line = replaceAll!(m => mkup.ff_i ~ mkup.mono ~ mkup.ff_o ~ m["text"] ~ mkup.ff_c ~ mkup.mono)(line, rgx.inline_mark_mono);
+ line = replaceAll!(m => mkup.ff_i ~ mkup.cite ~ mkup.ff_o ~ m["text"] ~ mkup.ff_c ~ mkup.cite)(line, rgx.inline_mark_cite);
+ foreach (regx; [rgx.inline_mark_emphasis, rgx.inline_mark_bold, rgx.inline_mark_underscore, rgx.inline_mark_italics, rgx.inline_mark_superscript, rgx.inline_mark_subscript, rgx.inline_mark_strike, rgx.inline_mark_insert]) {
+ line = replaceAll!(m => mkup.ff_i ~ m["mark"] ~ mkup.ff_o ~ m["text"] ~ mkup.ff_c ~ m["mark"])(line, regx);
+ }
+ return line;
+ }
+ @safe static string links_and_images()(string obj_txt) {
+ static auto rgx = RgxI();
+ static auto mkup = InlineMarkup();
+ if (obj_txt.match(rgx.smid_inline_url_generic)) {
+ if (
+ obj_txt.match(rgx.smid_inline_link_endnote_url_helper)
+ || obj_txt.match(rgx.smid_inline_link_endnote_url_helper_punctuated)
+ ) {
+ obj_txt = replaceAll!(m => format("%s%s%s%s%s%s%s %s%s%s%s%s%s %s%s",
+ mkup.lnk_o, m["content"].strip, mkup.lnk_c,
+ mkup.url_o, m["link"], mkup.url_c,
+ mkup.en_a_o,
+ mkup.lnk_o, m["link"].strip, mkup.lnk_c,
+ mkup.url_o, m["link"], mkup.url_c,
+ mkup.en_a_c,
+ m[3]
+ ))(obj_txt, rgx.smid_inline_link_endnote_url_helper_punctuated);
+ obj_txt = replaceAll!(m => format("%s%s%s%s%s%s%s %s%s%s%s%s%s %s",
+ mkup.lnk_o, m["content"].strip, mkup.lnk_c,
+ mkup.url_o, m["link"], mkup.url_c,
+ mkup.en_a_o,
+ mkup.lnk_o, m["link"].strip, mkup.lnk_c,
+ mkup.url_o, m["link"], mkup.url_c,
+ mkup.en_a_c
+ ))(obj_txt, rgx.smid_inline_link_endnote_url_helper);
+ } else {
+ obj_txt = replaceAll!(m => format("%s%s%s%s%s%s%s",
+ m["pre"],
+ mkup.lnk_o, m["content"].strip, mkup.lnk_c,
+ mkup.url_o, m["link"], mkup.url_c
+ ))(obj_txt, rgx.smid_inline_link_markup_regular);
+ }
+ obj_txt = replaceAll!(m => format("%s%s%s%s%s%s%s",
+ m["pre"],
+ mkup.lnk_o, m["link"].strip, mkup.lnk_c,
+ mkup.url_o, m["link"], mkup.url_c
+ ))(obj_txt, rgx.smid_inline_link_naked_url); //
+ }
+ return obj_txt;
+ }
+ // ↓ abstraction struct init
+ @safe static auto eN() {
+ struct _e {
+ enum bi {
+ off,
+ on,
+ }
+ enum ocn {
+ off,
+ on,
+ closing,
+ bkidx,
+ reset,
+ }
+ enum sect {
+ unset,
+ head,
+ toc,
+ substantive,
+ bibliography,
+ glossary,
+ book_index,
+ blurb,
+ }
+ enum txt_is {
+ off,
+ para,
+ heading,
+ }
+ enum blk_is {
+ off,
+ code,
+ poem,
+ block,
+ group,
+ table,
+ quote,
+ }
+ enum blk_state {
+ off,
+ on,
+ closing,
+ }
+ enum blk_delim {
+ off,
+ curly,
+ tic,
+ curly_special,
+ tic_special,
+ }
+ }
+ return _e();
+ }
+ @safe string[string][string] inline_para_link_anchor()(
+ string[string] an_object,
+ string[string] tag_in_seg,
+ string[string][string] tag_assoc
+ ) {
+ static auto rgx = RgxI();
+ if (auto m = an_object["substantive"].match(rgx.inline_link_anchor)) {
+ if (m.captures[1] !in tag_assoc) {
+ tag_assoc[(m.captures[1])]["seg_lv4"] = tag_in_seg["seg_lv4"];
+ tag_assoc[(m.captures[1])]["seg_lv1to4"] = tag_in_seg["seg_lv1to4"];
+ } else {
+ writeln("a tag named already exists, check text line\n ", an_object["substantive"]);
+ }
+ }
+ return tag_assoc;
+ }
@system ST_txt_by_line_common_reset txt_by_line_common_reset_()(
int[string] line_occur,
string[string] an_object,
@@ -2800,6 +1994,215 @@ template docAbstraction() {
}
return ret;
}
+ ST_the_section build_the_glossary_section(
+ char[] line, // line is immutable, not necessary to return unchanged
+ uint[string] pith,
+ string[string][string] tag_assoc, // only for headings: html & epub
+ ) {
+ static auto rgx = RgxI();
+ ObjGenericComposite comp_obj_;
+ ObjGenericComposite[] add_to_current_document_section;
+ 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";
+ ST_the_section ret;
+ if (line.matchFirst(rgx.heading_glossary)) {
+ {
+ comp_obj_ = set_object_heading("lev1", "backmatter", "glossary", "Glossary");
+ comp_obj_.metainfo.identifier = "";
+ comp_obj_.metainfo.dummy_heading = false;
+ comp_obj_.metainfo.object_number_off = false;
+ comp_obj_.metainfo.object_number_type = 0;
+ comp_obj_.tags.segment_anchor_tag_epub = "_part_glossary";
+ comp_obj_.tags.anchor_tag_html = comp_obj_.tags.segment_anchor_tag_epub;
+ comp_obj_.tags.in_segment_html = "glossary";
+ comp_obj_.tags.anchor_tags = ["section_glossary"];
+ comp_obj_.metainfo.dom_structure_markedup_tags_status = [ 1, 1, 0, 0, 0, 0, 0, 0];
+ comp_obj_.metainfo.dom_structure_collapsed_tags_status = [ 1, 1, 0, 0, 0, 0, 0, 0];
+ add_to_current_document_section ~= comp_obj_; //
+ tag_assoc[comp_obj_.tags.anchor_tag_html]["seg_lv4"] = comp_obj_.tags.in_segment_html;
+ tag_assoc[comp_obj_.tags.segment_anchor_tag_epub]["seg_lv1to4"] = comp_obj_.tags.segment_anchor_tag_epub;
+ } {
+ comp_obj_ = set_object_heading("lev4", "backmatter", "glossary", "Glossary");
+ comp_obj_.metainfo.identifier = "";
+ comp_obj_.metainfo.dummy_heading = true;
+ comp_obj_.metainfo.object_number_off = true;
+ comp_obj_.metainfo.object_number_type = 0;
+ comp_obj_.tags.segment_anchor_tag_epub = "glossary";
+ comp_obj_.tags.anchor_tag_html = comp_obj_.tags.segment_anchor_tag_epub;
+ comp_obj_.tags.in_segment_html = comp_obj_.tags.anchor_tag_html;
+ comp_obj_.metainfo.heading_lev_collapsed = 2;
+ comp_obj_.tags.anchor_tags = ["glossary"];
+ add_to_current_document_section ~= comp_obj_; //
+ tag_assoc[comp_obj_.tags.anchor_tag_html]["seg_lv4"] = comp_obj_.tags.in_segment_html;
+ tag_assoc[comp_obj_.tags.segment_anchor_tag_epub]["seg_lv1to4"] = comp_obj_.tags.segment_anchor_tag_epub;
+ pith["ocn"] = eN.ocn.on;
+ }
+ {
+ ret.comp_section_obj ~= add_to_current_document_section;
+ ret.pith = pith;
+ ret.tag_assoc = tag_assoc; // only for headings: html & epub
+ }
+ } else { // 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;
+ }
+ }
+ comp_obj_ = set_object_generic("backmatter", "glossary", "para", "glossary", links_and_images(line.to!string.strip).replaceFirst(rgx.para_attribs, ""), 0);
+ comp_obj_.metainfo.identifier = "";
+ comp_obj_.metainfo.object_number_off = true;
+ comp_obj_.metainfo.object_number_type = 0;
+ comp_obj_.attrib.indent_hang = indent["hang_position"];
+ comp_obj_.attrib.indent_base = indent["base_position"];
+ comp_obj_.attrib.bullet = bullet;
+ add_to_current_document_section ~= comp_obj_; //
+ pith["ocn"] = eN.ocn.on;
+ {
+ ret.comp_section_obj = add_to_current_document_section;
+ ret.pith = pith;
+ ret.tag_assoc = tag_assoc; // NO CHANGE here, only for headings: html & epub
+ }
+ }
+ return ret;
+ }
+ ST_the_section build_the_blurb_section(Opt) (
+ char[] line, // line is immutable, not necessary to return unchanged
+ uint[string] pith,
+ string[string][string] tag_assoc, // only for headings: html & epub
+ Opt opt_action,
+ ) {
+ static auto rgx = RgxI();
+ ObjGenericComposite comp_obj_;
+ ObjGenericComposite[] add_to_current_document_section;
+ // assert (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" : (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";
+ ST_the_section ret;
+ if (line.matchFirst(rgx.heading_blurb)
+ && (opt_action.backmatter && opt_action.section_blurb)) {
+ {
+ comp_obj_ = set_object_heading("lev1", "backmatter", "blurb", "Blurb");
+ comp_obj_.metainfo.identifier = "";
+ comp_obj_.metainfo.dummy_heading = false;
+ comp_obj_.metainfo.object_number_off = false;
+ comp_obj_.metainfo.object_number_type = 0;
+ comp_obj_.tags.segment_anchor_tag_epub = "_part_blurb";
+ comp_obj_.tags.anchor_tag_html = comp_obj_.tags.segment_anchor_tag_epub;
+ comp_obj_.tags.in_segment_html = "blurb";
+ comp_obj_.tags.anchor_tags = ["section_blurb"];
+ comp_obj_.metainfo.dom_structure_markedup_tags_status = [ 1, 1, 0, 0, 0, 0, 0, 0];
+ comp_obj_.metainfo.dom_structure_collapsed_tags_status = [ 1, 1, 0, 0, 0, 0, 0, 0];
+ add_to_current_document_section ~= comp_obj_;
+ tag_assoc[comp_obj_.tags.anchor_tag_html]["seg_lv4"] = comp_obj_.tags.in_segment_html;
+ tag_assoc[comp_obj_.tags.segment_anchor_tag_epub]["seg_lv1to4"] = comp_obj_.tags.segment_anchor_tag_epub;
+ }
+ {
+ comp_obj_ = set_object_heading("lev4", "backmatter", "blurb", "Blurb");
+ comp_obj_.metainfo.identifier = "";
+ comp_obj_.metainfo.dummy_heading = true;
+ comp_obj_.metainfo.object_number_off = true;
+ comp_obj_.metainfo.object_number_type = 0;
+ comp_obj_.tags.segment_anchor_tag_epub = "blurb";
+ comp_obj_.tags.anchor_tag_html = comp_obj_.tags.segment_anchor_tag_epub;
+ comp_obj_.tags.in_segment_html = comp_obj_.tags.anchor_tag_html;
+ comp_obj_.metainfo.heading_lev_collapsed = 2;
+ comp_obj_.tags.anchor_tags = ["blurb"];
+ add_to_current_document_section ~= comp_obj_;
+ tag_assoc[comp_obj_.tags.anchor_tag_html]["seg_lv4"] = comp_obj_.tags.in_segment_html;
+ tag_assoc[comp_obj_.tags.segment_anchor_tag_epub]["seg_lv1to4"] = comp_obj_.tags.segment_anchor_tag_epub;
+ }
+ } else if (line.matchFirst(rgx.headings)
+ && (opt_action.backmatter && opt_action.section_blurb)) {
+ comp_obj_ = comp_obj_.init;
+ comp_obj_.metainfo.is_of_part = "backmatter";
+ comp_obj_.metainfo.is_of_section = "blurb";
+ comp_obj_.metainfo.is_of_type = "para";
+ comp_obj_.metainfo.is_a = "heading";
+ comp_obj_.text = line.to!string;
+ comp_obj_.metainfo.ocn = 0;
+ comp_obj_.metainfo.identifier = "";
+ comp_obj_.metainfo.dummy_heading = false;
+ comp_obj_.metainfo.object_number_off = true;
+ comp_obj_.metainfo.object_number_type = 0;
+ comp_obj_.tags.segment_anchor_tag_epub = "blurb";
+ comp_obj_.tags.anchor_tag_html = comp_obj_.tags.segment_anchor_tag_epub;
+ comp_obj_.tags.in_segment_html = comp_obj_.tags.anchor_tag_html;
+ comp_obj_.metainfo.heading_lev_markup = an_object["lev_markup_number"].to!int; // make int, remove need to conv
+ comp_obj_.metainfo.heading_lev_collapsed = an_object["lev_collapsed_number"].to!int; // make int, remove need to conv
+ comp_obj_.metainfo.parent_ocn = 1;
+ comp_obj_.metainfo.parent_lev_markup = 0;
+ add_to_current_document_section ~= comp_obj_;
+ tag_assoc[comp_obj_.tags.anchor_tag_html]["seg_lv4"] = comp_obj_.tags.in_segment_html;
+ tag_assoc[comp_obj_.tags.segment_anchor_tag_epub]["seg_lv1to4"] = comp_obj_.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);
+ {
+ 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_ = set_object_generic("backmatter", "blurb", "para", "blurb", links_and_images(line.to!string.strip).replaceFirst(rgx.para_attribs, ""), 0);
+ comp_obj_.metainfo.identifier = "";
+ comp_obj_.metainfo.object_number_off = true;
+ comp_obj_.metainfo.object_number_type = 0;
+ comp_obj_.attrib.indent_hang = indent["hang_position"];
+ comp_obj_.attrib.indent_base = indent["base_position"];
+ comp_obj_.has.inline_links = true;
+ comp_obj_.attrib.bullet = bullet;
+ add_to_current_document_section ~= comp_obj_;
+ }
+ pith["ocn"] = eN.ocn.on;
+ {
+ ret.comp_section_obj = add_to_current_document_section;
+ ret.pith = pith;
+ ret.tag_assoc = tag_assoc; // NO CHANGE here, only for headings: html & epub
+ }
+ return ret;
+ }
@safe ST_txt_by_line_block_start txt_by_line_block_start()(
char[] line,
uint[string] pith,
@@ -3079,23 +2482,17 @@ template docAbstraction() {
= 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_block = comp_obj_block.init;
- comp_obj_block.metainfo.is_of_part = "body";
- comp_obj_block.metainfo.is_of_section = "body";
- comp_obj_block.metainfo.is_of_type = "block";
- comp_obj_block.metainfo.is_a = "verse";
- comp_obj_block.metainfo.ocn = obj_cite_digits.object_number;
- comp_obj_block.metainfo.identifier = obj_cite_digits.identifier;
- comp_obj_block.metainfo.object_number_off = obj_cite_digits.off;
- comp_obj_block.metainfo.o_n_book_index = obj_cite_digits.bkidx;
- comp_obj_block.metainfo.object_number_type = obj_cite_digits.type;
- comp_obj_block.tags.html_segment_anchor_tag_is = tag_in_seg["seg_lv4"];
- comp_obj_block.tags.epub_segment_anchor_tag_is = tag_in_seg["seg_lv1to4"];
- comp_obj_block.text = an_object["substantive"];
- comp_obj_block.has.inline_notes_reg = substantive_obj_misc_struct.has_notes_reg;
- comp_obj_block.has.inline_notes_star = substantive_obj_misc_struct.has_notes_star;
- comp_obj_block.has.inline_links = substantive_obj_misc_struct.has_links;
- the_document_body_section ~= comp_obj_block;
+ comp_obj_ = set_object_generic("body", "body", "block", "verse", an_object["substantive"], obj_cite_digits.object_number);
+ comp_obj_.metainfo.identifier = obj_cite_digits.identifier;
+ comp_obj_.metainfo.object_number_off = obj_cite_digits.off;
+ comp_obj_.metainfo.o_n_book_index = obj_cite_digits.bkidx;
+ comp_obj_.metainfo.object_number_type = obj_cite_digits.type;
+ comp_obj_.tags.html_segment_anchor_tag_is = tag_in_seg["seg_lv4"];
+ comp_obj_.tags.epub_segment_anchor_tag_is = tag_in_seg["seg_lv1to4"];
+ comp_obj_.has.inline_notes_reg = substantive_obj_misc_struct.has_notes_reg;
+ comp_obj_.has.inline_notes_star = substantive_obj_misc_struct.has_notes_star;
+ comp_obj_.has.inline_links = substantive_obj_misc_struct.has_links;
+ the_document_body_section ~= comp_obj_;
tag_assoc = an_object.inline_para_link_anchor(tag_in_seg, tag_assoc);
}
object_reset(an_object);
@@ -3141,23 +2538,17 @@ template docAbstraction() {
= 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_block = comp_obj_block.init;
- comp_obj_block.metainfo.is_of_part = "body";
- comp_obj_block.metainfo.is_of_section = "body";
- comp_obj_block.metainfo.is_of_type = "block";
- comp_obj_block.metainfo.is_a = "verse";
- comp_obj_block.metainfo.ocn = obj_cite_digits.object_number;
- comp_obj_block.metainfo.identifier = obj_cite_digits.identifier;
- comp_obj_block.metainfo.object_number_off = obj_cite_digits.off;
- comp_obj_block.metainfo.o_n_book_index = obj_cite_digits.bkidx;
- comp_obj_block.metainfo.object_number_type = obj_cite_digits.type;
- comp_obj_block.tags.html_segment_anchor_tag_is = tag_in_seg["seg_lv4"];
- comp_obj_block.tags.epub_segment_anchor_tag_is = tag_in_seg["seg_lv1to4"];
- comp_obj_block.text = an_object["substantive"];
- comp_obj_block.has.inline_notes_reg = substantive_obj_misc_struct.has_notes_reg;
- comp_obj_block.has.inline_notes_star = substantive_obj_misc_struct.has_notes_star;
- comp_obj_block.has.inline_links = substantive_obj_misc_struct.has_links;
- the_document_body_section ~= comp_obj_block;
+ comp_obj_ = set_object_generic("body", "body", "block", "verse", an_object["substantive"], obj_cite_digits.object_number);
+ comp_obj_.metainfo.identifier = obj_cite_digits.identifier;
+ comp_obj_.metainfo.object_number_off = obj_cite_digits.off;
+ comp_obj_.metainfo.o_n_book_index = obj_cite_digits.bkidx;
+ comp_obj_.metainfo.object_number_type = obj_cite_digits.type;
+ comp_obj_.tags.html_segment_anchor_tag_is = tag_in_seg["seg_lv4"];
+ comp_obj_.tags.epub_segment_anchor_tag_is = tag_in_seg["seg_lv1to4"];
+ comp_obj_.has.inline_notes_reg = substantive_obj_misc_struct.has_notes_reg;
+ comp_obj_.has.inline_notes_star = substantive_obj_misc_struct.has_notes_star;
+ comp_obj_.has.inline_links = substantive_obj_misc_struct.has_links;
+ the_document_body_section ~= comp_obj_;
tag_assoc = an_object.inline_para_link_anchor(tag_in_seg, tag_assoc);
object_reset(an_object);
processing.remove("verse");
@@ -3179,23 +2570,17 @@ template docAbstraction() {
= 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_block = comp_obj_block.init;
- comp_obj_block.metainfo.is_of_part = "body";
- comp_obj_block.metainfo.is_of_section = "body";
- comp_obj_block.metainfo.is_of_type = "block";
- comp_obj_block.metainfo.is_a = "verse";
- comp_obj_block.metainfo.ocn = obj_cite_digits.object_number;
- comp_obj_block.metainfo.identifier = obj_cite_digits.identifier;
- comp_obj_block.metainfo.object_number_off = obj_cite_digits.off;
- comp_obj_block.metainfo.o_n_book_index = obj_cite_digits.bkidx;
- comp_obj_block.metainfo.object_number_type = obj_cite_digits.type;
- comp_obj_block.tags.html_segment_anchor_tag_is = tag_in_seg["seg_lv4"];
- comp_obj_block.tags.epub_segment_anchor_tag_is = tag_in_seg["seg_lv1to4"];
- comp_obj_block.text = an_object["substantive"];
- comp_obj_block.has.inline_notes_reg = substantive_obj_misc_struct.has_notes_reg;
- comp_obj_block.has.inline_notes_star = substantive_obj_misc_struct.has_notes_star;
- comp_obj_block.has.inline_links = substantive_obj_misc_struct.has_links;
- the_document_body_section ~= comp_obj_block;
+ comp_obj_ = set_object_generic("body", "body", "block", "verse", an_object["substantive"], obj_cite_digits.object_number);
+ comp_obj_.metainfo.identifier = obj_cite_digits.identifier;
+ comp_obj_.metainfo.object_number_off = obj_cite_digits.off;
+ comp_obj_.metainfo.o_n_book_index = obj_cite_digits.bkidx;
+ comp_obj_.metainfo.object_number_type = obj_cite_digits.type;
+ comp_obj_.tags.html_segment_anchor_tag_is = tag_in_seg["seg_lv4"];
+ comp_obj_.tags.epub_segment_anchor_tag_is = tag_in_seg["seg_lv1to4"];
+ comp_obj_.has.inline_notes_reg = substantive_obj_misc_struct.has_notes_reg;
+ comp_obj_.has.inline_notes_star = substantive_obj_misc_struct.has_notes_star;
+ comp_obj_.has.inline_links = substantive_obj_misc_struct.has_links;
+ the_document_body_section ~= comp_obj_;
tag_assoc = an_object.inline_para_link_anchor(tag_in_seg, tag_assoc);
object_number_poem["end"] = obj_cite_digits.object_number.to!string;
object_reset(an_object);
@@ -3241,23 +2626,17 @@ template docAbstraction() {
= 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_block = comp_obj_block.init;
- comp_obj_block.metainfo.is_of_part = "body";
- comp_obj_block.metainfo.is_of_section = "body";
- comp_obj_block.metainfo.is_of_type = "block";
- comp_obj_block.metainfo.is_a = "verse";
- comp_obj_block.metainfo.ocn = obj_cite_digits.object_number;
- comp_obj_block.metainfo.identifier = obj_cite_digits.identifier;
- comp_obj_block.metainfo.object_number_off = obj_cite_digits.off;
- comp_obj_block.metainfo.o_n_book_index = obj_cite_digits.bkidx;
- comp_obj_block.metainfo.object_number_type = obj_cite_digits.type;
- comp_obj_block.tags.html_segment_anchor_tag_is = tag_in_seg["seg_lv4"];
- comp_obj_block.tags.epub_segment_anchor_tag_is = tag_in_seg["seg_lv1to4"];
- comp_obj_block.text = an_object["substantive"];
- comp_obj_block.has.inline_notes_reg = substantive_obj_misc_struct.has_notes_reg;
- comp_obj_block.has.inline_notes_star = substantive_obj_misc_struct.has_notes_star;
- comp_obj_block.has.inline_links = substantive_obj_misc_struct.has_links;
- the_document_body_section ~= comp_obj_block;
+ comp_obj_ = set_object_generic("body", "body", "block", "verse", an_object["substantive"], obj_cite_digits.object_number);
+ comp_obj_.metainfo.identifier = obj_cite_digits.identifier;
+ comp_obj_.metainfo.object_number_off = obj_cite_digits.off;
+ comp_obj_.metainfo.o_n_book_index = obj_cite_digits.bkidx;
+ comp_obj_.metainfo.object_number_type = obj_cite_digits.type;
+ comp_obj_.tags.html_segment_anchor_tag_is = tag_in_seg["seg_lv4"];
+ comp_obj_.tags.epub_segment_anchor_tag_is = tag_in_seg["seg_lv1to4"];
+ comp_obj_.has.inline_notes_reg = substantive_obj_misc_struct.has_notes_reg;
+ comp_obj_.has.inline_notes_star = substantive_obj_misc_struct.has_notes_star;
+ comp_obj_.has.inline_links = substantive_obj_misc_struct.has_links;
+ the_document_body_section ~= comp_obj_;
tag_assoc = an_object.inline_para_link_anchor(tag_in_seg, tag_assoc);
object_reset(an_object);
processing.remove("verse");
@@ -3344,7 +2723,7 @@ template docAbstraction() {
an_object,
the_document_body_section,
obj_cite_digits,
- comp_obj_heading,
+ comp_obj_,
cntr,
pith,
conf_make_meta,
@@ -3353,7 +2732,7 @@ template docAbstraction() {
an_object = _get.this_object;
the_document_body_section = _get.the_document_body_section;
obj_cite_digits = _get.obj_cite_digits;
- comp_obj_heading = _get._comp_obj_heading;
+ comp_obj_ = _get.comp_obj_;
cntr = _get.cntr;
pith = _get.pith;
}
@@ -3624,12 +3003,12 @@ template docAbstraction() {
string[string] an_object,
ObjGenericComposite[] the_document_body_section,
OCNset obj_cite_digits,
- ObjGenericComposite _comp_obj_heading,
+ ObjGenericComposite comp_obj_,
int cntr,
uint[string] pith,
CMM conf_make_meta
) {
- comp_obj_block = comp_obj_block.init;
+ comp_obj_ = comp_obj_.init;
obj_cite_digits = ocn_emit(pith["ocn"]);
auto comp_obj_location = node_construct.node_location_emitter(
content_non_header,
@@ -3645,22 +3024,22 @@ template docAbstraction() {
ST_txtAndAnchorTagPlusHasFootnotesUrlsImages substantive_obj_misc_struct
= obj_im.obj_inline_markup_and_anchor_tags_and_misc(an_object, "body_nugget", conf_make_meta, No._new_doc);
an_object["substantive"] = substantive_obj_misc_struct.obj_txt;
- comp_obj_block.metainfo.ocn = obj_cite_digits.object_number;
- comp_obj_block.metainfo.identifier = obj_cite_digits.identifier;
- comp_obj_block.metainfo.object_number_off = obj_cite_digits.off;
- comp_obj_block.tags.html_segment_anchor_tag_is = tag_in_seg["seg_lv4"];
- comp_obj_block.tags.epub_segment_anchor_tag_is = tag_in_seg["seg_lv1to4"];
- comp_obj_block.metainfo.o_n_book_index = obj_cite_digits.bkidx;
- comp_obj_block.metainfo.object_number_type = obj_cite_digits.type;
- comp_obj_block = comp_obj_block.flow_table_instructions(an_object["table_head"]);
+ comp_obj_.metainfo.ocn = obj_cite_digits.object_number;
+ comp_obj_.metainfo.identifier = obj_cite_digits.identifier;
+ comp_obj_.metainfo.object_number_off = obj_cite_digits.off;
+ comp_obj_.tags.html_segment_anchor_tag_is = tag_in_seg["seg_lv4"];
+ comp_obj_.tags.epub_segment_anchor_tag_is = tag_in_seg["seg_lv1to4"];
+ comp_obj_.metainfo.o_n_book_index = obj_cite_digits.bkidx;
+ comp_obj_.metainfo.object_number_type = obj_cite_digits.type;
+ comp_obj_ = comp_obj_.flow_table_instructions(an_object["table_head"]);
{
- auto _get = comp_obj_block.flow_table_substantive_munge_special(an_object["substantive"]);
+ auto _get = comp_obj_.flow_table_substantive_munge_special(an_object["substantive"]);
{
- comp_obj_block = _get.table_object;
+ comp_obj_ = _get.table_object;
an_object["substantive"] = _get.table_substantive;
}
}
- the_document_body_section ~= comp_obj_block;
+ the_document_body_section ~= comp_obj_;
object_reset(an_object);
processing.remove("verse");
++cntr;
@@ -3669,7 +3048,7 @@ template docAbstraction() {
ret.this_object = an_object;
ret.the_document_body_section = the_document_body_section;
ret.obj_cite_digits = obj_cite_digits;
- ret._comp_obj_heading = _comp_obj_heading;
+ ret.comp_obj_ = comp_obj_;
ret.cntr = cntr;
ret.pith = pith;
}
@@ -3682,7 +3061,7 @@ template docAbstraction() {
ObjGenericComposite[] the_document_body_section,
string[][string][string] bookindex_unordered_hashes,
OCNset obj_cite_digits,
- ObjGenericComposite _comp_obj_heading,
+ ObjGenericComposite comp_obj_,
int cntr,
uint[string] pith,
string[string] object_number_poem,
@@ -3726,25 +3105,19 @@ template docAbstraction() {
= 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_block = comp_obj_block.init;
- comp_obj_block.metainfo.is_of_part = "body";
- comp_obj_block.metainfo.is_of_section = "body";
- comp_obj_block.metainfo.is_of_type = "block";
- comp_obj_block.metainfo.is_a = "quote";
- comp_obj_block.metainfo.ocn = obj_cite_digits.object_number;
- comp_obj_block.metainfo.identifier = obj_cite_digits.identifier;
- comp_obj_block.metainfo.object_number_off = obj_cite_digits.off;
- comp_obj_block.metainfo.o_n_book_index = obj_cite_digits.bkidx;
- comp_obj_block.metainfo.object_number_type = obj_cite_digit_type;
- comp_obj_block.metainfo.lang = an_object["lang"];
- comp_obj_block.metainfo.attrib = an_object["attrib"];
- comp_obj_block.tags.html_segment_anchor_tag_is = tag_in_seg["seg_lv4"];
- comp_obj_block.tags.epub_segment_anchor_tag_is = tag_in_seg["seg_lv1to4"];
- comp_obj_block.text = an_object["substantive"];
- comp_obj_block.has.inline_notes_reg = substantive_obj_misc_struct.has_notes_reg;
- comp_obj_block.has.inline_notes_star = substantive_obj_misc_struct.has_notes_star;
- comp_obj_block.has.inline_links = substantive_obj_misc_struct.has_links;
- the_document_body_section ~= comp_obj_block;
+ comp_obj_ = set_object_generic("body", "body", "block", "quote", an_object["substantive"], obj_cite_digits.object_number);
+ comp_obj_.metainfo.identifier = obj_cite_digits.identifier;
+ comp_obj_.metainfo.object_number_off = obj_cite_digits.off;
+ comp_obj_.metainfo.o_n_book_index = obj_cite_digits.bkidx;
+ comp_obj_.metainfo.object_number_type = obj_cite_digit_type;
+ comp_obj_.metainfo.lang = an_object["lang"];
+ comp_obj_.metainfo.attrib = an_object["attrib"];
+ comp_obj_.tags.html_segment_anchor_tag_is = tag_in_seg["seg_lv4"];
+ comp_obj_.tags.epub_segment_anchor_tag_is = tag_in_seg["seg_lv1to4"];
+ comp_obj_.has.inline_notes_reg = substantive_obj_misc_struct.has_notes_reg;
+ comp_obj_.has.inline_notes_star = substantive_obj_misc_struct.has_notes_star;
+ comp_obj_.has.inline_links = substantive_obj_misc_struct.has_links;
+ the_document_body_section ~= comp_obj_;
tag_assoc = an_object.inline_para_link_anchor(tag_in_seg, tag_assoc);
pith["block_is"] = eN.blk_is.quote;
pith["block_state"] = eN.blk_state.off;
@@ -3778,25 +3151,19 @@ template docAbstraction() {
= 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_block = comp_obj_block.init;
- comp_obj_block.metainfo.is_of_part = "body";
- comp_obj_block.metainfo.is_of_section = "body";
- comp_obj_block.metainfo.is_of_type = "block";
- comp_obj_block.metainfo.is_a = "group";
- comp_obj_block.metainfo.ocn = obj_cite_digits.object_number;
- comp_obj_block.metainfo.identifier = obj_cite_digits.identifier;
- comp_obj_block.metainfo.object_number_off = obj_cite_digits.off;
- comp_obj_block.metainfo.o_n_book_index = obj_cite_digits.bkidx;
- comp_obj_block.metainfo.object_number_type = obj_cite_digits.type;
- comp_obj_block.metainfo.lang = an_object["lang"];
- comp_obj_block.metainfo.attrib = an_object["attrib"];
- comp_obj_block.tags.html_segment_anchor_tag_is = tag_in_seg["seg_lv4"];
- comp_obj_block.tags.epub_segment_anchor_tag_is = tag_in_seg["seg_lv1to4"];
- comp_obj_block.text = an_object["substantive"];
- comp_obj_block.has.inline_notes_reg = substantive_obj_misc_struct.has_notes_reg;
- comp_obj_block.has.inline_notes_star = substantive_obj_misc_struct.has_notes_star;
- comp_obj_block.has.inline_links = substantive_obj_misc_struct.has_links;
- the_document_body_section ~= comp_obj_block;
+ comp_obj_ = set_object_generic("body", "body", "block", "group", an_object["substantive"], obj_cite_digits.object_number);
+ comp_obj_.metainfo.identifier = obj_cite_digits.identifier;
+ comp_obj_.metainfo.object_number_off = obj_cite_digits.off;
+ comp_obj_.metainfo.o_n_book_index = obj_cite_digits.bkidx;
+ comp_obj_.metainfo.object_number_type = obj_cite_digits.type;
+ comp_obj_.metainfo.lang = an_object["lang"];
+ comp_obj_.metainfo.attrib = an_object["attrib"];
+ comp_obj_.tags.html_segment_anchor_tag_is = tag_in_seg["seg_lv4"];
+ comp_obj_.tags.epub_segment_anchor_tag_is = tag_in_seg["seg_lv1to4"];
+ comp_obj_.has.inline_notes_reg = substantive_obj_misc_struct.has_notes_reg;
+ comp_obj_.has.inline_notes_star = substantive_obj_misc_struct.has_notes_star;
+ comp_obj_.has.inline_links = substantive_obj_misc_struct.has_links;
+ the_document_body_section ~= comp_obj_;
tag_assoc = an_object.inline_para_link_anchor(tag_in_seg, tag_assoc);
pith["block_is"] = eN.blk_is.poem;
pith["block_state"] = eN.blk_state.off;
@@ -3830,25 +3197,19 @@ template docAbstraction() {
= 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; // check
- comp_obj_block = comp_obj_block.init;
- comp_obj_block.metainfo.is_of_part = "body";
- comp_obj_block.metainfo.is_of_section = "body";
- comp_obj_block.metainfo.is_of_type = "block";
- comp_obj_block.metainfo.is_a = "block";
- comp_obj_block.metainfo.ocn = obj_cite_digits.object_number;
- comp_obj_block.metainfo.identifier = obj_cite_digits.identifier;
- comp_obj_block.metainfo.object_number_off = obj_cite_digits.off;
- comp_obj_block.metainfo.o_n_book_index = obj_cite_digits.bkidx;
- comp_obj_block.metainfo.object_number_type = obj_cite_digit_type;
- comp_obj_block.metainfo.lang = an_object["lang"];
- comp_obj_block.metainfo.attrib = an_object["attrib"];
- comp_obj_block.tags.html_segment_anchor_tag_is = tag_in_seg["seg_lv4"];
- comp_obj_block.tags.epub_segment_anchor_tag_is = tag_in_seg["seg_lv1to4"];
- comp_obj_block.text = an_object["substantive"];
- comp_obj_block.has.inline_notes_reg = substantive_obj_misc_struct.has_notes_reg;
- comp_obj_block.has.inline_notes_star = substantive_obj_misc_struct.has_notes_star;
- comp_obj_block.has.inline_links = substantive_obj_misc_struct.has_links;
- the_document_body_section ~= comp_obj_block;
+ comp_obj_ = set_object_generic("body", "body", "block", "block", an_object["substantive"], obj_cite_digits.object_number);
+ comp_obj_.metainfo.identifier = obj_cite_digits.identifier;
+ comp_obj_.metainfo.object_number_off = obj_cite_digits.off;
+ comp_obj_.metainfo.o_n_book_index = obj_cite_digits.bkidx;
+ comp_obj_.metainfo.object_number_type = obj_cite_digit_type;
+ comp_obj_.metainfo.lang = an_object["lang"];
+ comp_obj_.metainfo.attrib = an_object["attrib"];
+ comp_obj_.tags.html_segment_anchor_tag_is = tag_in_seg["seg_lv4"];
+ comp_obj_.tags.epub_segment_anchor_tag_is = tag_in_seg["seg_lv1to4"];
+ comp_obj_.has.inline_notes_reg = substantive_obj_misc_struct.has_notes_reg;
+ comp_obj_.has.inline_notes_star = substantive_obj_misc_struct.has_notes_star;
+ comp_obj_.has.inline_links = substantive_obj_misc_struct.has_links;
+ the_document_body_section ~= comp_obj_;
pith["block_is"] = eN.blk_is.block;
pith["block_state"] = eN.blk_state.off;
pith["block_delim"] = eN.blk_delim.off;
@@ -3876,17 +3237,11 @@ template docAbstraction() {
heading_ptr-1,
an_object["is"]
);
- comp_obj_poem_ocn = comp_obj_poem_ocn.init;
- comp_obj_poem_ocn.metainfo.is_of_part = "body";
- comp_obj_poem_ocn.metainfo.is_of_section = "body";
- comp_obj_poem_ocn.metainfo.is_of_type = "block";
- comp_obj_poem_ocn.metainfo.is_a = "poem";
- comp_obj_poem_ocn.metainfo.ocn = obj_cite_digits.object_number;
+ comp_obj_poem_ocn = set_object_generic("body", "body", "block", "poem", "", obj_cite_digits.object_number);
comp_obj_poem_ocn.metainfo.identifier = obj_cite_digits.identifier;
comp_obj_poem_ocn.metainfo.object_number_off = obj_cite_digits.off;
comp_obj_poem_ocn.metainfo.o_n_book_index = obj_cite_digits.bkidx;
comp_obj_poem_ocn.metainfo.object_number_type = obj_cite_digits.type;
- comp_obj_poem_ocn.text = "";
the_document_body_section ~= comp_obj_poem_ocn;
pith["block_is"] = eN.blk_is.poem;
pith["block_state"] = eN.blk_state.off;
@@ -3919,26 +3274,20 @@ template docAbstraction() {
= 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_code = comp_obj_code.init;
- comp_obj_code.metainfo.is_of_part = "body";
- comp_obj_code.metainfo.is_of_section = "body";
- comp_obj_code.metainfo.is_of_type = "block";
- comp_obj_code.metainfo.is_a = "code";
- comp_obj_code.metainfo.ocn = obj_cite_digits.object_number;
- comp_obj_code.metainfo.identifier = obj_cite_digits.identifier;
- comp_obj_code.metainfo.object_number_off = obj_cite_digits.off;
- comp_obj_code.metainfo.o_n_book_index = obj_cite_digits.bkidx;
- comp_obj_code.metainfo.object_number_type = obj_cite_digits.type;
- comp_obj_code.metainfo.syntax = an_object["syntax"];
- comp_obj_code.metainfo.attrib = an_object["attrib"];
- comp_obj_code.code_block.linenumbers = (an_object["attrib"].match(rgx.code_numbering)) ? true : false;
- comp_obj_code.tags.html_segment_anchor_tag_is = tag_in_seg["seg_lv4"];
- comp_obj_code.tags.epub_segment_anchor_tag_is = tag_in_seg["seg_lv1to4"];
- comp_obj_code.text = an_object["substantive"];
- comp_obj_code.has.inline_notes_reg = substantive_obj_misc_struct.has_notes_reg;
- comp_obj_code.has.inline_notes_star = substantive_obj_misc_struct.has_notes_star;
- comp_obj_code.has.inline_links = substantive_obj_misc_struct.has_links;
- the_document_body_section ~= comp_obj_code;
+ comp_obj_ = set_object_generic("body", "body", "block", "code", an_object["substantive"], obj_cite_digits.object_number);
+ comp_obj_.metainfo.identifier = obj_cite_digits.identifier;
+ comp_obj_.metainfo.object_number_off = obj_cite_digits.off;
+ comp_obj_.metainfo.o_n_book_index = obj_cite_digits.bkidx;
+ comp_obj_.metainfo.object_number_type = obj_cite_digits.type;
+ comp_obj_.metainfo.syntax = an_object["syntax"];
+ comp_obj_.metainfo.attrib = an_object["attrib"];
+ comp_obj_.code_block.linenumbers = (an_object["attrib"].match(rgx.code_numbering)) ? true : false;
+ comp_obj_.tags.html_segment_anchor_tag_is = tag_in_seg["seg_lv4"];
+ comp_obj_.tags.epub_segment_anchor_tag_is = tag_in_seg["seg_lv1to4"];
+ comp_obj_.has.inline_notes_reg = substantive_obj_misc_struct.has_notes_reg;
+ comp_obj_.has.inline_notes_star = substantive_obj_misc_struct.has_notes_star;
+ comp_obj_.has.inline_links = substantive_obj_misc_struct.has_links;
+ the_document_body_section ~= comp_obj_;
pith["block_is"] = eN.blk_is.code;
pith["block_state"] = eN.blk_state.off;
pith["block_delim"] = eN.blk_delim.off;
@@ -3946,7 +3295,7 @@ template docAbstraction() {
processing.remove("verse");
++cntr;
} else if (pith["block_is"] == eN.blk_is.table) {
- comp_obj_block = comp_obj_block.init;
+ comp_obj_ = comp_obj_.init;
obj_cite_digits = ocn_emit(pith["ocn"]);
an_object["bookindex_nugget"]
= ("bookindex_nugget" in an_object) ? an_object["bookindex_nugget"] : "";
@@ -3971,23 +3320,23 @@ template docAbstraction() {
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;
- comp_obj_block = comp_obj_block.init;
- comp_obj_block.metainfo.ocn = obj_cite_digits.object_number;
- comp_obj_block.metainfo.identifier = obj_cite_digits.identifier;
- comp_obj_block.metainfo.object_number_off = obj_cite_digits.off;
- comp_obj_block.tags.html_segment_anchor_tag_is = tag_in_seg["seg_lv4"];
- comp_obj_block.tags.epub_segment_anchor_tag_is = tag_in_seg["seg_lv1to4"];
- comp_obj_block.metainfo.o_n_book_index = obj_cite_digits.bkidx;
- comp_obj_block.metainfo.object_number_type = obj_cite_digits.type;
- comp_obj_block = comp_obj_block.flow_table_instructions(an_object["table_head"]);
+ comp_obj_ = comp_obj_.init;
+ comp_obj_.metainfo.ocn = obj_cite_digits.object_number;
+ comp_obj_.metainfo.identifier = obj_cite_digits.identifier;
+ comp_obj_.metainfo.object_number_off = obj_cite_digits.off;
+ comp_obj_.tags.html_segment_anchor_tag_is = tag_in_seg["seg_lv4"];
+ comp_obj_.tags.epub_segment_anchor_tag_is = tag_in_seg["seg_lv1to4"];
+ comp_obj_.metainfo.o_n_book_index = obj_cite_digits.bkidx;
+ comp_obj_.metainfo.object_number_type = obj_cite_digits.type;
+ comp_obj_ = comp_obj_.flow_table_instructions(an_object["table_head"]);
{
- auto _get = comp_obj_block.flow_table_substantive_munge(an_object["substantive"]);
+ auto _get = comp_obj_.flow_table_substantive_munge(an_object["substantive"]);
{
- comp_obj_block = _get.table_object;
+ comp_obj_ = _get.table_object;
an_object["substantive"] = _get.table_substantive;
}
}
- the_document_body_section ~= comp_obj_block;
+ the_document_body_section ~= comp_obj_;
pith["block_is"] = eN.blk_is.table;
pith["block_state"] = eN.blk_state.off;
pith["block_delim"] = eN.blk_delim.off;
@@ -4002,7 +3351,7 @@ template docAbstraction() {
ret.the_document_body_section = the_document_body_section;
ret.bookindex_unordered_hashes = bookindex_unordered_hashes;
ret.obj_cite_digits = obj_cite_digits;
- ret.comp_obj_heading = _comp_obj_heading; //
+ ret.comp_obj_ = comp_obj_; //
ret.cntr = cntr;
ret.pith = pith;
}
@@ -4693,6 +4042,53 @@ template docAbstraction() {
invariant() {
}
}
+ @safe ObjGenericComposite set_object_heading()(
+ string level,
+ string part,
+ string section,
+ string text,
+ ) {
+ ObjGenericComposite comp_obj;
+ comp_obj = comp_obj.init;
+ comp_obj.metainfo.is_of_part = part;
+ comp_obj.metainfo.is_of_section = section;
+ comp_obj.metainfo.is_of_type = "para";
+ comp_obj.metainfo.is_a = "heading";
+ comp_obj.text = text;
+ comp_obj.metainfo.ocn = 0;
+ if (level == "lev1") {
+ comp_obj.metainfo.heading_lev_markup = 1;
+ comp_obj.metainfo.heading_lev_collapsed = 1;
+ comp_obj.metainfo.parent_ocn = 1;
+ comp_obj.metainfo.parent_lev_markup = 0;
+ } else if (level == "lev4") {
+ comp_obj.metainfo.heading_lev_markup = 4;
+ comp_obj.metainfo.heading_lev_collapsed = 1;
+ comp_obj.metainfo.parent_ocn = 1;
+ comp_obj.metainfo.parent_lev_markup = 0;
+ comp_obj.metainfo.dom_structure_markedup_tags_status = [ 1, 1, 0, 0, 1, 0, 0, 0]; // KEEP
+ comp_obj.metainfo.dom_structure_collapsed_tags_status = [ 1, 1, 1, 0, 0, 0, 0, 0]; // KEEP
+ }
+ return comp_obj;
+ }
+ @safe ObjGenericComposite set_object_generic()(
+ string part,
+ string section,
+ string type,
+ string is_a,
+ string text,
+ int ocn,
+ ) {
+ ObjGenericComposite comp_obj;
+ comp_obj = comp_obj.init;
+ comp_obj.metainfo.is_of_part = part;
+ comp_obj.metainfo.is_of_section = section;
+ comp_obj.metainfo.is_of_type = type;
+ comp_obj.metainfo.is_a = is_a;
+ comp_obj.text = text;
+ comp_obj.metainfo.ocn = ocn;
+ return comp_obj;
+ }
@safe static struct ObjInlineMarkupMunge {
string[string] obj_txt;
int n_foot, n_foot_reg, n_foot_sp_asterisk, n_foot_sp_plus;
@@ -5059,7 +4455,7 @@ template docAbstraction() {
string[][string] lev4_subtoc,
ObjGenericComposite[] the_document_toc_section,
) {
- ObjGenericComposite comp_obj_toc;
+ ObjGenericComposite comp_obj_;
mixin InternalMarkup;
static auto mkup = InlineMarkup();
char[] heading_toc_ = (obj_["substantive"].dup.strip.to!(char[]))
@@ -5082,35 +4478,29 @@ template docAbstraction() {
mkup.url_c,
);
toc_txt_= toc_txt_.links_and_images;
- 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.metainfo.dummy_heading = (an_object["dummy_heading_status"] == "t") ? true: false;
- comp_obj_toc.attrib.indent_hang = indent["hang_position"];
- comp_obj_toc.attrib.indent_base = indent["base_position"];
- comp_obj_toc.attrib.bullet = false;
- comp_obj_toc.text = toc_txt_.to!string.strip;
- comp_obj_toc.has.inline_links = true;
- the_document_toc_section ~= comp_obj_toc;
- }
- 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.metainfo.dummy_heading = (an_object["dummy_heading_status"] == "t") ? true: false;
- comp_obj_toc.attrib.bullet = false;
- comp_obj_toc.has.inline_links = true;
+ comp_obj_ = set_object_generic("frontmatter", "toc", "para", "toc", toc_txt_.to!string.strip, 0);
+ comp_obj_.metainfo.identifier = "";
+ comp_obj_.metainfo.object_number_off = true;
+ comp_obj_.metainfo.object_number_type = 0;
+ comp_obj_.metainfo.dummy_heading = (an_object["dummy_heading_status"] == "t") ? true: false;
+ comp_obj_.attrib.indent_hang = indent["hang_position"];
+ comp_obj_.attrib.indent_base = indent["base_position"];
+ comp_obj_.attrib.bullet = false;
+ comp_obj_.has.inline_links = true;
+ the_document_toc_section ~= comp_obj_;
+ }
+ comp_obj_ = comp_obj_.init;
+ comp_obj_.metainfo.is_of_part = "frontmatter";
+ comp_obj_.metainfo.is_of_section = "toc";
+ comp_obj_.metainfo.is_of_type = "para";
+ comp_obj_.metainfo.is_a = "toc";
+ comp_obj_.metainfo.ocn = 0;
+ comp_obj_.metainfo.identifier = "";
+ comp_obj_.metainfo.object_number_off = true;
+ comp_obj_.metainfo.object_number_type = 0;
+ comp_obj_.metainfo.dummy_heading = (an_object["dummy_heading_status"] == "t") ? true: false;
+ comp_obj_.attrib.bullet = false;
+ comp_obj_.has.inline_links = true;
switch (obj_["lev_markup_number"].to!int) {
case 0: .. case 3:
break;
@@ -5329,12 +4719,12 @@ template docAbstraction() {
@safe string obj_attributes()(
string obj_is_,
string obj_raw,
- ObjGenericComposite _comp_obj_heading,
+ ObjGenericComposite comp_obj_,
) {
scope(exit) {
destroy(obj_is_);
destroy(obj_raw);
- destroy(_comp_obj_heading);
+ destroy(comp_obj_);
}
_obj_attrib["json"] ="{";
switch (obj_is_) {
@@ -5373,7 +4763,7 @@ template docAbstraction() {
break;
}
_obj_attrib["json"] ~= " }";
- _obj_attrib["json"] = _set_additional_values_parse_as_json(_obj_attrib["json"], obj_is_, _comp_obj_heading);
+ _obj_attrib["json"] = _set_additional_values_parse_as_json(_obj_attrib["json"], obj_is_, comp_obj_);
debug(structattrib) {
if (oa_j["is"].str() == "heading") {
writeln(_obj_attrib["json"]);
@@ -5488,21 +4878,21 @@ template docAbstraction() {
@safe string _set_additional_values_parse_as_json()(
string _obj_attrib,
string obj_is_,
- ObjGenericComposite _comp_obj_heading,
+ ObjGenericComposite comp_obj_,
) {
JSONValue oa_j = parseJSON(_obj_attrib);
assert(
(oa_j.type == JSON_TYPE.OBJECT)
);
if (obj_is_ == "heading") {
- oa_j.object["object_number"] = _comp_obj_heading.metainfo.ocn;
- oa_j.object["lev_markup_number"] = _comp_obj_heading.metainfo.heading_lev_markup;
- oa_j.object["lev_collapsed_number"] = _comp_obj_heading.metainfo.heading_lev_collapsed;
- oa_j.object["heading_ptr"] = _comp_obj_heading.ptr.heading;
- oa_j.object["doc_object_ptr"] = _comp_obj_heading.ptr.doc_object;
- }
- oa_j.object["parent_object_number"] = _comp_obj_heading.metainfo.parent_ocn;
- oa_j.object["parent_lev_markup_number"] = _comp_obj_heading.metainfo.parent_lev_markup;
+ oa_j.object["object_number"] = comp_obj_.metainfo.ocn;
+ oa_j.object["lev_markup_number"] = comp_obj_.metainfo.heading_lev_markup;
+ oa_j.object["lev_collapsed_number"] = comp_obj_.metainfo.heading_lev_collapsed;
+ oa_j.object["heading_ptr"] = comp_obj_.ptr.heading;
+ oa_j.object["doc_object_ptr"] = comp_obj_.ptr.doc_object;
+ }
+ oa_j.object["parent_object_number"] = comp_obj_.metainfo.parent_ocn;
+ oa_j.object["parent_lev_markup_number"] = comp_obj_.metainfo.parent_lev_markup;
_obj_attrib = oa_j.toString();
return _obj_attrib;
}
@@ -5654,7 +5044,7 @@ template docAbstraction() {
bookindex_unordered_hashes.byKey.array
.sort!("toUpper(a) < toUpper(b)", SwapStrategy.stable).release;
ObjGenericComposite[] bookindex_section;
- ObjGenericComposite comp_obj_heading_, comp_obj_para;
+ ObjGenericComposite comp_obj_;
auto node_para_int_ = node_metadata_para_int;
auto node_para_str_ = node_metadata_para_str;
if ((mainkeys.length > 0)
@@ -5663,55 +5053,36 @@ template docAbstraction() {
string bi_tmp;
string[] bi_tmp_tags;
{
- comp_obj_heading_ = comp_obj_heading_.init;
- comp_obj_heading_.metainfo.is_of_part = "backmatter";
- comp_obj_heading_.metainfo.is_of_section = "bookindex";
- comp_obj_heading_.metainfo.is_of_type = "para";
- comp_obj_heading_.metainfo.is_a = "heading";
- comp_obj_heading_.text = "Book Index";
- comp_obj_heading_.metainfo.ocn = 0;
- comp_obj_heading_.metainfo.identifier = "";
- comp_obj_heading_.metainfo.dummy_heading = false;
- comp_obj_heading_.metainfo.object_number_off = false;
- comp_obj_heading_.metainfo.object_number_type = 0;
- comp_obj_heading_.tags.segment_anchor_tag_epub = "_part_book_index";
- comp_obj_heading_.tags.anchor_tag_html = comp_obj_heading_.tags.segment_anchor_tag_epub;
- comp_obj_heading_.tags.in_segment_html = "bookindex";
- comp_obj_heading_.tags.anchor_tags = ["section_bookindex"];
- comp_obj_heading_.metainfo.heading_lev_markup = 1;
- comp_obj_heading_.metainfo.heading_lev_collapsed = 1;
- comp_obj_heading_.metainfo.parent_ocn = 1;
- comp_obj_heading_.metainfo.parent_lev_markup = 0;
- comp_obj_heading.has.inline_links = true;
- bookindex_section ~= 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_ = set_object_heading("lev1", "backmatter", "bookindex", "Book Index");
+ comp_obj_.metainfo.identifier = "";
+ comp_obj_.metainfo.dummy_heading = false;
+ comp_obj_.metainfo.object_number_off = false;
+ comp_obj_.metainfo.object_number_type = 0;
+ comp_obj_.tags.segment_anchor_tag_epub = "_part_book_index";
+ comp_obj_.tags.anchor_tag_html = comp_obj_.tags.segment_anchor_tag_epub;
+ comp_obj_.tags.in_segment_html = "bookindex";
+ comp_obj_.tags.anchor_tags = ["section_bookindex"];
+ comp_obj_.has.inline_links = true;
+ bookindex_section ~= comp_obj_;
+ tag_assoc[comp_obj_.tags.anchor_tag_html]["seg_lv4"] = comp_obj_.tags.in_segment_html;
+ tag_assoc[comp_obj_.tags.segment_anchor_tag_epub]["seg_lv1to4"] = comp_obj_.tags.segment_anchor_tag_epub;
++mkn;
}
{
- comp_obj_heading_ = comp_obj_heading_.init;
- comp_obj_heading_.metainfo.is_of_part = "backmatter";
- comp_obj_heading_.metainfo.is_of_section = "bookindex";
- comp_obj_heading_.metainfo.is_of_type = "para";
- comp_obj_heading_.metainfo.is_a = "heading";
- comp_obj_heading_.text = "Index";
- comp_obj_heading_.metainfo.ocn = 0;
- comp_obj_heading_.metainfo.identifier = "";
- comp_obj_heading_.metainfo.dummy_heading = true;
- comp_obj_heading_.metainfo.object_number_off = true;
- comp_obj_heading_.metainfo.object_number_type = 0;
- comp_obj_heading_.tags.segment_anchor_tag_epub = "bookindex";
- comp_obj_heading_.tags.anchor_tag_html = comp_obj_heading_.tags.segment_anchor_tag_epub;
- comp_obj_heading_.tags.in_segment_html = comp_obj_heading_.tags.anchor_tag_html;
- comp_obj_heading_.metainfo.heading_lev_markup = 4;
- comp_obj_heading_.metainfo.heading_lev_collapsed = 2;
- comp_obj_heading_.metainfo.parent_ocn = 1;
- comp_obj_heading_.metainfo.parent_lev_markup = 0;
- comp_obj_heading.has.inline_links = false;
- comp_obj_heading_.tags.anchor_tags = ["bookindex"];
- bookindex_section ~= 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_ = set_object_heading("lev4", "backmatter", "bookindex", "Index");
+ comp_obj_.metainfo.identifier = "";
+ comp_obj_.metainfo.dummy_heading = true;
+ comp_obj_.metainfo.object_number_off = true;
+ comp_obj_.metainfo.object_number_type = 0;
+ comp_obj_.tags.segment_anchor_tag_epub = "bookindex";
+ comp_obj_.tags.anchor_tag_html = comp_obj_.tags.segment_anchor_tag_epub;
+ comp_obj_.tags.in_segment_html = comp_obj_.tags.anchor_tag_html;
+ comp_obj_.metainfo.heading_lev_collapsed = 2;
+ comp_obj_.has.inline_links = false;
+ comp_obj_.tags.anchor_tags = ["bookindex"];
+ bookindex_section ~= comp_obj_;
+ tag_assoc[comp_obj_.tags.anchor_tag_html]["seg_lv4"] = comp_obj_.tags.in_segment_html;
+ tag_assoc[comp_obj_.tags.segment_anchor_tag_epub]["seg_lv1to4"] = comp_obj_.tags.segment_anchor_tag_epub;
++mkn;
}
import std.array : appender;
@@ -5751,39 +5122,26 @@ template docAbstraction() {
bi_tmp ~= " \\\\\n ";
++skn;
}
- bi_tmp = bi_tmp.replaceFirst(rgx.trailing_linebreak, "");
- comp_obj_para = comp_obj_para.init;
- comp_obj_para.metainfo.is_of_part = "backmatter";
- comp_obj_para.metainfo.is_of_section = "bookindex";
- comp_obj_para.metainfo.is_of_type = "para";
- comp_obj_para.metainfo.is_a = "bookindex";
- comp_obj_para.text = bi_tmp.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.tags.anchor_tags = bi_tmp_tags;
- comp_obj_para.attrib.indent_hang = 0;
- comp_obj_para.attrib.indent_base = 1;
- comp_obj_para.attrib.bullet = false;
- comp_obj_para.has.inline_links = true;
- comp_obj_para.text = bi_tmp.to!string.strip;
- bookindex_section ~= comp_obj_para;
+ bi_tmp = bi_tmp.replaceFirst(rgx.trailing_linebreak, "");
+ comp_obj_ = set_object_generic("backmatter", "bookindex", "para", "bookindex", bi_tmp.to!string.strip, 0);
+ comp_obj_.metainfo.identifier = "";
+ comp_obj_.metainfo.object_number_off = true;
+ comp_obj_.metainfo.object_number_type = 0;
+ comp_obj_.tags.anchor_tags = bi_tmp_tags;
+ comp_obj_.attrib.indent_hang = 0;
+ comp_obj_.attrib.indent_base = 1;
+ comp_obj_.attrib.bullet = false;
+ comp_obj_.has.inline_links = true;
+ comp_obj_.text = bi_tmp.to!string.strip;
+ bookindex_section ~= comp_obj_;
++mkn;
}
} else { // no book index, (figure out what to do here)
- comp_obj_heading_ = comp_obj_heading_.init;
- comp_obj_heading_.text = "(skip) there is no Book Index";
- comp_obj_heading_.metainfo.ocn = 0;
- comp_obj_heading_.metainfo.identifier = "";
- comp_obj_heading_.metainfo.dummy_heading = true;
- comp_obj_heading_.metainfo.object_number_off = true;
- comp_obj_heading_.metainfo.object_number_type = 0;
- comp_obj_heading_.metainfo.heading_lev_markup = 1;
- comp_obj_heading_.metainfo.heading_lev_collapsed = 1;
- comp_obj_heading_.metainfo.parent_ocn = 1;
- comp_obj_heading_.metainfo.parent_lev_markup = 0;
- bookindex_section ~= comp_obj_heading_;
+ comp_obj_ = set_object_heading("lev1", "backmatter", "bookindex", "(skip) there is no Book Index");
+ comp_obj_.metainfo.identifier = "";
+ comp_obj_.metainfo.dummy_heading = true;
+ comp_obj_.metainfo.object_number_off = true;
+ bookindex_section ~= comp_obj_;
}
ST_bookindex ret;
{
@@ -5898,89 +5256,54 @@ template docAbstraction() {
string lev, lev_markup_number, lev_collapsed_number;
string attrib;
int[string] indent;
- ObjGenericComposite comp_obj_heading_;
+ ObjGenericComposite comp_obj_;
if ((endnotes_["notes"].length > 0)
&& (opt_action.backmatter && opt_action.section_endnotes)) {
{
- comp_obj_heading_ = comp_obj_heading_.init;
- comp_obj_heading_.metainfo.is_of_part = "backmatter";
- comp_obj_heading_.metainfo.is_of_section = "endnotes";
- comp_obj_heading_.metainfo.is_of_type = "para";
- comp_obj_heading_.metainfo.is_a = "heading";
- comp_obj_heading_.text = "Endnotes";
- comp_obj_heading_.metainfo.ocn = 0;
- comp_obj_heading_.metainfo.identifier = "";
- comp_obj_heading_.metainfo.dummy_heading = false;
- comp_obj_heading_.metainfo.object_number_off = false;
- comp_obj_heading_.metainfo.object_number_type = 0;
- comp_obj_heading_.tags.segment_anchor_tag_epub = "_part_endnotes";
- comp_obj_heading_.tags.anchor_tag_html = comp_obj_heading_.tags.segment_anchor_tag_epub;
- comp_obj_heading_.tags.in_segment_html = "endnotes";
- comp_obj_heading_.tags.anchor_tags = ["section_endnotes"];
- comp_obj_heading_.metainfo.heading_lev_markup = 1;
- comp_obj_heading_.metainfo.heading_lev_collapsed = 1;
- comp_obj_heading_.metainfo.parent_ocn = 1;
- comp_obj_heading_.metainfo.parent_lev_markup = 0;
- the_document_endnotes_section ~= comp_obj_heading_;
- tag_assoc[comp_obj_heading_.tags.anchor_tag_html]["seg_lv4"] = comp_obj_heading_.tags.in_segment_html;
- tag_assoc[comp_obj_heading_.tags.segment_anchor_tag_epub]["seg_lv1to4"] = comp_obj_heading_.tags.segment_anchor_tag_epub;
+ comp_obj_ = set_object_heading("lev1", "backmatter", "endnotes", "Endnotes");
+ comp_obj_.metainfo.identifier = "";
+ comp_obj_.metainfo.dummy_heading = false;
+ comp_obj_.metainfo.object_number_off = false;
+ comp_obj_.metainfo.object_number_type = 0;
+ comp_obj_.tags.segment_anchor_tag_epub = "_part_endnotes";
+ comp_obj_.tags.anchor_tag_html = comp_obj_.tags.segment_anchor_tag_epub;
+ comp_obj_.tags.in_segment_html = "endnotes";
+ comp_obj_.tags.anchor_tags = ["section_endnotes"];
+ the_document_endnotes_section ~= comp_obj_;
+ tag_assoc[comp_obj_.tags.anchor_tag_html]["seg_lv4"] = comp_obj_.tags.in_segment_html;
+ tag_assoc[comp_obj_.tags.segment_anchor_tag_epub]["seg_lv1to4"] = comp_obj_.tags.segment_anchor_tag_epub;
++mkn;
}
{
- comp_obj_heading_ = comp_obj_heading_.init;
- comp_obj_heading_.metainfo.is_of_part = "backmatter";
- comp_obj_heading_.metainfo.is_of_section = "endnotes";
- comp_obj_heading_.metainfo.is_of_type = "para";
- comp_obj_heading_.metainfo.is_a = "heading";
- comp_obj_heading_.text = "Endnotes";
- comp_obj_heading_.metainfo.ocn = 0;
- comp_obj_heading_.metainfo.identifier = "";
- comp_obj_heading_.metainfo.dummy_heading = true;
- comp_obj_heading_.metainfo.object_number_off = true;
- comp_obj_heading_.metainfo.object_number_type = 0;
- comp_obj_heading_.tags.segment_anchor_tag_epub = "endnotes";
- comp_obj_heading_.tags.anchor_tag_html = comp_obj_heading_.tags.segment_anchor_tag_epub;
- comp_obj_heading_.tags.in_segment_html = comp_obj_heading_.tags.anchor_tag_html;
- comp_obj_heading_.metainfo.heading_lev_markup = 4;
- comp_obj_heading_.metainfo.heading_lev_collapsed = 2;
- comp_obj_heading_.metainfo.parent_ocn = 1;
- comp_obj_heading_.metainfo.parent_lev_markup = 0;
- comp_obj_heading_.tags.anchor_tags = ["endnotes"];
- the_document_endnotes_section ~= comp_obj_heading_;
- tag_assoc[comp_obj_heading_.tags.anchor_tag_html]["seg_lv4"] = comp_obj_heading_.tags.in_segment_html;
- tag_assoc[comp_obj_heading_.tags.segment_anchor_tag_epub]["seg_lv1to4"] = comp_obj_heading_.tags.segment_anchor_tag_epub;
+ comp_obj_ = set_object_heading("lev4", "backmatter", "endnotes", "Endnotes");
+ comp_obj_.metainfo.identifier = "";
+ comp_obj_.metainfo.dummy_heading = true;
+ comp_obj_.metainfo.object_number_off = true;
+ comp_obj_.metainfo.object_number_type = 0;
+ comp_obj_.tags.segment_anchor_tag_epub = "endnotes";
+ comp_obj_.tags.anchor_tag_html = comp_obj_.tags.segment_anchor_tag_epub;
+ comp_obj_.tags.in_segment_html = comp_obj_.tags.anchor_tag_html;
+ comp_obj_.tags.anchor_tags = ["endnotes"];
+ the_document_endnotes_section ~= comp_obj_;
+ tag_assoc[comp_obj_.tags.anchor_tag_html]["seg_lv4"] = comp_obj_.tags.in_segment_html;
+ tag_assoc[comp_obj_.tags.segment_anchor_tag_epub]["seg_lv1to4"] = comp_obj_.tags.segment_anchor_tag_epub;
++mkn;
}
} 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 are no Endnotes";
- comp_obj_heading_.metainfo.ocn = 0;
- comp_obj_heading_.metainfo.identifier = "";
- comp_obj_heading_.metainfo.dummy_heading = true;
- comp_obj_heading_.metainfo.object_number_off = true;
- comp_obj_heading_.metainfo.object_number_type = 0;
- comp_obj_heading_.metainfo.heading_lev_markup = 1;
- 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_endnotes_section ~= comp_obj_heading_;
+ comp_obj_ = set_object_heading("lev1", "empty", "empty", "(skip) there are no Endnotes");
+ comp_obj_.metainfo.identifier = "";
+ comp_obj_.metainfo.dummy_heading = true;
+ comp_obj_.metainfo.object_number_off = true;
+ comp_obj_.metainfo.object_number_type = 0;
+ the_document_endnotes_section ~= comp_obj_;
}
if (opt_action.backmatter && opt_action.section_endnotes) {
ObjGenericComposite comp_obj_endnote_;
- comp_obj_endnote_ = comp_obj_endnote_.init;
- comp_obj_endnote_.metainfo.is_of_part = "backmatter";
- comp_obj_endnote_.metainfo.is_of_section = "endnotes";
- comp_obj_endnote_.metainfo.is_of_type = "para";
- comp_obj_endnote_.metainfo.is_a = "endnote";
- comp_obj_endnote_.metainfo.ocn = 0;
+ comp_obj_endnote_ = set_object_generic("backmatter", "endnotes", "para", "endnote", "", 0);
comp_obj_endnote_.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_.metainfo.dummy_heading = false;
+ comp_obj_.metainfo.object_number_off = true;
+ comp_obj_.metainfo.object_number_type = 0;
comp_obj_endnote_.attrib.indent_hang = 0;
comp_obj_endnote_.attrib.indent_base = 0;
comp_obj_endnote_.attrib.bullet = false;
@@ -6002,6 +5325,90 @@ template docAbstraction() {
return ret;
}
}
+ @system public ST_biblio_section backmatter_make_the_bibliography_section()(
+ string[] biblio_unsorted_incomplete,
+ JSONValue[] bib_arr_json,
+ ) {
+ Bibliography biblio = Bibliography();
+ ObjGenericComposite comp_obj_;
+ static auto mkup = InlineMarkup();
+ ST_flow_bibliography _get = biblio.flow_bibliography_(biblio_unsorted_incomplete, bib_arr_json);
+ JSONValue[] biblio_ordered;
+ biblio_ordered = _get.biblio_sorted;
+ if (biblio_ordered.length > 0) {
+ {
+ comp_obj_ = set_object_heading("lev1", "backmatter", "bibliography", "Bibliography");
+ comp_obj_.metainfo.identifier = "";
+ comp_obj_.metainfo.dummy_heading = false;
+ comp_obj_.metainfo.object_number_off = false;
+ comp_obj_.metainfo.object_number_type = 0;
+ comp_obj_.tags.segment_anchor_tag_epub = "_part_bibliography";
+ comp_obj_.tags.anchor_tag_html = comp_obj_.tags.segment_anchor_tag_epub;
+ comp_obj_.tags.in_segment_html = "bibliography";
+ comp_obj_.tags.anchor_tags = ["section_bibliography"];
+ comp_obj_.metainfo.dom_structure_markedup_tags_status = [ 1, 1, 0, 0, 0, 0, 0, 0];
+ comp_obj_.metainfo.dom_structure_collapsed_tags_status = [ 1, 1, 0, 0, 0, 0, 0, 0];
+ the_document_bibliography_section ~= comp_obj_;
+ tag_assoc[comp_obj_.tags.anchor_tag_html]["seg_lv4"] = comp_obj_.tags.in_segment_html;
+ tag_assoc[comp_obj_.tags.segment_anchor_tag_epub]["seg_lv1to4"] = comp_obj_.tags.segment_anchor_tag_epub;
+ }
+ {
+ comp_obj_ = set_object_heading("lev4", "backmatter", "bibliography", "Bibliography");
+ comp_obj_.metainfo.identifier = "";
+ comp_obj_.metainfo.dummy_heading = true;
+ comp_obj_.metainfo.object_number_off = true;
+ comp_obj_.metainfo.object_number_type = 0;
+ comp_obj_.tags.segment_anchor_tag_epub = "bibliography";
+ comp_obj_.tags.anchor_tag_html = comp_obj_.tags.segment_anchor_tag_epub;
+ comp_obj_.tags.in_segment_html = comp_obj_.tags.anchor_tag_html;
+ comp_obj_.tags.anchor_tags = ["bibliography"];
+ the_document_bibliography_section ~= comp_obj_;
+ tag_assoc[comp_obj_.tags.anchor_tag_html]["seg_lv4"] = comp_obj_.tags.in_segment_html;
+ tag_assoc[comp_obj_.tags.segment_anchor_tag_epub]["seg_lv1to4"] = comp_obj_.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_ = set_object_generic("backmatter", "bibliography", "para", "bibliography", out_.to!string.strip, 0);
+ comp_obj_.metainfo.identifier = "";
+ comp_obj_.metainfo.object_number_off = true;
+ comp_obj_.metainfo.object_number_type = 0;
+ comp_obj_.attrib.indent_hang = 0;
+ comp_obj_.attrib.indent_base = 1;
+ comp_obj_.attrib.bullet = bullet;
+ comp_obj_.tags.anchor_tags = [anchor_tag];
+ the_document_bibliography_section ~= comp_obj_;
+ }
+ }
+ } else {
+ comp_obj_ = set_object_heading("lev1", "empty", "empty", "(skip) there is no Bibliography");
+ comp_obj_.metainfo.identifier = "";
+ comp_obj_.metainfo.dummy_heading = true;
+ comp_obj_.metainfo.object_number_off = true;
+ comp_obj_.metainfo.object_number_type = 0;
+ the_document_bibliography_section ~= comp_obj_;
+ }
+ debug(bibliosection) { foreach (o; the_document_bibliography_section) { writeln(o.text); } }
+ ST_biblio_section ret;
+ {
+ ret.bibliography_section = the_document_bibliography_section;
+ ret.tag_assoc = tag_assoc; //
+ }
+ return ret;
+ }
struct Bibliography {
@system public ST_flow_bibliography flow_bibliography_()(
string[] biblio_unsorted_incomplete,
@@ -6082,6 +5489,517 @@ template docAbstraction() {
}
}
}
+ @system public ObjGenericComposite[] backmatter_gather_table_of_contents(
+ ObjGenericComposite[] the_document_endnotes_section,
+ ObjGenericComposite[] the_document_glossary_section,
+ ObjGenericComposite[] the_document_bibliography_section,
+ ObjGenericComposite[] the_document_bookindex_section,
+ ObjGenericComposite[] the_document_blurb_section,
+ ) {
+ ObjGenericComposite[] toc_section_backmatter;
+ string toc_txt_;
+ static auto mkup = InlineMarkup();
+ ObjGenericComposite comp_obj_;
+ int[string] indent = [
+ "hang_position" : 1,
+ "base_position" : 1,
+ ];
+ comp_obj_ = set_object_generic("frontmatter", "toc", "para", "toc", "", 0);
+ comp_obj_.metainfo.identifier = "";
+ comp_obj_.metainfo.object_number_off = true;
+ comp_obj_.metainfo.object_number_type = 0;
+ comp_obj_.attrib.indent_hang = indent["hang_position"];
+ comp_obj_.attrib.indent_base = indent["base_position"];
+ comp_obj_.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_.text = toc_txt_.to!string.strip;
+ comp_obj_.has.inline_links = true;
+ toc_section_backmatter ~= comp_obj_;
+ }
+ 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_.text = toc_txt_.to!string.strip;
+ comp_obj_.has.inline_links = true;
+ toc_section_backmatter ~= comp_obj_;
+ }
+ 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_.text = toc_txt_.to!string.strip;
+ comp_obj_.has.inline_links = true;
+ toc_section_backmatter ~= comp_obj_;
+ }
+ 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_.text = toc_txt_.to!string.strip;
+ comp_obj_.has.inline_links = true;
+ toc_section_backmatter ~= comp_obj_;
+ }
+ 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_.has.inline_links = true;
+ comp_obj_.text = toc_txt_.to!string.strip;
+ toc_section_backmatter ~= comp_obj_;
+ }
+ debug(toc) {
+ writefln( "%s %s", __LINE__,);
+ foreach (toc_linked_heading; toc_section_backmatter) {
+ writeln(mkup.indent_by_spaces_provided(toc_linked_heading.attrib.indent_hang), toc_linked_heading.text);
+ }
+ }
+ return toc_section_backmatter;
+ }
+ @system public ST_ancestors after_doc_determine_ancestors(
+ ObjGenericComposite[] the_document_body_section,
+ ObjGenericComposite[] the_document_endnotes_section,
+ ObjGenericComposite[] the_document_glossary_section,
+ ObjGenericComposite[] the_document_bibliography_section,
+ ObjGenericComposite[] the_document_bookindex_section,
+ ObjGenericComposite[] the_document_blurb_section,
+ ) {
+ @safe int[] _get_ancestors_markup(ObjGenericComposite obj, int[] _ancestors_markup) {
+ if (obj.metainfo.is_a == "heading") {
+ debug(dom) { writeln(obj.text); }
+ if (obj.metainfo.heading_lev_markup == 1) {
+ _ancestors_markup = [
+ _ancestors_markup[0],
+ 0,0,0,0,0,0,0
+ ];
+ }
+ if (obj.metainfo.heading_lev_markup == 2) {
+ _ancestors_markup = [
+ _ancestors_markup[0],
+ _ancestors_markup[1],
+ 0,0,0,0,0,0
+ ];
+ }
+ if (obj.metainfo.heading_lev_markup == 3) {
+ _ancestors_markup = [
+ _ancestors_markup[0],
+ _ancestors_markup[1],
+ _ancestors_markup[2],
+ 0,0,0,0,0
+ ];
+ }
+ if (obj.metainfo.heading_lev_markup == 4) {
+ _ancestors_markup = [
+ _ancestors_markup[0],
+ _ancestors_markup[1],
+ _ancestors_markup[2],
+ _ancestors_markup[3],
+ 0,0,0,0
+ ];
+ }
+ if (obj.metainfo.heading_lev_markup == 5) {
+ _ancestors_markup = [
+ _ancestors_markup[0],
+ _ancestors_markup[1],
+ _ancestors_markup[2],
+ _ancestors_markup[3],
+ _ancestors_markup[4],
+ 0,0,0
+ ];
+ }
+ if (obj.metainfo.heading_lev_markup == 6) {
+ _ancestors_markup = [
+ _ancestors_markup[0],
+ _ancestors_markup[1],
+ _ancestors_markup[2],
+ _ancestors_markup[3],
+ _ancestors_markup[4],
+ _ancestors_markup[5],
+ 0,0
+ ];
+ }
+ if (obj.metainfo.heading_lev_markup == 7) {
+ _ancestors_markup = [
+ _ancestors_markup[0],
+ _ancestors_markup[1],
+ _ancestors_markup[2],
+ _ancestors_markup[3],
+ _ancestors_markup[4],
+ _ancestors_markup[5],
+ _ancestors_markup[6],
+ 0
+ ];
+ }
+ if (obj.metainfo.heading_lev_markup == 8) {
+ _ancestors_markup = [
+ _ancestors_markup[0],
+ _ancestors_markup[1],
+ _ancestors_markup[2],
+ _ancestors_markup[3],
+ _ancestors_markup[4],
+ _ancestors_markup[5],
+ _ancestors_markup[6],
+ _ancestors_markup[7]
+ ];
+ }
+ _ancestors_markup[obj.metainfo.heading_lev_markup] = obj.metainfo.ocn;
+ }
+ debug(ancestor_markup) { writeln("marked up: ", _ancestors_markup); }
+ return _ancestors_markup;
+ }
+ @safe int[] _get_ancestors_collapsed(ObjGenericComposite obj, int[] _ancestors_collapsed) {
+ if (obj.metainfo.is_a == "heading") {
+ if (obj.metainfo.heading_lev_collapsed == 1) {
+ _ancestors_collapsed = [
+ _ancestors_collapsed[0],
+ 0,0,0,0,0,0,0
+ ];
+ }
+ if (obj.metainfo.heading_lev_collapsed == 2) {
+ _ancestors_collapsed = [
+ _ancestors_collapsed[0],
+ _ancestors_collapsed[1],
+ 0,0,0,0,0,0
+ ];
+ }
+ if (obj.metainfo.heading_lev_collapsed == 3) {
+ _ancestors_collapsed = [
+ _ancestors_collapsed[0],
+ _ancestors_collapsed[1],
+ _ancestors_collapsed[2],
+ 0,0,0,0,0
+ ];
+ }
+ if (obj.metainfo.heading_lev_collapsed == 4) {
+ _ancestors_collapsed = [
+ _ancestors_collapsed[0],
+ _ancestors_collapsed[1],
+ _ancestors_collapsed[2],
+ _ancestors_collapsed[3],
+ 0,0,0,0
+ ];
+ }
+ if (obj.metainfo.heading_lev_collapsed == 5) {
+ _ancestors_collapsed = [
+ _ancestors_collapsed[0],
+ _ancestors_collapsed[1],
+ _ancestors_collapsed[2],
+ _ancestors_collapsed[3],
+ _ancestors_collapsed[4],
+ 0,0,0
+ ];
+ }
+ if (obj.metainfo.heading_lev_collapsed == 6) {
+ _ancestors_collapsed = [
+ _ancestors_collapsed[0],
+ _ancestors_collapsed[1],
+ _ancestors_collapsed[2],
+ _ancestors_collapsed[3],
+ _ancestors_collapsed[4],
+ _ancestors_collapsed[5],
+ 0,0
+ ];
+ }
+ if (obj.metainfo.heading_lev_collapsed == 7) {
+ _ancestors_collapsed = [
+ _ancestors_collapsed[0],
+ _ancestors_collapsed[1],
+ _ancestors_collapsed[2],
+ _ancestors_collapsed[3],
+ _ancestors_collapsed[4],
+ _ancestors_collapsed[5],
+ _ancestors_collapsed[6],
+ 0
+ ];
+ }
+ if (obj.metainfo.heading_lev_collapsed == 8) {
+ _ancestors_collapsed = [
+ _ancestors_collapsed[0],
+ _ancestors_collapsed[1],
+ _ancestors_collapsed[2],
+ _ancestors_collapsed[3],
+ _ancestors_collapsed[4],
+ _ancestors_collapsed[5],
+ _ancestors_collapsed[6],
+ _ancestors_collapsed[7]
+ ];
+ }
+ _ancestors_collapsed[obj.metainfo.heading_lev_collapsed] = obj.metainfo.ocn;
+ }
+ debug(ancestor_collapsed) { writeln("collapsed: ", _ancestors_collapsed); }
+ return _ancestors_collapsed;
+ }
+ // multiple 1~ levels, loop through document body
+ if (the_document_body_section.length > 1) {
+ int[] _ancestors_markup = [0,0,0,0,0,0,0,0];
+ int[][] _ancestors_markup_;
+ _ancestors_markup = [1,0,0,0,0,0,0,0];
+ _ancestors_markup_ ~= _ancestors_markup;
+ int[] _ancestors_collapsed = [0,0,0,0,0,0,0,0];
+ int[][] _ancestors_collapsed_;
+ _ancestors_collapsed = [1,0,0,0,0,0,0,0];
+ _ancestors_collapsed_ ~= _ancestors_collapsed;
+ foreach (ref obj; the_document_body_section) {
+ if (obj.metainfo.is_a == "heading") {
+ obj.metainfo.markedup_ancestors = _get_ancestors_markup(obj, _ancestors_markup);
+ obj.metainfo.collapsed_ancestors = _get_ancestors_collapsed(obj, _ancestors_collapsed);
+ 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);
+ }
+ }
+ ST_ancestors ret;
+ ret.the_document_body_section = the_document_body_section;
+ ret.the_document_endnotes_section = the_document_endnotes_section;
+ ret.the_document_glossary_section = the_document_glossary_section;
+ ret.the_document_bibliography_section = the_document_bibliography_section;
+ ret.the_document_bookindex_section = the_document_bookindex_section;
+ ret.the_document_blurb_section = the_document_blurb_section;
+ return ret;
+ }
+ @system public ST_segnames after_doc_determine_segnames(
+ ObjGenericComposite[] the_document_body_section,
+ ObjGenericComposite[] the_document_endnotes_section,
+ ObjGenericComposite[] the_document_glossary_section,
+ ObjGenericComposite[] the_document_bibliography_section,
+ ObjGenericComposite[] the_document_bookindex_section,
+ ObjGenericComposite[] the_document_blurb_section,
+ string[][string] segnames,
+ int html_segnames_ptr_cntr,
+ int html_segnames_ptr,
+ ) {
+ 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++;
+ }
+ 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;
+ }
+ }
+ 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") {
+ 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++;
+ }
+ 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];
+ }
+ if (obj.metainfo.heading_lev_markup == 4) {
+ obj.ptr.html_segnames = html_segnames_ptr;
+ break;
+ }
+ }
+ 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];
+ }
+ if (obj.metainfo.heading_lev_markup == 4) {
+ obj.ptr.html_segnames = html_segnames_ptr;
+ break;
+ }
+ }
+ html_segnames_ptr_cntr++;
+ }
+ ST_segnames ret;
+ ret.segnames = segnames;
+ ret.html_segnames_ptr_cntr = html_segnames_ptr_cntr;
+ ret.html_segnames_ptr = html_segnames_ptr;
+ return ret;
+ }
+ // decendants
+ @safe auto after_doc_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;
+ }
+ }
+ }
+ 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
+ }
+ }
+ Tuple!(int, int)[] pairs;
+ foreach (pair; _heading_ocn_decendants.byPair) {
+ pairs ~= tuple(pair[0].to!int, pair[1]);
+ }
+ return pairs.sort;
+ }
+ @safe string[] extract_images()(string content_block) {
+ static auto rgx = RgxI();
+ string[] images_;
+ if (auto m = content_block.matchAll(rgx.image)) {
+ images_ ~= m.captures[1];
+ }
+ return images_;
+ }
+ @system auto _image_dimensions(O,M)(O obj, M manifested) {
+ static auto rgx = RgxI();
+ 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",
+ )
+ );
+ }
+ debug(images) { writeln("image without dimensions: ", obj.text); }
+ }
+ return obj;
+ }
+ // links
+ @safe auto _links(O)(O obj) {
+ static auto rgx = RgxI();
+ 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)
+ );
+ }
+ }
+ }
+ return obj;
+ }
struct NodeStructureMetadata {
int lv, lv0, lv1, lv2, lv3, lv4, lv5, lv6, lv7;
int obj_cite_digit;
@@ -6136,11 +6054,8 @@ template docAbstraction() {
}
invariant() {
}
- @safe ObjGenericComposite node_emitter_heading(Hd,TaL,TA,fNr,fNs,fL)(
- string _text,
- string lev_markup_number,
- string lev_collapsed_number,
- Hd dummy_heading_status,
+ @safe ObjGenericComposite node_emitter_heading(O,TaL,TA,SOAT)(
+ O an_object,
string[string] tag_in_seg,
TaL lev_anchor_tag,
TA tag_assoc,
@@ -6148,12 +6063,14 @@ template docAbstraction() {
int cntr_,
int ptr_,
string[] lv_ancestors_txt,
- string is_,
int html_segnames_ptr,
- fNr flag_notes_reg,
- fNs flag_notes_star,
- fL flag_links,
+ SOAT substantive_object_and_anchor_tags_struct,
) {
+ string _text = an_object["substantive"];
+ string lev_markup_number = an_object["lev_markup_number"];
+ string lev_collapsed_number = an_object["lev_collapsed_number"];
+ string dummy_heading_status = an_object["dummy_heading_status"];
+ string is_ = an_object["is"];
debug(asserts) {
static assert(is(typeof(lev) == string));
static assert(is(typeof(obj_cite_digits.object_number) == int));
@@ -6255,75 +6172,75 @@ template docAbstraction() {
default:
break;
}
- ObjGenericComposite _comp_obj_heading_;
- _comp_obj_heading_ = _comp_obj_heading_.init;
- _comp_obj_heading_.metainfo.is_of_part = "body";
- _comp_obj_heading_.metainfo.is_of_section = "body";
- _comp_obj_heading_.metainfo.is_of_type = "para";
- _comp_obj_heading_.metainfo.is_a = "heading";
- _comp_obj_heading_.text = _text.to!string.strip;
- _comp_obj_heading_.metainfo.ocn = obj_cite_digits.object_number;
- _comp_obj_heading_.metainfo.identifier = obj_cite_digits.identifier;
- _comp_obj_heading_.metainfo.dummy_heading = (dummy_heading_status == "t") ? true: false;
- _comp_obj_heading_.metainfo.object_number_off = obj_cite_digits.off;
- // _comp_obj_heading_.metainfo.o_n_book_index = obj_cite_digits.bkidx;
- _comp_obj_heading_.metainfo.object_number_type = obj_cite_digits.type;
- _comp_obj_heading_.tags.segment_anchor_tag_epub = tag_in_seg["seg_lv1to4"];
- _comp_obj_heading_.tags.anchor_tag_html = tag_in_seg["seg_lv4"];
- _comp_obj_heading_.tags.in_segment_html = _comp_obj_heading_.tags.anchor_tag_html;
- _comp_obj_heading_.tags.heading_lev_anchor_tag = lev_anchor_tag;
- _comp_obj_heading_.tags.html_segment_anchor_tag_is = tag_in_seg["seg_lv4"];
- _comp_obj_heading_.tags.epub_segment_anchor_tag_is = tag_in_seg["seg_lv1to4"];
- _comp_obj_heading_.metainfo.heading_lev_markup = (!(lev_markup_number.empty) ? lev_markup_number.to!int : 0);
- _comp_obj_heading_.metainfo.heading_lev_collapsed = (!(lev_collapsed_number.empty) ? lev_collapsed_number.to!int : 0);
- _comp_obj_heading_.metainfo.parent_ocn = p_["object_number"];
- _comp_obj_heading_.metainfo.parent_lev_markup = p_["lev_markup_number"];
- _comp_obj_heading_.tags.heading_ancestors_text = lv_ancestors_txt;
- _comp_obj_heading_.ptr.doc_object = cntr_;
- _comp_obj_heading_.ptr.html_segnames = ((lev_markup_number == "4") ? html_segnames_ptr : 0);
- _comp_obj_heading_.ptr.heading = ptr_;
- _comp_obj_heading_.has.inline_notes_reg = flag_notes_reg;
- _comp_obj_heading_.has.inline_notes_star = flag_notes_star;
- _comp_obj_heading_.has.inline_links = flag_links;
- tag_assoc[_comp_obj_heading_.tags.anchor_tag_html]["seg_lv4"] = _comp_obj_heading_.tags.in_segment_html;
- tag_assoc[_comp_obj_heading_.tags.segment_anchor_tag_epub]["seg_lv1to4"] = _comp_obj_heading_.tags.segment_anchor_tag_epub;
+ ObjGenericComposite comp_obj_;
+ comp_obj_ = comp_obj_.init;
+ comp_obj_.metainfo.is_of_part = "body";
+ comp_obj_.metainfo.is_of_section = "body";
+ comp_obj_.metainfo.is_of_type = "para";
+ comp_obj_.metainfo.is_a = "heading";
+ comp_obj_.text = _text.to!string.strip;
+ comp_obj_.metainfo.ocn = obj_cite_digits.object_number;
+ comp_obj_.metainfo.identifier = obj_cite_digits.identifier;
+ comp_obj_.metainfo.dummy_heading = (dummy_heading_status == "t") ? true: false;
+ comp_obj_.metainfo.object_number_off = obj_cite_digits.off;
+ // comp_obj_.metainfo.o_n_book_index = obj_cite_digits.bkidx;
+ comp_obj_.metainfo.object_number_type = obj_cite_digits.type;
+ comp_obj_.tags.segment_anchor_tag_epub = tag_in_seg["seg_lv1to4"];
+ comp_obj_.tags.anchor_tag_html = tag_in_seg["seg_lv4"];
+ comp_obj_.tags.in_segment_html = comp_obj_.tags.anchor_tag_html;
+ comp_obj_.tags.heading_lev_anchor_tag = lev_anchor_tag;
+ comp_obj_.tags.html_segment_anchor_tag_is = tag_in_seg["seg_lv4"];
+ comp_obj_.tags.epub_segment_anchor_tag_is = tag_in_seg["seg_lv1to4"];
+ comp_obj_.metainfo.heading_lev_markup = (!(lev_markup_number.empty) ? lev_markup_number.to!int : 0);
+ comp_obj_.metainfo.heading_lev_collapsed = (!(lev_collapsed_number.empty) ? lev_collapsed_number.to!int : 0);
+ comp_obj_.metainfo.parent_ocn = p_["object_number"];
+ comp_obj_.metainfo.parent_lev_markup = p_["lev_markup_number"];
+ comp_obj_.tags.heading_ancestors_text = lv_ancestors_txt;
+ comp_obj_.ptr.doc_object = cntr_;
+ comp_obj_.ptr.html_segnames = ((lev_markup_number == "4") ? html_segnames_ptr : 0);
+ comp_obj_.ptr.heading = ptr_;
+ comp_obj_.has.inline_notes_reg = substantive_object_and_anchor_tags_struct.has_notes_reg;
+ comp_obj_.has.inline_notes_star = substantive_object_and_anchor_tags_struct.has_notes_star;
+ comp_obj_.has.inline_links = substantive_object_and_anchor_tags_struct.has_links;
+ tag_assoc[comp_obj_.tags.anchor_tag_html]["seg_lv4"] = comp_obj_.tags.in_segment_html;
+ tag_assoc[comp_obj_.tags.segment_anchor_tag_epub]["seg_lv1to4"] = comp_obj_.tags.segment_anchor_tag_epub;
debug(_node) {
if (lev_markup_number.match(rgx.levels_numbered_headings)) { writeln("* ", _node.to!string); }
}
debug(nodeheading) {
if (lev_markup_number.match(rgx.levels_numbered_headings)) { writeln("* ", _node.to!string); }
}
- assert(_comp_obj_heading_.metainfo.parent_lev_markup <= 7);
- assert(_comp_obj_heading_.metainfo.parent_ocn >= 0);
+ assert(comp_obj_.metainfo.parent_lev_markup <= 7);
+ assert(comp_obj_.metainfo.parent_ocn >= 0);
if (lev_markup_number.match(rgx.levels_numbered_headings)) {
- assert(_comp_obj_heading_.metainfo.heading_lev_markup <= 7);
- assert(_comp_obj_heading_.metainfo.ocn >= 0);
- if (_comp_obj_heading_.metainfo.parent_lev_markup > 0) {
- assert(_comp_obj_heading_.metainfo.parent_lev_markup < _comp_obj_heading_.metainfo.heading_lev_markup);
- if (_comp_obj_heading_.metainfo.ocn != 0) {
- assert(_comp_obj_heading_.metainfo.parent_ocn < _comp_obj_heading_.metainfo.ocn);
+ assert(comp_obj_.metainfo.heading_lev_markup <= 7);
+ assert(comp_obj_.metainfo.ocn >= 0);
+ if (comp_obj_.metainfo.parent_lev_markup > 0) {
+ assert(comp_obj_.metainfo.parent_lev_markup < comp_obj_.metainfo.heading_lev_markup);
+ if (comp_obj_.metainfo.ocn != 0) {
+ assert(comp_obj_.metainfo.parent_ocn < comp_obj_.metainfo.ocn);
}
}
- if (_comp_obj_heading_.metainfo.heading_lev_markup == 0) {
- assert(_comp_obj_heading_.metainfo.parent_lev_markup == DocStructMarkupHeading.h_sect_A);
- } else if (_comp_obj_heading_.metainfo.heading_lev_markup == DocStructMarkupHeading.h_sect_B) {
- assert(_comp_obj_heading_.metainfo.parent_lev_markup == DocStructMarkupHeading.h_sect_A);
- } else if (_comp_obj_heading_.metainfo.heading_lev_markup == DocStructMarkupHeading.h_sect_C) {
- assert(_comp_obj_heading_.metainfo.parent_lev_markup == DocStructMarkupHeading.h_sect_B);
- } else if (_comp_obj_heading_.metainfo.heading_lev_markup == DocStructMarkupHeading.h_sect_D) {
- assert(_comp_obj_heading_.metainfo.parent_lev_markup == DocStructMarkupHeading.h_sect_C);
- } else if (_comp_obj_heading_.metainfo.heading_lev_markup == DocStructMarkupHeading.h_text_1) {
- assert(_comp_obj_heading_.metainfo.parent_lev_markup <= DocStructMarkupHeading.h_sect_D);
- } else if (_comp_obj_heading_.metainfo.heading_lev_markup == DocStructMarkupHeading.h_text_2) {
- assert(_comp_obj_heading_.metainfo.parent_lev_markup == DocStructMarkupHeading.h_text_1);
- } else if (_comp_obj_heading_.metainfo.heading_lev_markup == DocStructMarkupHeading.h_text_3) {
- assert(_comp_obj_heading_.metainfo.parent_lev_markup == DocStructMarkupHeading.h_text_2);
- } else if (_comp_obj_heading_.metainfo.heading_lev_markup == DocStructMarkupHeading.h_text_4) {
- assert(_comp_obj_heading_.metainfo.parent_lev_markup == DocStructMarkupHeading.h_text_3);
- } else if (_comp_obj_heading_.metainfo.heading_lev_markup == DocStructMarkupHeading.h_text_5) {
- }
- }
- return _comp_obj_heading_;
+ if (comp_obj_.metainfo.heading_lev_markup == 0) {
+ assert(comp_obj_.metainfo.parent_lev_markup == DocStructMarkupHeading.h_sect_A);
+ } else if (comp_obj_.metainfo.heading_lev_markup == DocStructMarkupHeading.h_sect_B) {
+ assert(comp_obj_.metainfo.parent_lev_markup == DocStructMarkupHeading.h_sect_A);
+ } else if (comp_obj_.metainfo.heading_lev_markup == DocStructMarkupHeading.h_sect_C) {
+ assert(comp_obj_.metainfo.parent_lev_markup == DocStructMarkupHeading.h_sect_B);
+ } else if (comp_obj_.metainfo.heading_lev_markup == DocStructMarkupHeading.h_sect_D) {
+ assert(comp_obj_.metainfo.parent_lev_markup == DocStructMarkupHeading.h_sect_C);
+ } else if (comp_obj_.metainfo.heading_lev_markup == DocStructMarkupHeading.h_text_1) {
+ assert(comp_obj_.metainfo.parent_lev_markup <= DocStructMarkupHeading.h_sect_D);
+ } else if (comp_obj_.metainfo.heading_lev_markup == DocStructMarkupHeading.h_text_2) {
+ assert(comp_obj_.metainfo.parent_lev_markup == DocStructMarkupHeading.h_text_1);
+ } else if (comp_obj_.metainfo.heading_lev_markup == DocStructMarkupHeading.h_text_3) {
+ assert(comp_obj_.metainfo.parent_lev_markup == DocStructMarkupHeading.h_text_2);
+ } else if (comp_obj_.metainfo.heading_lev_markup == DocStructMarkupHeading.h_text_4) {
+ assert(comp_obj_.metainfo.parent_lev_markup == DocStructMarkupHeading.h_text_3);
+ } else if (comp_obj_.metainfo.heading_lev_markup == DocStructMarkupHeading.h_text_5) {
+ }
+ }
+ return comp_obj_;
}
invariant() {
}