BUPE.Item (BUPE v0.6.5)

View Source

The item element definition from the EPUB manifest.

Each Item represents a publication resource bundled in an EPUB (for example, XHTML content documents, images, or stylesheets).

The content field in the struct is not part of the EPUB spec; BUPE uses it internally to hold the resource contents when parsing.

Summary

Functions

from_string(path) deprecated

Normalizes a binary path or BUPE.Item struct.

Types

t()

@type t() :: %BUPE.Item{
  content: nil | String.t(),
  description: nil | String.t(),
  duration: nil | String.t(),
  fallback: nil | String.t(),
  href: String.t(),
  id: nil | String.t(),
  media_overlay: nil | String.t(),
  media_type: nil | String.t(),
  properties: nil | String.t()
}

Functions

from_string(path)

This function is deprecated. Use normalize/1 instead.

normalize(path)

@spec normalize(t() | binary()) :: t()

Normalizes a binary path or BUPE.Item struct.

When fields are missing, this function fills in defaults:

  • id becomes a generated UUID-based identifier.
  • description defaults to the file name without extension.
  • media_type is inferred from the href path.

Examples

iex> BUPE.Item.normalize(%BUPE.Item{
...>   id: "ode-to-bacon",
...>   href: "book/bacon.xhtml",
...>   description: "Ode to Bacon"
...> })
%BUPE.Item{
  description: "Ode to Bacon",
  duration: nil,
  fallback: nil,
  href: "book/bacon.xhtml",
  id: "ode-to-bacon",
  media_overlay: nil,
  media_type: "application/xhtml+xml",
  properties: nil
}