package oepub

  1. Overview
  2. Docs

Input signature of the functor Make. This module type drives how the content into the epub archive should be parsed to build a book. It also describes the type of content in each chapter.

Each function in ChapterContent are called at different stages of the parsing.

type t

the type representing the content of a chapter.

val empty : t

the empty value for a chapter.

val finalize : Stdlib.Buffer.t -> t -> t

finalize buffer content is called at the end of a parsed chapter.

val of_file : filename:string -> media_type:string -> title:string -> EpubArchive.t -> Opf.t -> Toc.t -> t Chapter.t list -> t -> Stdlib.Buffer.t -> string -> (string * t * Stdlib.Buffer.t * t Chapter.t list) option

of_file ~filename ~media_type epub opf toc chpaters content buffer file_bytes is called when a file is being read from the manifest link. If the function returns None, a default handler is called to handle a xml file.

filename refers to the exact name of filename in the epub archive.

val of_tag : tag:string -> title:string -> dirname:string -> (string * string) list -> EpubArchive.t -> Opf.t -> Toc.t -> t Chapter.t list -> t -> Stdlib.Buffer.t -> string * t * Stdlib.Buffer.t * t Chapter.t list

of_tag ~tag ~title ~dirname attributes epub opt toc chapters content buffer is called when an html tag is encontered.

  • tag is the name of the html tag being parsed.
  • title is the name of chapter being parsed.
  • dirname is the name of directory containing the file currently being parsed. dirname is useful if you need to deal with relative links (eg. src attribute the in tag img)

chapters should not be reversed in this function. Newly created chapter should be add a the head of the list.

OCaml

Innovation. Community. Security.