BUPE.Item (BUPE v0.6.3)

View Source

The Item element definition.

Each Item element represents a Publication Resource.

NOTE: The key content in the following struct is not part of the EPUB spec, but, we use that key internally to hold the content of the file that's associated with the Item for parsing purposes.

Summary

Functions

Convert a given path into a BUPE.Item struct.

Normalize the given 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)

@spec from_string(binary()) :: t()

Convert a given path into a BUPE.Item struct.

Examples

iex> BUPE.Item.from_string("book/bacon.xhtml") |> Map.take(~w(description href media_type)a)
%{
  description: "bacon",
  href: "book/bacon.xhtml",
  media_type: "application/xhtml+xml"
}

normalize(item)

@spec normalize(t()) :: t()

Normalize the given BUPE.Item struct.

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
}