diff options
| author | Ralph Amissah <ralph.amissah@gmail.com> | 2026-09-30 16:18:59 -0400 |
|---|---|---|
| committer | Ralph Amissah <ralph.amissah@gmail.com> | 2026-09-30 23:14:23 -0400 |
| commit | 993a3f655359f98dc26d3d3222e07792e2ccddf7 (patch) | |
| tree | 1633a8183b2affec4a2951c8357ab89e9073bd25 /org/ocda.org | |
| parent | search database: show all included notes (diff) | |
abstraction 2.1: a poem states its object range
- A poem is a container of verse, and stores its range of verse ocn,
- its verse are the citable units with ocn.
- A note in the last verse of a poem previously was not gathered into
the endnotes section, this now is fixed
Format 2.0 -> 2.1: the property is an addition, the poem is not a
citable object (but contans a range of objects), its verse are
(individual citable objects), and every reader checks the major version.
A 2.0 database reads as having no ranges.
(assisted by Claude-Code)
Diffstat (limited to 'org/ocda.org')
| -rw-r--r-- | org/ocda.org | 59 |
1 files changed, 52 insertions, 7 deletions
diff --git a/org/ocda.org b/org/ocda.org index b84b3ef..a164226 100644 --- a/org/ocda.org +++ b/org/ocda.org @@ -238,6 +238,8 @@ string[string] object_number_poem = [ "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,]; @@ -530,6 +532,7 @@ _loopMarkupSrcByLineStruct loopMarkupSrcByLine( 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); @@ -706,6 +709,46 @@ _loopMarkupSrcByLineStruct loopMarkupSrcByLine( 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( @@ -1142,12 +1185,13 @@ if (the_document_body_section.length > 1) { // writeln("body"); = 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"] @@ -1892,10 +1936,11 @@ template spineOcnAlign() { foreach (obj; doc.abstraction[section]) { int _ocn = obj.metainfo.ocn.to!int; if (_ocn <= 0) { continue; } - /+ ↓ first in document order wins. An ocn is not unique: a poem and - its first verse share one, by design, so the same number names - two objects and the first of them is the one both languages - will have reached first. + /+ ↓ first in document order wins. Until format spec:2.1 a (verse) ocn + was not unique: a poem carried the ocn of its last verse, so the + same number named two objects. A poem now carries 0 and is passed + over above; the rule stays, and costs nothing, for an artefact + written before spec:2.1. +/ if (_ocn !in _p.kinds) { _p.kinds[_ocn] = _kindOf(obj); } _p.ocn_count += 1; |
