aboutsummaryrefslogtreecommitdiffhomepage
path: root/org/ao_doc_abstraction.org
diff options
context:
space:
mode:
authorRalph Amissah <ralph@amissah.com>2017-05-01 18:46:11 -0400
committerRalph Amissah <ralph@amissah.com>2019-04-10 15:14:14 -0400
commita9a46fca7397aaa357bfdc2b98e181617bb6887b (patch)
tree4a3c214b8139204cdb4cce723f14da7bd34a939f /org/ao_doc_abstraction.org
parentxml family, special characters, deal with once (diff)
xmls work particularly with epub output
Diffstat (limited to 'org/ao_doc_abstraction.org')
-rw-r--r--org/ao_doc_abstraction.org151
1 files changed, 104 insertions, 47 deletions
diff --git a/org/ao_doc_abstraction.org b/org/ao_doc_abstraction.org
index 93768c1..878f1a0 100644
--- a/org/ao_doc_abstraction.org
+++ b/org/ao_doc_abstraction.org
@@ -605,6 +605,7 @@ auto note_section = NotesSection();
auto bookindex_extract_hash = BookIndexNuggetHash();
string[][string] lev4_subtoc;
string[] html_segnames=["toc"];
+int cnt1 = 1; int cnt2 = 1; int cnt3 = 1;
#+END_SRC
** 2. _loop: process document body_ [+6] :loop:
@@ -725,6 +726,7 @@ if there is a glossary section you need to:
comp_obj_heading_.text = "Glossary";
comp_obj_heading_.ocn = 0;
comp_obj_heading_.obj_cite_number = "";
+ comp_obj_heading_.segment_anchor_tag = "_part_glossary";
comp_obj_heading_.marked_up_level = "B";
comp_obj_heading_.heading_lev_markup = 1;
comp_obj_heading_.heading_lev_collapsed = 1;
@@ -806,6 +808,7 @@ if there is a blurb section you need to:
comp_obj_heading_.text = "Blurb";
comp_obj_heading_.ocn = 0;
comp_obj_heading_.obj_cite_number = "";
+ comp_obj_heading_.segment_anchor_tag = "_part_blurb";
comp_obj_heading_.marked_up_level = "B";
comp_obj_heading_.heading_lev_markup = 1;
comp_obj_heading_.heading_lev_collapsed = 1;
@@ -1143,8 +1146,28 @@ if ((type["heading"] == State.on)
segment_anchor_tag_that_object_belongs_to = anchor_tag_;
segment_anchor_tag_that_object_belongs_to_uri = anchor_tag_ ~ ".fnSuffix#" ~ obj_cite_number.to!string;
} else if (an_object["lev_markup_number"].to!int < 4) {
- segment_anchor_tag_that_object_belongs_to = "";
- segment_anchor_tag_that_object_belongs_to_uri = "";
+ string segn;
+ switch (an_object["lev_markup_number"].to!int) {
+ case 0:
+ segn = "_the_title";
+ goto default;
+ case 1:
+ segn = "_part_" ~ cnt1.to!string;
+ ++cnt1;
+ goto default;
+ case 2:
+ segn = "_part_" ~ cnt1.to!string ~ "_" ~ cnt2.to!string;
+ ++cnt2;
+ goto default;
+ case 3:
+ segn = "_part_" ~ cnt1.to!string ~ "_" ~ cnt2.to!string ~ "_" ~ cnt3.to!string;
+ ++cnt3;
+ goto default;
+ default:
+ segment_anchor_tag_that_object_belongs_to = segn;
+ segment_anchor_tag_that_object_belongs_to_uri = segn ~ ".fnSuffix";
+ break;
+ }
}
an_object["bookindex_nugget"] =
("bookindex_nugget" in an_object) ? an_object["bookindex_nugget"] : "";
@@ -1390,6 +1413,7 @@ if (biblio_ordered.length > 0) {
comp_obj_heading_.text = "Bibliography";
comp_obj_heading_.ocn = 0;
comp_obj_heading_.obj_cite_number = "";
+ comp_obj_heading_.segment_anchor_tag = "_part_bibliography";
comp_obj_heading_.marked_up_level = "B";
comp_obj_heading_.heading_lev_markup = 1;
comp_obj_heading_.heading_lev_collapsed = 1;
@@ -1704,7 +1728,7 @@ the_document_head_section ~= the_document_body_section[0];
the_document_body_section=the_document_body_section[1..$];
#+END_SRC
-*** minor loops :post:
+*** _minor loops_ :post:
**** 1. loop: backmatter loop up to lev4: html_segnames, set backmatter pointers
could optimise by
@@ -1817,11 +1841,15 @@ auto extract_images(S)(S content_block) {
}
return images_;
}
+string[] segnames_0_4;
foreach (ref obj; the_document_head_section) {
if (obj.is_a == "heading") {
debug(dom) {
writeln(obj.text);
}
+ if (obj.heading_lev_markup <= 4) {
+ segnames_0_4 ~= obj.segment_anchor_tag;
+ }
if ((opt_action_bool["html"])
|| (opt_action_bool["html_scroll"])
|| (opt_action_bool["html_seg"])
@@ -1839,9 +1867,12 @@ if (the_table_of_contents_section["scroll"].length > 1) {
dom_collapsed_buffer = dom_collapsed.dup;
foreach (ref obj; the_table_of_contents_section["scroll"]) {
if (obj.is_a == "heading") {
- if (obj.heading_lev_markup == 4) {
- obj.segname_next = html_segnames[obj.ptr_html_segnames + 1];
- assert(obj.segment_anchor_tag == html_segnames[obj.ptr_html_segnames]);
+ if (obj.heading_lev_markup <= 4) {
+ segnames_0_4 ~= obj.segment_anchor_tag;
+ if (obj.heading_lev_markup == 4) {
+ obj.segname_next = html_segnames[obj.ptr_html_segnames + 1];
+ assert(obj.segment_anchor_tag == html_segnames[obj.ptr_html_segnames]);
+ }
}
if ((opt_action_bool["html"])
|| (opt_action_bool["html_scroll"])
@@ -1862,9 +1893,12 @@ if (the_table_of_contents_section["scroll"].length > 1) {
debug(dom) {
writeln(obj.text);
}
- if (obj.heading_lev_markup == 4) {
- obj.segname_next = html_segnames[obj.ptr_html_segnames + 1];
- assert(obj.segment_anchor_tag == html_segnames[obj.ptr_html_segnames]);
+ if (obj.heading_lev_markup <= 4) {
+ segnames_0_4 ~= obj.segment_anchor_tag;
+ if (obj.heading_lev_markup == 4) {
+ obj.segname_next = html_segnames[obj.ptr_html_segnames + 1];
+ assert(obj.segment_anchor_tag == html_segnames[obj.ptr_html_segnames]);
+ }
}
if ((opt_action_bool["html"])
|| (opt_action_bool["html_scroll"])
@@ -1886,13 +1920,16 @@ if (the_document_body_section.length > 1) {
debug(dom) {
writeln(obj.text);
}
- if (obj.heading_lev_markup == 4) {
- obj.lev4_subtoc = lev4_subtoc[obj.segment_anchor_tag];
- obj.segname_prev = html_segnames[obj.ptr_html_segnames - 1];
- if (html_segnames.length > obj.ptr_html_segnames + 1) {
- obj.segname_next = html_segnames[obj.ptr_html_segnames + 1];
+ if (obj.heading_lev_markup <= 4) {
+ segnames_0_4 ~= obj.segment_anchor_tag;
+ if (obj.heading_lev_markup == 4) {
+ obj.lev4_subtoc = lev4_subtoc[obj.segment_anchor_tag];
+ obj.segname_prev = html_segnames[obj.ptr_html_segnames - 1];
+ if (html_segnames.length > obj.ptr_html_segnames + 1) {
+ obj.segname_next = html_segnames[obj.ptr_html_segnames + 1];
+ }
+ assert(obj.segment_anchor_tag == html_segnames[obj.ptr_html_segnames]);
}
- assert(obj.segment_anchor_tag == html_segnames[obj.ptr_html_segnames]);
}
if ((opt_action_bool["html"])
|| (opt_action_bool["html_scroll"])
@@ -1921,12 +1958,15 @@ if (the_endnotes_section.length > 1) {
debug(dom) {
writeln(obj.text);
}
- if (obj.heading_lev_markup == 4) {
- obj.segname_prev = html_segnames[obj.ptr_html_segnames - 1];
- if (html_segnames.length > obj.ptr_html_segnames + 1) {
- obj.segname_next = html_segnames[obj.ptr_html_segnames + 1];
+ if (obj.heading_lev_markup <= 4) {
+ segnames_0_4 ~= obj.segment_anchor_tag;
+ if (obj.heading_lev_markup == 4) {
+ obj.segname_prev = html_segnames[obj.ptr_html_segnames - 1];
+ if (html_segnames.length > obj.ptr_html_segnames + 1) {
+ obj.segname_next = html_segnames[obj.ptr_html_segnames + 1];
+ }
+ assert(obj.segment_anchor_tag == html_segnames[obj.ptr_html_segnames]);
}
- assert(obj.segment_anchor_tag == html_segnames[obj.ptr_html_segnames]);
}
if ((opt_action_bool["html"])
|| (opt_action_bool["html_scroll"])
@@ -1948,12 +1988,15 @@ if (the_glossary_section.length > 1) {
debug(dom) {
writeln(obj.text);
}
- if (obj.heading_lev_markup == 4) {
- obj.segname_prev = html_segnames[obj.ptr_html_segnames - 1];
- if (html_segnames.length > obj.ptr_html_segnames + 1) {
- obj.segname_next = html_segnames[obj.ptr_html_segnames + 1];
+ if (obj.heading_lev_markup <= 4) {
+ segnames_0_4 ~= obj.segment_anchor_tag;
+ if (obj.heading_lev_markup == 4) {
+ obj.segname_prev = html_segnames[obj.ptr_html_segnames - 1];
+ if (html_segnames.length > obj.ptr_html_segnames + 1) {
+ obj.segname_next = html_segnames[obj.ptr_html_segnames + 1];
+ }
+ assert(obj.segment_anchor_tag == html_segnames[obj.ptr_html_segnames]);
}
- assert(obj.segment_anchor_tag == html_segnames[obj.ptr_html_segnames]);
}
if ((opt_action_bool["html"])
|| (opt_action_bool["html_scroll"])
@@ -1975,12 +2018,15 @@ if (the_bibliography_section.length > 1) {
debug(dom) {
writeln(obj.text);
}
- if (obj.heading_lev_markup == 4) {
- obj.segname_prev = html_segnames[obj.ptr_html_segnames - 1];
- if (html_segnames.length > obj.ptr_html_segnames + 1) {
- obj.segname_next = html_segnames[obj.ptr_html_segnames + 1];
+ if (obj.heading_lev_markup <= 4) {
+ segnames_0_4 ~= obj.segment_anchor_tag;
+ if (obj.heading_lev_markup == 4) {
+ obj.segname_prev = html_segnames[obj.ptr_html_segnames - 1];
+ if (html_segnames.length > obj.ptr_html_segnames + 1) {
+ obj.segname_next = html_segnames[obj.ptr_html_segnames + 1];
+ }
+ assert(obj.segment_anchor_tag == html_segnames[obj.ptr_html_segnames]);
}
- assert(obj.segment_anchor_tag == html_segnames[obj.ptr_html_segnames]);
}
if ((opt_action_bool["html"])
|| (opt_action_bool["html_scroll"])
@@ -2003,12 +2049,15 @@ if (the_bookindex_section["scroll"].length > 1) {
if (obj.is_a == "heading") {
debug(dom) {
}
- if (obj.heading_lev_markup == 4) {
- obj.segname_prev = html_segnames[obj.ptr_html_segnames - 1];
- if (html_segnames.length > obj.ptr_html_segnames + 1) {
- obj.segname_next = html_segnames[obj.ptr_html_segnames + 1];
+ if (obj.heading_lev_markup <= 4) {
+ segnames_0_4 ~= obj.segment_anchor_tag;
+ if (obj.heading_lev_markup == 4) {
+ obj.segname_prev = html_segnames[obj.ptr_html_segnames - 1];
+ if (html_segnames.length > obj.ptr_html_segnames + 1) {
+ obj.segname_next = html_segnames[obj.ptr_html_segnames + 1];
+ }
+ assert(obj.segment_anchor_tag == html_segnames[obj.ptr_html_segnames]);
}
- assert(obj.segment_anchor_tag == html_segnames[obj.ptr_html_segnames]);
}
if ((opt_action_bool["html"])
|| (opt_action_bool["html_scroll"])
@@ -2029,12 +2078,15 @@ if (the_bookindex_section["scroll"].length > 1) {
debug(dom) {
writeln(obj.text);
}
- if (obj.heading_lev_markup == 4) {
- obj.segname_prev = html_segnames[obj.ptr_html_segnames - 1];
- if (html_segnames.length > obj.ptr_html_segnames + 1) {
- obj.segname_next = html_segnames[obj.ptr_html_segnames + 1];
+ if (obj.heading_lev_markup <= 4) {
+ segnames_0_4 ~= obj.segment_anchor_tag;
+ if (obj.heading_lev_markup == 4) {
+ obj.segname_prev = html_segnames[obj.ptr_html_segnames - 1];
+ if (html_segnames.length > obj.ptr_html_segnames + 1) {
+ obj.segname_next = html_segnames[obj.ptr_html_segnames + 1];
+ }
+ assert(obj.segment_anchor_tag == html_segnames[obj.ptr_html_segnames]);
}
- assert(obj.segment_anchor_tag == html_segnames[obj.ptr_html_segnames]);
}
if ((opt_action_bool["html"])
|| (opt_action_bool["html_scroll"])
@@ -2056,12 +2108,15 @@ if (the_blurb_section.length > 1) {
debug(dom) {
writeln(obj.text);
}
- if (obj.heading_lev_markup == 4) {
- obj.segname_prev = html_segnames[obj.ptr_html_segnames - 1];
- if (html_segnames.length > obj.ptr_html_segnames + 1) {
- obj.segname_next = html_segnames[obj.ptr_html_segnames + 1];
+ if (obj.heading_lev_markup <= 4) {
+ segnames_0_4 ~= obj.segment_anchor_tag;
+ if (obj.heading_lev_markup == 4) {
+ obj.segname_prev = html_segnames[obj.ptr_html_segnames - 1];
+ if (html_segnames.length > obj.ptr_html_segnames + 1) {
+ obj.segname_next = html_segnames[obj.ptr_html_segnames + 1];
+ }
+ assert(obj.segment_anchor_tag == html_segnames[obj.ptr_html_segnames]);
}
- assert(obj.segment_anchor_tag == html_segnames[obj.ptr_html_segnames]);
}
if ((opt_action_bool["html"])
|| (opt_action_bool["html_scroll"])
@@ -2205,6 +2260,7 @@ auto t = tuple(
document_the,
docSectKeysSeq!()(document_section_keys_sequenced),
segnames,
+ segnames_0_4,
images,
);
return t;
@@ -3436,7 +3492,6 @@ void _block_flag_line_empty_(B)(
auto substantive_obj_misc_tuple =
obj_im.obj_inline_markup_and_anchor_tags_and_misc(an_object, an_object_key, dochead_make_aa);
an_object["substantive"] = substantive_obj_misc_tuple[sObj.content];
- anchor_tags = substantive_obj_misc_tuple[sObj.anchor_tags];
comp_obj_block = comp_obj_block.init;
comp_obj_block.use = "body";
comp_obj_block.is_of = "block";
@@ -3484,7 +3539,7 @@ void _block_flag_line_empty_(B)(
comp_obj_poem_ocn.is_a = "poem";
comp_obj_poem_ocn.ocn = obj_cite_number;
comp_obj_poem_ocn.obj_cite_number = (obj_cite_number_poem["start"], obj_cite_number_poem["end"]);
- comp_obj_poem_ocn.text = ""; // an_object["substantive"];
+ comp_obj_poem_ocn.text = "";
the_document_body_section ~= comp_obj_poem_ocn;
type["blocks"] = TriState.off;
type["poem"] = TriState.off;
@@ -5838,6 +5893,7 @@ struct BookIndexReportSection {
comp_obj_heading_.text = "Book Index";
comp_obj_heading_.ocn = 0;
comp_obj_heading_.obj_cite_number = "";
+ comp_obj_heading_.segment_anchor_tag = "_part_book_index";
comp_obj_heading_.marked_up_level = "B";
comp_obj_heading_.heading_lev_markup = 1;
comp_obj_heading_.heading_lev_collapsed = 1;
@@ -6088,6 +6144,7 @@ struct NotesSection {
comp_obj_heading_.text = "Endnotes";
comp_obj_heading_.ocn = 0;
comp_obj_heading_.obj_cite_number = "";
+ comp_obj_heading_.segment_anchor_tag = "_part_endnotes";
comp_obj_heading_.marked_up_level = "B";
comp_obj_heading_.heading_lev_markup = 1;
comp_obj_heading_.heading_lev_collapsed = 1;