Reference

The rules

Fifteen checks across metadata, structure, navigation, and references. Each one describes a specific way an EPUB breaks for assistive technology, and carries the WCAG reference it answers to.

How a book is checked

The pipeline is local unzip, XML and HTML parsing, then a rewrite of the archive. There is no network step.

  1. Audit

    Unzip the EPUB and run fifteen rules against EPUB Accessibility 1.1 and WCAG 2.x. Output is human-readable, JSON, or SARIF.

  2. Fix

    Repair metadata, language, alt placeholders, and navigation. Apply every fix, or pass --only for a subset.

  3. Verify

    Re-audit the repaired archive and return what remains, so a pipeline can fail when a human still needs to make a judgement.

What fix changes

fix writes a repaired EPUB (default <input>.fixed.epub) and logs every change it makes. It applies the fixes below.

Metadata
Adds dc:language, dc:title, and the five schema:* accessibility metas when they are missing.
Language
Sets lang and xml:lang on every spine document so assistive technology reads the correct language.
Alt placeholders
Writes alt="TODO: describe image" on images with no alt attribute and logs every changed image, so a human can replace the placeholder.
Navigation
Adds a landmarks nav, builds a page-list when the book has pagebreaks, and generates a whole navigation document, updating the manifest, when the book has none.

The fifteen rules

Every rule booklens checks against EPUB Accessibility 1.1 and WCAG 2.x. The Fixable column matches the library.
Code Severity WCAG Check Fixable
E001error3.1.1Missing dc:languageauto
E002error2.4.2Missing dc:titleauto
E003error1.3.1Missing schema:accessModeauto
E004error1.3.1Missing schema:accessModeSufficientauto
E005error1.3.1Missing schema:accessibilityFeatureauto
E006error1.3.1Missing schema:accessibilityHazardauto
W007warning1.3.1Missing schema:accessibilitySummaryauto
E008error1.1.1Image with no alt attributeTODO placeholder
E009error3.1.1<html> without lang / xml:langauto
W010warning1.3.1Navigation missing a landmarks navXHTML nav only
W011info / warning1.3.1Navigation missing a page-list when the book has pagebreakswhen pagebreaks exist
W012warning1.3.1Headings skip a level or do not begin with an h1reported
W013warning1.3.1Table has no header cellsreported
W014warning2.4.4Link text is a raw URLreported
E015error2.4.1Publication has no navigation documentwrites nav + manifest

The rules reported but not auto-fixed are the ones where a repair would require judgement. Guessing a heading level or a link label silently corrupts the book; booklens leaves those to a human and says so. W010 and W011 can only be written into an XHTML navigation document; for an EPUB 2 / NCX-only book fix skips them with a changelog line instead of corrupting the NCX. W011 is a warning when the book contains pagebreaks and an info note when it does not.

Example run

An audit of a deliberately inaccessible book, as the CLI prints it:

booklens audit fixtures/inaccessible.epub
$ booklens audit fixtures/inaccessible.epuberror E008 OEBPS/chapter1.xhtml 1 image(s) missing an alt attribute.error E009 OEBPS/chapter1.xhtml html element is missing both lang and xml:lang attributes.warning W012 OEBPS/chapter1.xhtml Headings skip a level or do not begin with an h1.warning W013 OEBPS/chapter1.xhtml Table has no header cells (no <th> or role="columnheader").warning W014 OEBPS/chapter1.xhtml Link text is a raw URL: https://example.comerror E001 OEBPS/content.opf Publication is missing a dc:language declaration.error E003 OEBPS/content.opf Publication is missing schema:accessMode metadata.warning W010 OEBPS/nav.xhtml Navigation document is missing a landmarks nav element.info W011 OEBPS/nav.xhtml Navigation document has no page-list; the publication contains no pagebreaks.inaccessible.epub: 10 error(s), 8 warning(s), 1 info