diff options
| author | Ralph Amissah <ralph.amissah@gmail.com> | 2026-09-13 20:53:26 -0400 |
|---|---|---|
| committer | Ralph Amissah <ralph.amissah@gmail.com> | 2026-09-14 12:18:51 -0400 |
| commit | 6835275408e1629f450d163e0cc5221c977e87d2 (patch) | |
| tree | ac35771a889a4766d8efc89af5f78e91fa99e3d3 /src/sisudoc/ocda | |
| parent | regex: confine url within an endnote (delimiter) (diff) | |
epub and html: no errors left over the sample set
epubcheck 5.3.0 over the 35 sample epubs went from 1302 remaining errors
to none. The six causes for those remaining errors fixed here.
most of the count was one of them:
- Tables (1123 errors, 86%) where the writer emitted obsolete
attributes, removed in 2014; table also now in div instead of a
paragraph. also fixed:
- Navigation (115). Every level 4 heading's nav entry ended "#0", the
ocn of an object that has no ocn and so no id.
- Duplicate ids (37). (from three unrelated sources).
- The publication identifier (27 warnings). dc:identifier was a
hardcoded hex string, not a UUID, and the same one in all 35 files,
so two documents in one library collided. It is now UUID v5 over the
document's own uid: a real RFC 4122 identifier, stable across builds
and distinct per document.
- Image manifest entries (15). media-type was "image/" plus the file
extension, giving "image/jpg", which is not a media type; epubcheck
reads it as a foreign resource and wants a fallback. There is now a
mapping, which also covers svg and webp. Item ids came from the file
basename, and "2bits_02_01-100.png" gave an id starting with a digit,
which is not an XML name; ids are now prefixed and sanitised.
- An ocn resolving to no segment (9). A poem block and its first verse
share one ocn; the verses are written into a segment and the block
itself is not.
Also dropped from the package document: an xmlns:xsi that nothing
used, and a prefix declaration for the rendition vocabulary, which is
a reserved prefix and needed no declaring. The package now carries
xml:lang.
test-epub-validity.sh now allows no fatal and no error. Two NAV-011
warnings remain and are described in it. Three reference .ssp files
change, all of them the anchor tag disambiguation above.
(assisted by Claude-Code)
Diffstat (limited to 'src/sisudoc/ocda')
| -rw-r--r-- | src/sisudoc/ocda/abstraction/doc_has.d | 14 | ||||
| -rw-r--r-- | src/sisudoc/ocda/meta/metadoc_from_src.d | 28 | ||||
| -rw-r--r-- | src/sisudoc/ocda/meta/metadoc_from_src_functions.d | 1 |
3 files changed, 39 insertions, 4 deletions
diff --git a/src/sisudoc/ocda/abstraction/doc_has.d b/src/sisudoc/ocda/abstraction/doc_has.d index ecdef25..4ecf018 100644 --- a/src/sisudoc/ocda/abstraction/doc_has.d +++ b/src/sisudoc/ocda/abstraction/doc_has.d @@ -264,8 +264,18 @@ template spineDocHasFromAbstraction() { _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.length > 0) { + _tag_assoc[obj.metainfo.identifier]["seg_lv1to4"] + = obj.tags.epub_segment_anchor_tag_is; + } } } _out.imagelist = _images.sort.uniq.array; 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 diff --git a/src/sisudoc/ocda/meta/metadoc_from_src_functions.d b/src/sisudoc/ocda/meta/metadoc_from_src_functions.d index 77770f4..08ee22c 100644 --- a/src/sisudoc/ocda/meta/metadoc_from_src_functions.d +++ b/src/sisudoc/ocda/meta/metadoc_from_src_functions.d @@ -66,6 +66,7 @@ template docAbstractionFunctions() { string anchor_tag; string anchor_tag_; string[string] tag_in_seg; + bool[string] _heading_anchor_tags_seen; string lev_anchor_tag; string[string][string] tag_assoc; string[] lv0to3_tags; |
