/epub

Epub parser library for golang

Primary LanguageGoMIT LicenseMIT

epub

A pure go implementation of epub file format.

Codeship Status for n3integration/epub codecov Go Report Card Documentation

Usage

import (
  "bytes"
  "fmt"
  "io"

  "github.com/n3integration/epub"
)

func main() {
+ // 1. Open the epub by passing its file path
  f := "some.epub"
  book, err := epub.Open(f)
  defer book.Close()

+ // 2. Iterate over book sections
  book.Each(func(title string, xhtml io.ReadCloser) {
+   // 3. Read and process section contents
    buf := new(bytes.Buffer)
    buf.ReadFrom(xhtml)

    fmt.Println("==========================================================")
    fmt.Println(title)
    fmt.Println("==========================================================")
    fmt.Println(buf.String())
  })
}

Reference