diff options
Diffstat (limited to 'src/sisudoc/ocda/meta/metadoc_from_src.d')
| -rw-r--r-- | src/sisudoc/ocda/meta/metadoc_from_src.d | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/src/sisudoc/ocda/meta/metadoc_from_src.d b/src/sisudoc/ocda/meta/metadoc_from_src.d index fb30a94..c856de3 100644 --- a/src/sisudoc/ocda/meta/metadoc_from_src.d +++ b/src/sisudoc/ocda/meta/metadoc_from_src.d @@ -95,6 +95,7 @@ template docAbstraction() { reset_note_numbers = true; lev_anchor_tag = ""; anchor_tag = ""; + _heading_anchor_tags_seen = _heading_anchor_tags_seen.init; } mixin spineNode; int[string] node_para_int_ = node_metadata_para_int; @@ -618,6 +619,18 @@ template docAbstraction() { = obj_im.obj_inline_markup_and_anchor_tags_and_misc(an_object, an_object_key, conf_make_meta, ((_new_doc) ? Yes._new_doc : No._new_doc)); an_object["substantive"] = substantive_object_and_anchor_tags_struct.obj_txt; anchor_tag = substantive_object_and_anchor_tags_struct.anchor_tag; + /+ ↓ an anchor tag names one heading. Markup can give the + same name to several ("2~x- 1.", "2~x- 2." ...), and + an id has to be unique within a document, so a repeat + takes the ocn as a suffix. The first keeps the name + the author wrote, so a link to it still arrives. + +/ + if (!(anchor_tag.empty)) { + if (anchor_tag in _heading_anchor_tags_seen) { + anchor_tag = anchor_tag ~ "-" ~ obj_cite_digits.object_number.to!string; + } + _heading_anchor_tags_seen[anchor_tag] = true; + } if (_new_doc) { cnt1 = 1; cnt2 = 1; @@ -1005,8 +1018,18 @@ template docAbstraction() { tag_assoc[(obj.metainfo.identifier)]["seg_lv4"] = obj.tags.html_segment_anchor_tag_is; } - tag_assoc[(obj.metainfo.identifier)]["seg_lv1to4"] - = obj.tags.epub_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. + 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. + +/ + if (!(obj.tags.epub_segment_anchor_tag_is.empty)) { + tag_assoc[(obj.metainfo.identifier)]["seg_lv1to4"] + = obj.tags.epub_segment_anchor_tag_is; + } } if (obj.metainfo.is_a == "heading") { debug(dom) { writeln(obj.text); } @@ -1582,6 +1605,7 @@ template docAbstraction() { content_non_header = "8"; lev_anchor_tag = ""; anchor_tag = ""; + _heading_anchor_tags_seen = _heading_anchor_tags_seen.init; // identify parts /+ ↓ what the document has, as plain data. ST_DocHas is in metadoc_object_setter so that it can also be built from a loaded |
