Skip to content

A11y inferrence improvements - #141

Open
chocolatkey wants to merge 3 commits into
developfrom
feat/a11y-inferrence-improvements
Open

chocolatkey wants to merge 3 commits into
developfrom
feat/a11y-inferrence-improvements

Conversation

@chocolatkey

Copy link
Copy Markdown
Member

From the changelog:


Added

  • The manifest command now infers the languages of a publication's text when --inspect-html is combined with --infer-a11y=split. The publication's (X)HTML documents are scanned through their guided navigation representation, and the languages declared in them (lang or xml:lang) are listed under language in the inferred accessibility object, as BCP-47 tags ordered by the number of strings found in each language, most used first. Like metadata.language, a single language is written as a string instead of a one-item array
    • A string is a block of text, or a run of text in another language inside of one (e.g. <i lang="fr">). Text with no declared language is not counted, so nothing is inferred for publications that don't declare any
    • Tags are normalized (en_us becomes en-US) and keep their region and script, so en and en-US are listed separately. Tags that are not valid are ignored
    • This inference is never merged into the publication's own metadata: nothing is inferred with --infer-a11y=merged
  • The manifest command now infers the textual and visual access modes from the content of a publication's (X)HTML documents when --inspect-html is combined with --infer-a11y. textual is inferred when a document contains text, and visual when one contains an image, an inline SVG or a video which is neither decorative (role="presentation" or role="none") nor a cover
    • Only the documents of the reading order are read, without the navigation document. Image descriptions such as alt are not text, so a publication made of images is not textual. An image with an empty alt is not considered decorative
    • These access modes are inferred even when the publication declares its own accessMode: the missing ones are added to it with --infer-a11y=merged, or listed in the inferred accessibility object with --infer-a11y=split

Changed

  • The go-toolkit has been updated to v0.17.1. For the detailed list, refer to the go-toolkit's changelog; the highlights as they apply to the CLI:
    • Publications are handled more strictly as untrusted input. Crafted ZIP archives can no longer make the CLI allocate gigabytes of memory, and package documents (manifests, OPF, navigation documents, media overlays…) larger than 32 MiB are an error instead of being read whole
    • Exploded publications no longer serve files outside of their directory through symbolic links, nor named pipes or devices. S3 and GCS publications list every object of their prefix, rather than the first 1000
    • The access mode inference changes below
  • The visual access mode is no longer inferred from the images and videos which are only listed in a publication's resources, which made nearly every EPUB with a cover visual. Without --inspect-html, it is now only inferred when the reading order itself contains an image or a video. For most EPUBs, this means that --infer-a11y alone no longer infers visual: combine it with --inspect-html to infer it from the images the documents actually use
  • With --inspect-html, the references of an image now list the places where it's used as a decorative image ("role": ["presentation"]) or with an empty alt, which were left out before, as well as the SVGs embedding it with an <image> element
  • With --inspect-html, each (X)HTML document is now converted to its guided navigation representation only once, instead of once for every inspection that reads it

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The change introduces an extraneous .go.old file containing a standalone program under cmd/injector that won’t be built and is likely accidental, creating repository noise that should be removed or properly relocated/documented before approval.

1 open issue
What changed in this PR

Improves manifest accessibility inference when --inspect-html is enabled by adding document-driven access mode detection and updating supporting tests, documentation, and dependencies.

Changes:

  • Infer textual/visual access modes by scanning guided navigation output of reading-order (X)HTML documents.
  • Wire the new inspector into manifest flows and expand tests around access-mode inference and ranged serving.
  • Update documentation/changelog and bump module dependencies (including github.com/readium/go-toolkit v0.17.1).
File Description
pkg/​serve/​api_test.go Tightens ranged-request test assertions by computing ZIP entry offsets and validating the expected origin byte ranges.
pkg/​inspector/​access_modes_inspector.go Adds an inspector that infers textual and visual access modes from guided navigation content with cover/decorative handling.
pkg/​inspector/​access_modes_inspector_test.go Introduces unit tests covering access-mode inference rules and edge cases for merged/split behaviors.
internal/​cli/​manifest.go Integrates the access mode inspector into manifest with --inspect-html and adjusts guided navigation conversion behavior.
go.sum Updates dependency checksums to match the module version changes.
go.mod Bumps and refreshes Go module dependencies, including upgrading github.com/readium/go-toolkit to v0.17.1.
docs/​manifest.md Documents the updated accessibility inference behavior, including access-mode inference when --inspect-html is enabled.
cmd/​injector/​main.go.old Adds a standalone legacy .go.old program file under cmd/injector that is not part of the build.
CHANGELOG.MD Updates the changelog with entries describing the new/changed accessibility inference behavior and dependency upgrade.

Review effort: Balanced
Copilot was unable to complete this review at the selected tier due to model policy or plan restrictions.

Comment thread cmd/injector/main.go.old Resolved

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

An unresolved moderate issue remains where cover resource HREFs are stored without fragment normalization while image comparisons remove fragments, which can cause cover links containing fragments to be missed and misclassified as visual.

No open issues 🎉

1 previously missed issue

In code that hasn't changed since last review

Medium severity Normalize fragment-stripped cover HREFs before classifying visuals

pkg/​inspector/​access_modes_inspector.go:104

Cover resources are recorded using link.Href.String() as-is, but image objects are compared after stripping fragments (obj.ImgRef.RemoveFragment()). If a manifest’s cover link itself contains a fragment, the cover won’t be recognized and may be incorrectly inferred as visual. Consider normalizing cover HREFs the same way when populating scan.covers.

1 resolved since last review

Review effort: Balanced

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants