Options
All
  • Public
  • Public/Protected
  • All
Menu

Class PackageWrapper

Wrapper around the internal representation of a EPUB3 Package document, as defined in the EPUB 3.3 Specification

The module relies on the xmlbuilder2 package, which generates an XML file out of a set of JS objects. See the documentation of that library for the details; the short overview is:

  • JSON names starting with "@"" represent an attribute.
  • JSON name "#"" represent textual content of the element.
  • Otherwise a JSON name refers to an embedded dictionary representing a subelement in XML.

The type hierarchy to represent an OPF file through such objects is defined through Package. Those types and default values do not reflect all possibilities of Package documents, only those that are relevant for W3C Technical reports.

Hierarchy

  • PackageWrapper

Index

Constructors

constructor

  • new PackageWrapper(identifier: string, title: string): PackageWrapper
  • Parameters

    • identifier: string

      Canonical identifier of the publication, used in the dc:identifier metadata entry

    • title: string

      Title of the publication

    Returns PackageWrapper

Methods

add_a11y_feature

  • add_a11y_feature(features: string[]): void
  • Add accessibility feature strings to the metadata

    Parameters

    • features: string[]

      list of feature strings

    Returns void

add_collection

  • add_collection(new_collection: Collection): void
  • Add a new OPF collection. This is used when the final EPUB is itself a collection of parts; each collection in the OPF sense collects the constituents of a specific part.

    Parameters

    • new_collection: Collection

      a new collection to be added to the package document.

    Returns void

add_creators

  • add_creators(creators: string[]): void
  • Add a list of creators (authors) to the publication.

    Parameters

    • creators: string[]

      list of creators of the publications

    Returns void

add_dates

  • add_dates(date: string): void
  • Set the date and the modification date of the publication.

    Parameters

    • date: string

      modification date and proper date (there is no difference for W3C Documents)

    Returns void

add_manifest_item

  • add_manifest_item(item: ManifestItem, add_spine_item?: boolean): void
  • Add a manifest item, i.e., the reference to a resource that is part of the publication.

    add_spine_item
    • whether the item must be added to the spine, too (with a linear=no attribute value)

    Parameters

    Returns void

add_spine_item

  • add_spine_item(idref: string, add_linear?: boolean): void
  • Add a spine item, i.e., the reference to the resource in the manifest that is a constituent of the spite (i.e., reading order) of the book

    Parameters

    • idref: string

      the reference that must be added to the spine item

    • Default value add_linear: boolean = false

    Returns void

add_wcag_link

  • add_wcag_link(): void
  • Add an A11y link to WCAG A, to specify that the document conforms to this level

    Returns void

serialize

  • serialize(): string
  • Serialize the Package document into (pretty printed) XML.

    Returns string

    • Pretty printed XML