Main entry points
This module contains the main external entry points for the EPUB conversion. These are:
- Main processing steps for the creation of EPUB files: the [[RespecToEPUB]] class;
- A representation of the EPUB OCF instances (i.e., of the ZIP file for the final content): the [[OCF]] class;
- A representation of the EPUB “package”, i.e., the XML file providing the main manifest of the EPUB file: the [[PackageWrapper]] class.
Main Processing class
-
create_epub(): Promise<ocf.OCF>url: string,options: Options
Create an EPUB 3, ie, an OCF file from the original content
-
create_epub_from_dom(): Promise<ocf.OCF>url: string,dom: jsdom.JSDOM
Create an OCF instance from DOM representing the original content.
-
generate_epub(): Promise<ocf.OCF>
Create the final epub file (ie, an OCF instance): download all resources, if applicable, add them all, as well as the generated content (package file, nav file, the original content file, etc.) to an OCF instance.
-
get_extra_resources(): Promise<ResourceRef[]>
Collect the references to the extra resources, to be added to the EPUB file as well as the package opf file. It relies on searching through the HTML source file, based on the query patterns given in [[resource_references]].
- global: Global
- global_url: string
-
resource_references: LocalLinks[]
Arrays of query/attribute pairs that may refer to a resource to be collected:
Interface of the "Global" data, to be used by various utilities
-
config: any
The initial config object, originally filled by the user (respec puts a copy of this object, as JSON, into the header of the generated content).
-
document_url: string
The URL of the document to be processed
-
dom: jsdom.JSDOM
The DOM element, as returned from parsing
-
html_element: Element
The DOM HTML element of the main document
-
opf_content: opf.PackageWrapper
The class used for the generation of the EPUB opf file
-
package: boolean
[Debug] Whether the opf instance should be should be printed to the console instead of generating an EPUB file
-
process_version: number
Process version used to generate this file. The possible values are 2016 and 2021
-
resources: ResourceRef[]
List of extra resources, to be added to the opf file and into the final EPUB file. The main role of the [[create_epub_from_dom]] function is to collect all relevant resources; once done, this array is used to generate the final
package.opffile as well as to collect the resources themselves and add them to the final epub file. -
trace: boolean
[Debug] Whether trace information should be printed to the console
Interface for the resources that, eventually, should be added to the EPUB file
-
absolute_url: string
URL of the resource in case it must be fetched
-
add_to_spine: boolean
Flag whether the resource reference should also be added to the spine with a 'linear=no' attribute
-
id: string
The item must have a fixed id, rather than a generated one
-
media_type: string
Media type of the resource; this must be added to the package manifest entry
-
properties: string
Extra properties, defined by the package specification, to be added to the entry
-
relative_url: string
The URL to be used within the EPUB; relative to the top of the file
-
text_content: string
Content of the resource in case it is generated by this program
Usage
import * as mod from "lib/convert.ts";