diff options
Diffstat (limited to 'src/sisudoc/ocda/meta/metadoc_from_src.d')
| -rw-r--r-- | src/sisudoc/ocda/meta/metadoc_from_src.d | 80 |
1 files changed, 59 insertions, 21 deletions
diff --git a/src/sisudoc/ocda/meta/metadoc_from_src.d b/src/sisudoc/ocda/meta/metadoc_from_src.d index 7fcf3bb..dec00c6 100644 --- a/src/sisudoc/ocda/meta/metadoc_from_src.d +++ b/src/sisudoc/ocda/meta/metadoc_from_src.d @@ -933,16 +933,11 @@ template docAbstraction() { the_document_head_section ~= the_document_body_section[0]; the_document_body_section = the_document_body_section[1..$]; } - { // 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 ancestors: moved to run after every sections ocn have been + generated (the backmatter section headings are given their ocn in the + per section loops below) and ahead of descendants & children which + depend on parent_ocn + +/ { // 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); @@ -1232,6 +1227,25 @@ template docAbstraction() { obj = _links(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_head_section + ); + the_document_body_section = get_ancestors.the_document_body_section; + the_document_head_section = get_ancestors.the_document_head_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; + } // get descendants if (the_document_body_section.length > 1) { auto pairs = after_doc_get_descendants( @@ -1343,19 +1357,43 @@ template docAbstraction() { /+ ↓ compute children_headings for heading objects +/ { int[][int] heading_children; - foreach (obj; the_document_body_section) { - if (obj.metainfo.is_a == "heading" && obj.metainfo.parent_ocn != 0) { - heading_children[obj.metainfo.parent_ocn] ~= obj.metainfo.ocn; - } - } - foreach (ref obj; the_document_head_section) { - if (obj.metainfo.is_a == "heading" && obj.metainfo.ocn in heading_children) { - obj.metainfo.children_headings = heading_children[obj.metainfo.ocn]; + /+ ↓ substantive headings only (ocn 0 is an author suppressed heading and + is not citable, it does not have a place in the citation structure), + gathered across every section not the body alone + +/ + foreach (section; [ + the_document_head_section, + the_document_body_section, + the_document_endnotes_section, + the_document_glossary_section, + the_document_bibliography_section, + the_document_bookindex_section, + the_document_blurb_section, + ]) { + foreach (obj; section) { + if (obj.metainfo.is_a == "heading" + && obj.metainfo.ocn != 0 + && obj.metainfo.parent_ocn != 0 + && obj.metainfo.parent_ocn != obj.metainfo.ocn + ) { + heading_children[obj.metainfo.parent_ocn] ~= obj.metainfo.ocn; + } } } - foreach (ref obj; the_document_body_section) { - if (obj.metainfo.is_a == "heading" && obj.metainfo.ocn in heading_children) { - obj.metainfo.children_headings = heading_children[obj.metainfo.ocn]; + /+ ↓ slice copies, the elements written to are the same elements +/ + foreach (section; [ + the_document_head_section, + the_document_body_section, + the_document_endnotes_section, + the_document_glossary_section, + the_document_bibliography_section, + the_document_bookindex_section, + the_document_blurb_section, + ]) { + foreach (ref obj; section) { + if (obj.metainfo.is_a == "heading" && obj.metainfo.ocn in heading_children) { + obj.metainfo.children_headings = heading_children[obj.metainfo.ocn]; + } } } // if (opt_action.vox_gt_2) { |
