aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/sisudoc/ocda/meta/metadoc_from_src.d
diff options
context:
space:
mode:
Diffstat (limited to 'src/sisudoc/ocda/meta/metadoc_from_src.d')
-rw-r--r--src/sisudoc/ocda/meta/metadoc_from_src.d50
1 files changed, 47 insertions, 3 deletions
diff --git a/src/sisudoc/ocda/meta/metadoc_from_src.d b/src/sisudoc/ocda/meta/metadoc_from_src.d
index 3670a39..cbd25e2 100644
--- a/src/sisudoc/ocda/meta/metadoc_from_src.d
+++ b/src/sisudoc/ocda/meta/metadoc_from_src.d
@@ -148,6 +148,8 @@ template docAbstraction() {
"start" : "",
"end" : ""
];
+ /+ ↓ where the open poem's first verse will go, -1 when no poem is open +/
+ long _poem_open_idx = -1;
string[] lv_ancestors_txt = [ "", "", "", "", "", "", "", "", ];
/+ ↓ dom structure state, per document (not shared, parallel safe) +/
int[] dom_structure_markedup_tags_status = [ 0, 0, 0, 0, 0, 0, 0, 0,];
@@ -426,6 +428,7 @@ template docAbstraction() {
object_reset(an_object);
processing.remove("verse");
object_number_poem["start"] = obj_cite_digits.object_number.to!string;
+ _poem_open_idx = the_document_body_section.length.to!long;
}
{
ST_txt_by_line_block_start _get = line.txt_by_line_block_start(pith, dochas, object_number_poem);
@@ -602,6 +605,46 @@ template docAbstraction() {
pith = _get.pith;
}
}
+ /+ ↓ poem closed: poem object has been appended after its last verse.
+ It is a container, not a citable unit - its verses are - so it
+ carries no ocn of its own and states the range of its verses
+ instead, and it goes to the head of them, so that a writer
+ meeting it knows what follows and where it ends, and can wrap the
+ verses in one pass. (an issue with a note in the last verse of a
+ poem has been addressed)
+ +/
+ if (_poem_open_idx >= 0
+ && the_document_body_section.length > _poem_open_idx + 1
+ && the_document_body_section[$-1].metainfo.is_a == "poem"
+ ) {
+ size_t _s = _poem_open_idx.to!size_t;
+ size_t _p = the_document_body_section.length - 1;
+ size_t _first = _s;
+ while (_first < _p && the_document_body_section[_first].metainfo.is_a != "verse") { ++_first; }
+ size_t _last = _p;
+ while (_last > _s && the_document_body_section[_last - 1].metainfo.is_a != "verse") { --_last; }
+ if (_first < _p && _last > _s) {
+ --_last;
+ if ((the_document_body_section[_last].text).match(rgx.inline_notes_al_all_note)) {
+ object_notes = note_section.gather_notes_for_endnote_section(
+ the_document_body_section,
+ tag_in_seg,
+ (_last).to!int,
+ );
+ }
+ auto _poem = the_document_body_section[_p];
+ _poem.metainfo.ocn_range_first = the_document_body_section[_first].metainfo.ocn;
+ _poem.metainfo.ocn_range_last = the_document_body_section[_last].metainfo.ocn;
+ _poem.tags.html_segment_anchor_tag_is = the_document_body_section[_first].tags.html_segment_anchor_tag_is;
+ _poem.tags.epub_segment_anchor_tag_is = the_document_body_section[_first].tags.epub_segment_anchor_tag_is;
+ the_document_body_section
+ = the_document_body_section[0 .. _s]
+ ~ _poem
+ ~ the_document_body_section[_s .. _p];
+ previous_length = the_document_body_section.length.to!int;
+ }
+ _poem_open_idx = -1;
+ }
} else {
// line.empty, post contents, empty variables:
assert(
@@ -1031,12 +1074,13 @@ template docAbstraction() {
= obj.tags.html_segment_anchor_tag_is;
}
/+ ↓ An object that is not written into any segment still carries an
- identifier, and can share it: a poem block and its verses have one
- ocn between them, the verses are written and the block itself is not.
+ identifier, and could share it: a poem block carried the ocn of its last
+ verse until 2.1, and the verses are written where the block is not.
The block comes second, so an unguarded assignment replaced a good
segment name with an empty one, and the link came out as
".xhtml#297". seg_lv4 above is guarded already, which is why this
- showed in the epub and not in the html.
+ showed in the epub and not in the html. Since 2.1 the poem has no
+ identifier; the guard stays, for any object that is not in a segment.
+/
if (!(obj.tags.epub_segment_anchor_tag_is.empty)) {
tag_assoc[(obj.metainfo.identifier)]["seg_lv1to4"]