0.1.6 • Published 2 years ago
epubjs-cli v0.1.6
EpubJS-CLI
A CLI for creating ePubs from W3C Publication Manifests.
Installation
npm install -g epubjs-cliCreating an ePub
epubs-cli create ./path/to/manifest.jsonld -o mybook.epubOptions
Usage: epubjs-cli [options] [command]
Create an Epub from a JSON Manifest
Options:
-V, --version output the version number
-h, --help display help for command
Commands:
create [options] <inputPath>
help [command] display help for commandUsing with Nodejs
Input must be a file url.
import { writeFileSync } from 'node:fs';
import { pathToFileURL } from 'node:url';
import { ManifestToEpub } from "epubjs-cli";
let filePath = "./manifest.jsonld";
let url = pathToFileURL(filePath).href;
let epub = await new ManifestToEpub(url);
let file = await epub.save();
if (file) {
writeFileSync("./mybook.epub", file);
}Publication Manifests
A publication manifest is a JSON-LD serialized document that allows for expressing information about a digital publication, and providing URLs to the resource that publication requires. It's defined by the W3C Publication Manifests standard. It mostly maps nicely to elements in the Epub OPF XML document.
Adding Metadata
The manifest can support any schema.org metadata but when converting to Epub there are a few important ones that will be included in the generated package.opf.
dateModified->dcterms:modifiedid->dc:identifierinLanguage->dc:languagedateModified->dcterms:modifiedrights->dc:rightscreators[]->dc:creatorcontributor[]->dc:contributortitle->dc:titlesource->dc:sourcesubject->dc:subjectdescription->dc:description
Epub specific information
- HTML items can include a
propertiesarray, which will be passed as spine item properties when converting to Epub. - HTML items in the resources object will be included in the Epub spine element as non-linear spine items.
rel="cover"-> identifies the cover spine itemrel="cover-image"-> identifies the Epub cover image urlrel="contents"-> identifies the Table of Contents / Nav for the Epub