Expose EPUB ISBNs via metadata.isbns - #2
Closed
raphi011 wants to merge 2 commits into
Closed
Conversation
The package unique-identifier is usually a UUID, so ISBNs — when present — are secondary dc:identifier elements. EPUBMetadataParser now scans every dc:identifier, recognizing an ISBN via opf:scheme="ISBN" (EPUB 2), an identifier-type ONIX codelist 5 value (EPUB 3: 15/02), a urn:isbn: URN, or Calibre's bare isbn: value prefix. Values are returned as declared — only the scheme prefix and separators are stripped, with no normalization (an ISBN-10 stays an ISBN-10), so the toolkit never synthesizes a value the publisher didn't write. A publication may carry several ISBNs (e.g. its ISBN-10 and ISBN-13, or distinct ISBNs per format), so they are exposed as Metadata.isbns: [String], in document order with duplicates removed. Follows the mediaOverlay extension pattern (stashed in otherMetadata; no change to the public Metadata type). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
raphi011
force-pushed
the
feat/epub-isbn-metadata
branch
from
June 28, 2026 08:34
487fadc to
edcebe1
Compare
Owner
Author
|
Superseded by the upstream PR readium#837. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The EPUB parser now exposes the publication's ISBNs through a new
metadata.isbnsproperty. A package's primaryidentifieris usually a UUID, so an ISBN — when present — lives in a secondarydc:identifier.EPUBMetadataParserscans everydc:identifierand collects those recognizable as ISBNs.Detection
A
dc:identifieris treated as an ISBN when it carries any of:opf:scheme="ISBN"(EPUB 2)identifier-typeONIX Code List 5 refinement —15(ISBN-13) /02(ISBN-10) (EPUB 3)urn:isbn:URN valueisbn:value prefixValue handling
Values are returned as declared — only the scheme prefix (
urn:isbn:/isbn:) and separators (hyphens, whitespace) are stripped. There is no normalization: an ISBN-10 is returned as ISBN-10, not converted to ISBN-13, and no check-digit synthesis happens, so the toolkit never invents a value the publisher didn't write.A publication may declare more than one ISBN — the ISBN-10 and ISBN-13 of the same book, or distinct ISBNs per format — so
isbnsis a list, returned in document order with duplicates removed.API
Surfaced following the existing
mediaOverlayextension pattern: the values are stashed inotherMetadataand read back through a typed accessor, so there is no change to the publicMetadatatype — only an additive computed property on theSharedEPUB extension.Testing
EPUBMetadataParserTestscases + OPF fixtures covering: EPUB 2 (opf:scheme), EPUB 3 (identifier-typefor both ISBN-13 and ISBN-10),urn:isbn:, Calibre'sisbn:prefix, hyphen stripping, ISBN-10 returned verbatim (no conversion), multiple ISBNs in document order, duplicate-across-schemes dedup, and the no-ISBN (UUID-only) case.make formatreports no changes.Notes