diff --git a/README.md b/README.md index 393a662..592622c 100644 --- a/README.md +++ b/README.md @@ -95,7 +95,7 @@ Processors for each book format return an object that implements the following i - `.href`: a string representing the destination of the item. Does not have to be a valid URL. - `.subitems`: a array that contains TOC items - `.pageList`: same as the TOC, but for the [page list](https://www.w3.org/publishing/epub32/epub-packages.html#sec-nav-pagelist). -- `.metadata`: an object representing the metadata of the book. +- `.metadata`: an object representing the metadata of the book. Currently, it follows more or less the metadata schema of [Readium's webpub manifest](https://github.com/readium/webpub-manifest). - `.rendition`: an object that contains properties that correspond to the [rendition properties](https://www.w3.org/publishing/epub32/epub-packages.html#sec-package-metadata-rendering) in EPUB. If `.layout` is `"pre-paginated"`, the book is rendered with the fixed layout renderer. - `.resolveHref(href)`: given an href string, returns an object representing the destination referenced by the href, which has the following properties: - `.index`: the index of the referenced section in the `.section` array diff --git a/epub.js b/epub.js index 37133b6..6ae0aff 100644 --- a/epub.js +++ b/epub.js @@ -134,7 +134,13 @@ const METADATA = [ { name: 'rights', ...LANGS, props: [ALTS] }, { name: 'date' }, { name: 'dcterms:modified', type: 'meta' }, - { name: 'subject', many: true, ...LANGS, props: ['term', 'authority', ALTS] }, + { + name: 'subject', many: true, ...LANGS, props: ['term', 'authority', ALTS], + setLegacyAttrs: (obj, el) => { + obj.term ??= el.getAttributeNS(NS.OPF, 'term') + obj.authority ??= el.getAttributeNS(NS.OPF, 'authority') + }, + }, { name: 'source', many: true }, { name: 'belongs-to-collection', type: 'meta', many: true, ...LANGS, @@ -888,8 +894,9 @@ ${doc.querySelector('parsererror').innerText}`) published: metadata?.date, modified: metadata?.dctermsModified, subject: metadata?.subject - ?.filter(({ value, code }) => value || code) - ?.map(({ value, code, scheme }) => ({ name: value, code, scheme })), + ?.filter(({ value, term }) => value || term) + ?.map(({ value, term, authority }) => + ({ name: value, code: term, scheme: authority })), rights: metadata?.rights?.value, } const relators = {