The top level entry in the package: convert a single Respec file, or a collection thereof, into an EPUB document.
the URL of either the HTML content (if the target is a single document) or a JSON content (if the target is a collection of HTML documents)
ReSpec options in case the source has to be preprocessed by ReSpec
whether tracing is set (for debugging)
whether the package stops at the creation of an EPUB content and displays the content of the OPF file itself (for debugging)
Externally accessible entries
r2epub can be used as a library module both to TypeScript and to Javascript. This module is the common entry point from both the cli or the serve functions for the command line interface and the server side, respectively. Furthermore, it provides an API that can be used directly; a simple example is as follows:
In Typescript (using
node.js
):import * as r2epub from 'r2epub'; import * as fs from 'fs'; // The creation itself is asynchronous (the content has to be fetched over the wire). // The result is the class instance encapsulating an OCF (zip) content const url :string = "http://www.example.org/doc.html", const args :r2epub.Options = { respec : false, config : {} }; const ocf :r2epub.OCF = await r2epub.convert(url, args); // The zip file is finalized asynchronously const content :Buffer = await ocf.get_content(); // Get the content out to the disk fs.writeFileSync(ocf.name, content);
The same in Javascript (using
node.js
):const r2epub = require('r2epub'); // The creation itself is asynchronous (the content has to be fetched over the wire). // The result is the class instance encapsulating an OCF (zip) content const url = "http://www.example.org/doc.html", const args = { respec : false, config : {} }; const ocf = await r2epub.convert(url, args); // The zip file is finalized asynchronously const content = await ocf.get_content(); // Get the content out to the disk fs.writeFileSync(ocf.name, content);
See the detailed specification of the API element below. The top level functional entry point to the package is convert.