epub

package
v0.0.0-...-a3239b4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 26, 2020 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrFileNotFound = errors.New("epub: no '%s' found in file")
	ErrNoISBN       = errors.New("epub: no ISBN found in file")
	ErrNoMimetype   = errors.New("epub: no mimetype found in file")
	ErrNoContainer  = errors.New("epub: no no container.xml")
	ErrNoRootfile   = errors.New("epub: no rootfile found in container")

	// ErrBadRootfile occurs when container.xml references a rootfile that does
	// not exist in the zip.
	ErrBadRootfile = errors.New("epub: container references non-existent rootfile")

	// ErrNoItemref occurrs when a content.opf contains a spine without any
	// itemref entries.
	ErrNoItemref = errors.New("epub: no itemrefs found in spine")

	// ErrBadItemref occurs when an itemref entry in content.opf references an
	// item that does not exist in the manifest.
	ErrBadItemref = errors.New("epub: itemref references non-existent item")

	// ErrBadManifest occurs when a manifest in content.opf references an item
	// that does not exist in the zip.
	ErrBadManifest = errors.New("epub: manifest references non-existent item")
)

Functions

This section is empty.

Types

type Container

type Container struct {
	Rootfiles []*Rootfile `xml:"rootfiles>rootfile"`
}

Container serves as a directory of Rootfiles.

type EpubReader

type EpubReader struct {
	Name  string
	Files map[string]*zip.File
	Container
}

func (*EpubReader) GetCover

func (epubReader *EpubReader) GetCover() (string, error)

func (*EpubReader) GetISBN

func (epubReader *EpubReader) GetISBN() (string, error)

type EpubReaderCloser

type EpubReaderCloser struct {
	EpubReader
	// contains filtered or unexported fields
}

func OpenReader

func OpenReader(filename string) (*EpubReaderCloser, error)

func (*EpubReaderCloser) Close

func (epubReaderCloser *EpubReaderCloser) Close()

type Package

type Package struct {
	XMLName          xml.Name `xml:"package"`
	Text             string   `xml:",chardata"`
	Xmlns            string   `xml:"xmlns,attr"`
	UniqueIdentifier string   `xml:"unique-identifier,attr"`
	Version          string   `xml:"version,attr"`
	Metadata         struct {
		Text    string `xml:",chardata"`
		Dc      string `xml:"dc,attr"`
		Opf     string `xml:"opf,attr"`
		Title   string `xml:"title"`
		Creator struct {
			Text   string `xml:",chardata"`
			Role   string `xml:"role,attr"`
			FileAs string `xml:"file-as,attr"`
		} `xml:"creator"`
		Identifier []struct {
			Text   string `xml:",chardata"`
			ID     string `xml:"id,attr"`
			Scheme string `xml:"scheme,attr"`
		} `xml:"identifier"`
		Date        string `xml:"date"`
		Publisher   string `xml:"publisher"`
		Description string `xml:"description"`
		Contributor struct {
			Text string `xml:",chardata"`
			Role string `xml:"role,attr"`
		} `xml:"contributor"`
		Subject  string `xml:"subject"`
		Language string `xml:"language"`
		Meta     []struct {
			Text    string `xml:",chardata"`
			Name    string `xml:"name,attr"`
			Content string `xml:"content,attr"`
		} `xml:"meta"`
	} `xml:"metadata"`
	Manifest struct {
		Text string `xml:",chardata"`
		Item []struct {
			Text      string `xml:",chardata"`
			Href      string `xml:"href,attr"`
			ID        string `xml:"id,attr"`
			MediaType string `xml:"media-type,attr"`
		} `xml:"item"`
	} `xml:"manifest"`
	Spine struct {
		Text    string `xml:",chardata"`
		Toc     string `xml:"toc,attr"`
		Itemref []struct {
			Text  string `xml:",chardata"`
			Idref string `xml:"idref,attr"`
		} `xml:"itemref"`
	} `xml:"spine"`
	Guide struct {
		Text      string `xml:",chardata"`
		Reference []struct {
			Text  string `xml:",chardata"`
			Href  string `xml:"href,attr"`
			Title string `xml:"title,attr"`
			Type  string `xml:"type,attr"`
		} `xml:"reference"`
	} `xml:"guide"`
}

type Rootfile

type Rootfile struct {
	XMLName   xml.Name `xml:"rootfile"`
	FullPath  string   `xml:"full-path,attr"`
	MediaType string   `xml:"media-type,attr"`
	Package
}

Rootfile contains the location of a content.opf package file.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL