EPUB: fix subjects

Also update README
This commit is contained in:
John Factotum
2023-10-24 17:25:46 +08:00
parent 7c3b7447f6
commit 0d09ca12a2
2 changed files with 11 additions and 4 deletions
+1 -1
View File
@@ -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
+10 -3
View File
@@ -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 = {