Options
All
  • Public
  • Public/Protected
  • All
Menu

Class RespecToEPUB

Convenience class, to export the internal RespecToEPUB class for the package as a whole. (This is only useful if, for some reasons, the conversion is done starting with a DOM tree, using create_epub_from_dom. In general, convert should be used).

This class is largely for internal use to the package, and the API user can mostly ignore its details.

Hierarchy

Index

Constructors

constructor

  • new RespecToEPUB(trace?: boolean, print_package?: boolean): RespecToEPUB

Methods

create_epub

  • create_epub(url: string, options: Options): Promise<OCF>
  • Create an EPUB 3.2, ie, an OCF file from the original content

    This function is a wrapper around create_epub_from_dom:

    1. Creates the DOM, which means, possibly, the original content is ran through the respec processor (if necessary).
    2. Calls create_epub_from_dom to generate the OCF content.
    3. "Finalizes" the OCF content, i.e., dump everything to a file.
    async

    Parameters

    • url: string
    • options: Options

      Reference to the original document; this may have to be transformed by respec on-the-fly.

    Returns Promise<OCF>

create_epub_from_dom

  • create_epub_from_dom(url: string, dom: JSDOM): Promise<OCF>
  • Create an OCF instance from DOM representing the original content.

    1. Gather all the global information (Global).
    2. Add the basic metadata (authors, dates) to the opf file.
    3. Collect all the resources (see resource_references); the relative urls and the media types are collected in a global structure, to be added to the EPUB file and the opf file later.
    4. Add the reference to a W3C logo.
    5. Add the reference to the generic fixup script.
    6. Add some of the global W3C CSS files, and auxiliary image files.
    7. Create a title page.
    8. Create a cover image.
    9. Create a nav file.
    10. Main resource (i.e., Overview.xhtml) entry, with relevant properties.
    11. Finalize the package file based on the collected resources in Global.resources.
    12. Download all resources into the EPUB file.

    All the resource entries are first collected in the in a Global.resources array, to be then added to the package.opf file as well as to download the resources into the final epub result (see the last two steps above).

    async

    Parameters

    • url: string

      The url of the document (serves also as a base for all the other resources)

    • dom: JSDOM

      The DOM of the final format of the document (i.e., the original document may have gone through a respec processing...)

    Returns Promise<OCF>

    • The zip archive with the epub content, i.e., an OCF instance