Files
magnus919_agent-skills/epub/references/spec-and-validation.md
T
Magnus Hedemark 88e92f4472 feat: add epub skill v2 — 11 scripts, 9 references, 46 tests
Complete EPUB creation, editing, validation, and knowledge extraction
skill for the Agent Skills open format. Built from spec research, real
EPUB testing on 2.1MB commercial Apress title, and Apple Books
compatibility verification on macOS 26.

Scripts (11):
  epub-scaffold    — Create valid EPUB3 with cover XHTML, Apple Books CSS
  epub-edit        — Surgical editing (8 subcommands, epublib)
  epub-info        — Structure/metadata dump as JSON
  epub-text        — Clean text extraction, per-chapter or single-file
  epub-extract-knowledge — Heuristic + LLM extraction (env var auto-detect)
  epub-validate    — EPUBCheck or Python fallback validation
  epub-images      — List/extract all images with cover detection
  epub-batch       — Multi-file processing (extract-text, validate, metadata)
  epub-convert     — EPUB2→EPUB3 conversion with validation
  epub-repair      — Diagnose & auto-fix common structural issues
  epub-cover       — Add cover XHTML wrapper for Apple Books compatibility

References (9):
  epub-format-internals.md, python-libraries.md, spec-and-validation.md,
  tutorials-and-guides.md, agent-capability-discovery.md,
  fixed-layout-epub.md, accessibility.md, media-overlays.md,
  apple-books-compatibility.md (NEW — verified on macOS 26)

Test: 46/46 passing (test_epub_skill.sh)
2026-05-23 18:08:48 -04:00

4.8 KiB

Spec Reference & Validation Tools

W3C EPUB 3.3 Specifications

EPUB 3.3 is the current W3C Recommendation (May 2023). The spec is split into three documents:

Spec URL Purpose
EPUB 3.3 https://www.w3.org/TR/epub-33/ Authoring — how to create EPUBs
EPUB Reading Systems 3.3 https://www.w3.org/TR/epub-rs-33/ Rendering — how readers should behave
EPUB Accessibility 1.1 https://www.w3.org/TR/epub-a11y-11/ Accessibility requirements

Key Access Points in EPUB 3.3

EPUB 2.0.1 (Legacy)

For working with older EPUB2 files:

Validation Tools

EPUBCheck (Official)

The official W3C conformance validator. Written in Java, maintained by the DAISY Consortium.

# Download the latest release JAR
# Run against an EPUB
java -jar epubcheck.jar book.epub

# JSON output (for programmatic consumption)
java -jar epubcheck.jar --json book.epub

EPUBCheck validates:

  • OCF container structure (mimetype placement, container.xml)
  • OPF schema conformance
  • Manifest completeness (all files listed)
  • Spine references (all idrefs exist in manifest)
  • XHTML well-formedness
  • CSS validity
  • Navigation document structure
  • Metadata requirements
  • Accessibility metadata (partial)

Ace by DAISY (Accessibility)

Accessibility conformance evaluator for EPUB:

Pure-Python Validation

The epub-validate script in this skill provides a pure-Python validation fallback when Java/EPUBCheck is unavailable:

  • Structural checks (mimetype, container.xml, OPF parseability)
  • Manifest-vs-filesystem consistency
  • Spine-to-manifest reference checks
  • Basic metadata completeness

This is a lightweight alternative — EPUBCheck is the authoritative validator.

Authoring Guides

Official W3C Guides

Community Resources

Key Constraints Summary

When creating or editing EPUBs programmatically:

  1. mimetype first, uncompressed. The ZIP must have mimetype as entry #0 with STORE compression.
  2. Manifest is exhaustive. Every file used in rendering must be listed. No exceptions.
  3. Spine needs nav. The EPUB3 navigation document must be the first or near-first spine item.
  4. XHTML, not HTML. Content documents must be well-formed XML. Use proper namespaces. Self-closing tags required (<br/>, <img/>).
  5. Unique identifiers. Every manifest item needs a unique id. Every idref in the spine must match a manifest id.
  6. Language is required. Both <dc:language> in metadata and xml:lang/lang on content documents.
  7. Title is required. Every EPUB must have at least one <dc:title>.
  8. Identifier is required. Must be a unique identifier (URN, ISBN, or UUID recommended).
  9. Date modified. EPUB 3 requires <meta property="dcterms:modified"> with an ISO 8601 timestamp.
  10. Navigation required. EPUB3 requires a NAV document with properties="nav" in the manifest. NCX is optional but recommended for EPUB2 compatibility.