diff options
| author | Ralph Amissah <ralph.amissah@gmail.com> | 2026-05-03 18:10:11 -0400 |
|---|---|---|
| committer | Ralph Amissah <ralph.amissah@gmail.com> | 2026-05-04 11:44:55 -0400 |
| commit | 559b8b714a9694ba561009be5cd54cde3495b005 (patch) | |
| tree | ca8b55144194ddeac440025c6bf8b3c07767c104 | |
| parent | org: editor utils moved, editorconfig added to env (diff) | |
org/ out of sync with ./src (sync)
| -rw-r--r-- | org/ocda.org | 19 | ||||
| -rw-r--r-- | org/ocda_obj_setter.org | 1 | ||||
| -rw-r--r-- | org/out_src_abstraction_peg_text.org | 14 |
3 files changed, 22 insertions, 12 deletions
diff --git a/org/ocda.org b/org/ocda.org index d930917..f822f8d 100644 --- a/org/ocda.org +++ b/org/ocda.org @@ -1364,6 +1364,25 @@ 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]; + } + } + 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]; + } + } +} // TODO // - note create/insert heading object sole purpose eof close all open tags // sort out: diff --git a/org/ocda_obj_setter.org b/org/ocda_obj_setter.org index 76b7ca5..3da8b1d 100644 --- a/org/ocda_obj_setter.org +++ b/org/ocda_obj_setter.org @@ -121,6 +121,7 @@ struct DocObj_MetaInfo_ { int parent_lev_markup = 0; int parent_ocn = 0; int last_descendant_ocn = 0; + int[] children_headings; ubyte[32] sha256; } #+END_SRC diff --git a/org/out_src_abstraction_peg_text.org b/org/out_src_abstraction_peg_text.org index 2f2c798..7b7b600 100644 --- a/org/out_src_abstraction_peg_text.org +++ b/org/out_src_abstraction_peg_text.org @@ -144,16 +144,6 @@ template spineAbstractionTxt() { output ~= "}"; output ~= ""; - /+ ↓ pre-compute heading children map (one pass over body) +/ - int[][int] heading_children; // parent_ocn -> [child heading OCNs] - if ("body" in doc_abstraction) { - foreach (obj; doc_abstraction["body"]) { - if (obj.metainfo.is_a == "heading" && obj.metainfo.parent_ocn != 0) { - heading_children[obj.metainfo.parent_ocn] ~= obj.metainfo.ocn; - } - } - } - /+ ↓ document sections +/ string[] section_order = ["head", "toc", "body", "endnotes", "glossary", "bibliography", "bookindex", "blurb"]; @@ -194,9 +184,9 @@ template spineAbstractionTxt() { output ~= ".last_descendant: " ~ obj.metainfo.last_descendant_ocn.to!string; /+ ↓ child headings (from pre-computed map) +/ - if (obj.metainfo.is_a == "heading" && obj.metainfo.ocn in heading_children) { + if (obj.metainfo.children_headings.length > 0) { string[] ch; - foreach (c; heading_children[obj.metainfo.ocn]) { + foreach (c; obj.metainfo.children_headings) { ch ~= c.to!string; } output ~= ".children: " ~ ch.join(" "); |
