epub-accessibility-audit
Audit local EPUB 3 publications offline with EPUBCheck and bounded XML inspection across container/OPF manifest/spine, navigation fragment targets, a11y metadata, lang, and alt text.
Try your first task
A source-grounded starter task has not been verified for this skill yet.
SKILL.md
name: epub-accessibility-auditdescription: "Audit local EPUB 3 publications offline with EPUBCheck and bounded XML inspection across container/OPF manifest/spine, navigation fragment targets, a11y metadata, lang, and alt text."category: developmentrisk: safesource: selfsource_type: selfdate_added: "2026-12-01"author: Koushik-Katkamtags: [epub, epubcheck, accessibility, epub-a11y, validation, publishing]EPUB Accessibility Audit
Overview
Audit finished EPUB 3 .epub publications offline combining EPUBCheck (5.4.0) structural validation with bounded, XXE-safe XML/ZIP EPUB Accessibility 1.1 checks (lxml.etree + Python zipfile). Verifies META-INF/container.xml and package.opf references, manifest resource existence, spine reading order, navigation document (nav) links and #fragment targets, schema:accessMode / accessibilityFeature / accessibilityHazard / accessibilitySummary metadata, document xml:lang/lang, and <img> alt attributes. Clearly separates structural validity, automated accessibility checks, and human accessibility evaluation.
Distinction from existing accessibility skills:
accessibility-compliance-accessibility-audit,better-accessibility, andui-a11y: audit interactive web pages, DOM keyboard/focus flows, and StyleSeed UI components against WCAG rather than.epubOCF containers,package.opfmanifests/spines, EPUBCheck rules, orschema:accessibility*package metadata.
When to Use
- Validating compiled
.epubreleases before bookstore distribution or accessibility certification handoff. - Catching broken
nav.xhtml#fragmentlinks, missing manifest assets, absentschema:access*metadata, missingxml:lang, or<img>elements withoutalt. - Distinguishing structural EPUB validity (
EPUBCheckexit0) from accessibility failures inside structurally valid.epubarchives. - Do not use this skill to extract untrusted archives indiscriminately to disk, fetch external resources, or claim full human accessibility compliance.
Prerequisites
- Official
EPUBCheckJAR (epubcheck --version, tested on5.4.0) with Java (21.0.12) viaEPUBCHECK_JARenv var orepubcheckonPATH. - Python
3.10+withlxmlandpytest(tested with Python3.12.10,lxml==6.1.3,pytest==9.1.1). - No external network fetching or arbitrary ZIP extraction required.
How It Works
1. Enforce bounded archive safety before reading members
- Inspect ZIP central directory via
zipfile.ZipFilein memory without callingextractall(). - Reject path traversal (
.., leading/, backslashes, NUL bytes), symlinks (S_ISLNK), excessive member counts (> 2000), or oversized compressed/uncompressed entries (> 16 MiBmember /> 64 MiBtotal) asINVALID_INPUT/UNSAFE_ARCHIVE.
2. Run EPUBCheck and EPUB Accessibility 1.1 inspection separately
Run the local verification suite in EPUB accessibility audit harness:
- Structural & spec check (
EPUBCheck 5.4.0whenrun_epubcheck=True): Runjava -jar epubcheck.jar <file.epub> --json <report.json>(45stimeout), handling missing report files, corrupt JSON, or subprocess/JVM failures gracefully without uncaught exceptions, to validate OCFmimetype,container.xml,package.opfversion3.0, manifest file existence, spine reading order, and nav links. The default is bounded Python-only inspection for untrusted.epubarchives. Use it (run_epubcheck=False/inspect_epub_python_only) so the external Java JVM is never invoked; structural checks reportstructural_status="NOT_TESTED"(structural_valid=None,epubcheck_errors=None) distinctly from EPUBCheck pass/fail. - Accessibility metadata (
EPUB Accessibility 1.1§2.2 spec vs. recommended vs. project policy): Parsepackage.opfwith XXE-disabledlxml.etree.XMLParser(resolve_entities=False, no_network=True)while separating:- Specification-required metadata (
ERROR):dc:language,schema:accessMode,schema:accessibilityFeature,schema:accessibilityHazard. - Specification-recommended metadata (
WARN):schema:accessibilitySummary,schema:accessModeSufficient. - Optional strict project policy (
require_summary_policy=True->ERROR): When enabled, missingschema:accessibilitySummaryemits a distinctPROJECT_POLICY_MISSING_ACCESSIBILITY_SUMMARYfinding (category="PROJECT_POLICY") explicitly labeled as project policy rather than an EPUB Accessibility 1.1 specification failure. - Project/automated HTML checks (
ERROR):<html xml:lang>/lang,<img>alt, and nav target resolution.
- Specification-required metadata (
- Normalized navigation targets & fragment verification: Resolve
<nav epub:type="toc"> <a href="...">paths relative to the nav document directory (posixpath.normpath+ percent-decoding so../ch1.xhtmlfromEPUB/nav/toc.xhtmlresolves toEPUB/ch1.xhtml), reject archive escapes, require nav targets to exist in both the ZIP archive and<manifest>(UNMANIFESTED_NAV_TARGET), and confirm#fragmentIDs exist in target XHTML documents.
3. Preserve human-evaluation boundary
Always emit distinct sections in the audit output:
structural_status("PASS","FAIL", or"NOT_TESTED"whenrun_epubcheck=False) andstructural_valid(True,False, orNone)automated_a11y_validandfindings(separatingA11Y_AUTO,A11Y_RECOMMENDED,PROJECT_POLICY,STRUCTURAL, andSECURITY)human_eval_required(explicit note that automated checks and metadata presence never establish complete accessibility compliance — screen-reader reading order, meaningfulaltprose, heading semantics, and visual contrast still require human evaluation).
Examples
Run the self-contained verification suite in EPUB accessibility audit harness:
User request: "Audit release.epub for EPUB 3.3 structural errors, broken TOC #fragment links, and EPUB Accessibility 1.1 metadata."
Inputs: Synthetic or local finished .epub archive inspected via EPUBCheck 5.4.0 + bounded lxml XML checks.
Expected result: Valid accessible EPUB passes structural and automated a11y checks while flagging human review;
missing nav target or fragment fails structural + nav checks; structurally valid EPUB lacking schema:access* or img alt
passes EPUBCheck yet fails automated a11y audit.
Limitations
- Automated checks confirm presence of
schema:access*metadata,xml:lang/lang,altattributes, and#fragmentIDs; they cannot judge whetheralttext is accurate/descriptive, whether heading order is logical, or whether screen-reader UX passes WCAG 2.2 AA. - Encrypted/DRM-protected EPUBs and MathML/SMIL media-overlay timing synchronization are outside this offline audit scope.
Safety and Side Effects
- Strictly bounded in Python: caps the compressed input at 64 MiB before ZIP parsing, inspects the same bytes in memory without
extractall()and parses XML withresolve_entities=False, no_network=True. Useinspect_epub_python_only/audit_epub(..., run_epubcheck=False)on untrusted.epubarchives so the external JavaEPUBCheckJVM process is never silently launched. - Untrusted EPUBCheck boundary: Executing external Java
EPUBCheck(run_epubcheck=True) invokes a third-party JVM process over the input.epub; restrict execution to trusted/synthetic archives unless external JVM network and filesystem sandboxing are enforced. - Never modifies input
.epubarchives or writes outside temporary test directories.