epub

package
v0.0.0-...-1c2f23e Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PropertyCover = "cover-image"
	PropertyNav   = "nav"
	MetaNameCover = "cover"
	ContainerPath = "META-INF/container.xml"
)

Variables

View Source
var (
	ErrInvalid  = errors.New("epub: invalid file")
	ErrNotFound = errors.New("epub: file not found")
)

Functions

This section is empty.

Types

type Container

type Container struct {
	RootFile struct {
		FullPath string `xml:"full-path,attr"`
	} `xml:"rootfiles>rootfile"`
}

type Epub

type Epub struct {
	Container *Container
	Package   *Package
	// contains filtered or unexported fields
}

func New

func New(filePath string) (*Epub, error)

func (Epub) GetCoverFile

func (e Epub) GetCoverFile() fs.File

GetCoverFile returns the cover file from the EPUB. Returns nil if the cover file cannot be opened.

func (Epub) GetDir

func (e Epub) GetDir(idRef string) string

GetDir returns the directory path for a file identified by the given ID reference. Returns an empty string if the ID reference is not found.

func (Epub) GetFile

func (e Epub) GetFile(idRef string) fs.File

GetFile returns a file from the EPUB identified by the given ID reference. Returns nil if the ID reference is not found or the file cannot be opened.

func (Epub) GetFileFromPath

func (e Epub) GetFileFromPath(path string) fs.File

GetFileFromPath returns a file from the EPUB at the specified path. Returns nil if the file cannot be opened.

func (Epub) GetFilename

func (e Epub) GetFilename(idRef string) string

GetFilename returns the filename for a file identified by the given ID reference. Returns an empty string if the ID reference is not found.

func (Epub) GetSpineIDRefs

func (e Epub) GetSpineIDRefs() []string

GetSpineIDRefs returns a slice of all ID references in the EPUB's spine. The spine defines the reading order of the EPUB content.

type Manifest

type Manifest struct {
	Items []ManifestItem `xml:"item"`
	IDMap map[string]ManifestItem
}

type ManifestItem

type ManifestItem struct {
	ID         string `xml:"id,attr"`
	Href       string `xml:"href,attr"`
	MediaType  string `xml:"media-type,attr"`
	Properties string `xml:"properties,attr"`
}

type Metadata

type Metadata struct {
	Identifier  string `xml:"identifier"`
	Title       string `xml:"title"`
	Language    string `xml:"language"`
	Publisher   string `xml:"publisher"`
	Date        string `xml:"date"`
	Description string `xml:"description"`
	Creator     string `xml:"creator"`
	CoverPath   string
	NavPath     string

	Meta []struct {
		Name    string `xml:"name,attr"`
		Content string `xml:"content,attr"`
	} `xml:"meta"`
}

type Package

type Package struct {
	Metadata Metadata `xml:"metadata"`
	Manifest Manifest `xml:"manifest"`
	Spine    Spine    `xml:"spine"`
}

type Spine

type Spine struct {
	Items []SpintItem `xml:"itemref"`
}

type SpintItem

type SpintItem struct {
	IDref string `xml:"idref,attr"`
}

Jump to

Keyboard shortcuts

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