diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/sisudoc/io_out/create_abstraction_txt.d | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/sisudoc/io_out/create_abstraction_txt.d b/src/sisudoc/io_out/create_abstraction_txt.d index 7d0425c..d393f61 100644 --- a/src/sisudoc/io_out/create_abstraction_txt.d +++ b/src/sisudoc/io_out/create_abstraction_txt.d @@ -162,6 +162,16 @@ 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"]; @@ -201,6 +211,15 @@ template spineAbstractionTxt() { if (obj.metainfo.last_descendant_ocn != 0) 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) { + string[] ch; + foreach (c; heading_children[obj.metainfo.ocn]) { + ch ~= c.to!string; + } + output ~= ".children: " ~ ch.join(" "); + } + /+ ↓ ancestors (only if non-zero) +/ { bool has_anc = false; |
