LangelicEpub.Document (langelic_epub v0.2.3)

Copy Markdown View Source

An EPUB document — metadata, spine (reading order), assets, and TOC.

All chapters and assets are fully loaded into memory.

Page progression direction

page_progression_direction sets the OPF <spine page-progression-direction> attribute and, for "rtl", orients the generated nav document (its <html> root gets dir="rtl" plus the document language) so table-of-contents labels render in the correct direction. Allowed values:

  • "rtl" — right-to-left pagination (Arabic, Hebrew, …)
  • "ltr" — left-to-right pagination
  • nil — omit the attribute; readers fall back to their default (ltr)

Any other value makes LangelicEpub.build/1 return {:error, %LangelicEpub.Error{kind: :invalid_page_direction}}.

This field is set from the target language at build time. parse/1 always returns nil here — a source EPUB's direction is intentionally not round-tripped (a rtl Japanese source rebuilt into English must shed it).

Summary

Types

t()

@type t() :: %LangelicEpub.Document{
  assets: [LangelicEpub.Asset.t()],
  cover_asset_id: String.t() | nil,
  creators: [String.t()],
  date: String.t() | nil,
  description: String.t() | nil,
  identifier: String.t(),
  language: String.t() | nil,
  metadata: %{required(String.t()) => [String.t()]},
  page_progression_direction: String.t() | nil,
  publisher: String.t() | nil,
  rights: String.t() | nil,
  spine: [LangelicEpub.Chapter.t()],
  title: String.t(),
  toc: [LangelicEpub.NavItem.t()],
  version: String.t()
}