diff options
| author | Ralph Amissah <ralph.amissah@gmail.com> | 2026-08-30 13:28:10 -0400 |
|---|---|---|
| committer | Ralph Amissah <ralph.amissah@gmail.com> | 2026-08-30 13:28:10 -0400 |
| commit | 8944b13ecdfeb4908cb70974e57d905775055ccf (patch) | |
| tree | af039241a98863e7eeeb2ba0cd852838419422a3 /org/ocda.org | |
| parent | file rename: out_src_abstraction_ocda_peg_ssp.org (diff) | |
abstraction/.ssp: fix doc structure representation
fix to --abstraction/.ssp: fix document structure, representation
parent, ancestors, children. Make parent_ocn, the marked-up and
collapsed ancestor arrays, and the children correctly represent
the document structure. fixed
(assisted by Claude-Code)
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01836BxBb8LvVKJ8sBg7Dx6U
Diffstat (limited to 'org/ocda.org')
| -rw-r--r-- | org/ocda.org | 80 |
1 files changed, 59 insertions, 21 deletions
diff --git a/org/ocda.org b/org/ocda.org index 3a287e8..25a5d8e 100644 --- a/org/ocda.org +++ b/org/ocda.org @@ -1039,16 +1039,11 @@ ST_endnotes en_st = note_section.backmatter_endnote_objects(obj_cite_digits, opt 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); @@ -1338,6 +1333,25 @@ if (the_document_blurb_section.length > 1) { // writeln("blurb"); 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( @@ -1449,19 +1463,43 @@ if (the_document_body_section.length > 1) { /+ ↓ 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) { |
