aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/sisudoc/ocda/abstraction
diff options
context:
space:
mode:
Diffstat (limited to 'src/sisudoc/ocda/abstraction')
-rw-r--r--src/sisudoc/ocda/abstraction/db_in.d1
-rw-r--r--src/sisudoc/ocda/abstraction/doc_has.d40
-rw-r--r--src/sisudoc/ocda/abstraction/ssp.d12
-rw-r--r--src/sisudoc/ocda/abstraction/ssp_in.d1
4 files changed, 31 insertions, 23 deletions
diff --git a/src/sisudoc/ocda/abstraction/db_in.d b/src/sisudoc/ocda/abstraction/db_in.d
index 0d78f12..6e9b0e2 100644
--- a/src/sisudoc/ocda/abstraction/db_in.d
+++ b/src/sisudoc/ocda/abstraction/db_in.d
@@ -277,6 +277,7 @@ template spineAbstractionDbRead() {
obj.tags.segment_anchor_tag_epub = row[_col["segment_epub"]].as!string;
obj.tags.html_segment_anchor_tag_is = row[_col["segment_html_is"]].as!string;
obj.tags.epub_segment_anchor_tag_is = row[_col["segment_epub_is"]].as!string;
+ obj.tags.segment_lv4_is = row[_col["segment_lv4_is"]].as!string;
obj.tags.anchor_tag_html = row[_col["anchor"]].as!string;
obj.tags.heading_lev_anchor_tag = row[_col["heading_lev_anchor"]].as!string;
{
diff --git a/src/sisudoc/ocda/abstraction/doc_has.d b/src/sisudoc/ocda/abstraction/doc_has.d
index 75a4640..051da33 100644
--- a/src/sisudoc/ocda/abstraction/doc_has.d
+++ b/src/sisudoc/ocda/abstraction/doc_has.d
@@ -163,20 +163,6 @@ template spineDocHasFromAbstraction() {
_out.quotes = _count(_doc_has_block, "quotes");
string[] _images;
string[string][string] _tag_assoc;
- /+ ↓ keys waiting for the level 4 segment that will hold them.
-
- a heading above level 4 opens no html segment, so a cross reference
- to it has to land on the next level 4 heading, which has not been
- seen yet when the heading is read. The parser does this the same
- way, back-filling a pending tag when the level 4 heading arrives
- (metadoc_from_src.d, "tag_assoc[lv0_to_lv3_html_tag]"), and the
- order of the objects is what both are reading it from.
- +/
- string[] _awaiting_lv4;
- void _backfill(string _seg) {
- foreach (_k; _awaiting_lv4) { _tag_assoc[_k]["seg_lv4"] = _seg; }
- _awaiting_lv4 = [];
- }
/+ ↓ segnames["html"] is seeded with the toc, which is a segment of its
own before any level 4 heading opens one +/
_out.segnames_lv4 ~= "toc";
@@ -226,6 +212,7 @@ template spineDocHasFromAbstraction() {
+/
if (obj.tags.heading_lev_anchor_tag.length > 0
&& obj.tags.in_segment_html.length > 0
+ && obj.metainfo.heading_lev_markup >= 4
) {
_tag_assoc[obj.tags.heading_lev_anchor_tag]["seg_lv4"]
= obj.tags.in_segment_html;
@@ -245,14 +232,23 @@ template spineDocHasFromAbstraction() {
if (obj.metainfo.heading_lev_markup <= 4) {
_out.segnames_lv_0_to_4 ~= obj.tags.segment_anchor_tag_epub;
}
- if (obj.metainfo.heading_lev_markup == 4) {
- if (_section == "body") { _out.segnames_lv4 ~= obj.tags.anchor_tag_html; }
- /+ ↓ this is the segment the headings above it were waiting for +/
- _backfill(obj.tags.in_segment_html);
- } else if (obj.metainfo.heading_lev_markup < 4) {
- foreach (_k; [obj.metainfo.identifier, obj.tags.heading_lev_anchor_tag,
- obj.tags.anchor_tag_html]) {
- if (_k.length > 0) { _awaiting_lv4 ~= _k; }
+ if (_section == "body" && obj.metainfo.heading_lev_markup == 4) {
+ _out.segnames_lv4 ~= obj.tags.anchor_tag_html;
+ }
+ /+ ↓ a heading above level 4 opens no html segment of its own, so
+ a cross reference to it lands on the level 4 segment that
+ follows. That is .segment_lv4_is, resolved in ocda where the
+ finished sections are to hand and carried by the artefact, so
+ there is nothing to work out here
+ +/
+ if (obj.tags.segment_lv4_is.length > 0) {
+ /+ ↓ seg_lv4 only, and not through heading_lev_anchor_tag: that
+ names the level 4 heading itself, whose own entry says it
+ opens that segment rather than merely sits in it. epub
+ segments go down to level 1, so seg_lv1to4 is untouched
+ +/
+ foreach (_k; [obj.metainfo.identifier, obj.tags.anchor_tag_html]) {
+ if (_k.length > 0) { _tag_assoc[_k]["seg_lv4"] = obj.tags.segment_lv4_is; }
}
}
}
diff --git a/src/sisudoc/ocda/abstraction/ssp.d b/src/sisudoc/ocda/abstraction/ssp.d
index 6b487d7..487a33b 100644
--- a/src/sisudoc/ocda/abstraction/ssp.d
+++ b/src/sisudoc/ocda/abstraction/ssp.d
@@ -61,7 +61,9 @@ module sisudoc.ocda.abstraction.ssp;
1.1 2026-09-10 @source block; the document metadata the output writers
read carried in full (14 meta and 3 make properties
- added); was 0.1
+ added); .segment_lv4_is, the segment a cross
+ reference to a heading above level 4 lands on;
+ was 0.1
+/
enum ssp_format_version = "1.1";
enum ssp_format_version_major = "1";
@@ -380,6 +382,14 @@ template sspObjectRecord() {
if (obj.tags.epub_segment_anchor_tag_is.length > 0) {
output ~= ".segment_epub_is: " ~ obj.tags.epub_segment_anchor_tag_is;
}
+ /+ ↓ the level 4 segment a cross reference to this heading lands on,
+ emitted only where it is not the segment the heading sits in, which
+ is every heading at level 4 or below +/
+ if (obj.tags.segment_lv4_is.length > 0
+ && obj.tags.segment_lv4_is != obj.tags.html_segment_anchor_tag_is
+ ) {
+ output ~= ".segment_lv4_is: " ~ obj.tags.segment_lv4_is;
+ }
/+ ↓ heading ancestors text +/
{
bool has_hat = false;
diff --git a/src/sisudoc/ocda/abstraction/ssp_in.d b/src/sisudoc/ocda/abstraction/ssp_in.d
index 873cb7e..59a5b80 100644
--- a/src/sisudoc/ocda/abstraction/ssp_in.d
+++ b/src/sisudoc/ocda/abstraction/ssp_in.d
@@ -311,6 +311,7 @@ template spineAbstractionRead() {
case "segment_epub": obj.tags.segment_anchor_tag_epub = _val; break;
case "segment_html_is": obj.tags.html_segment_anchor_tag_is = _val; break;
case "segment_epub_is": obj.tags.epub_segment_anchor_tag_is = _val; break;
+ case "segment_lv4_is": obj.tags.segment_lv4_is = _val; break;
case "heading_ancestors_text":
{
string[8] _h;