epub

package
v0.0.13 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Parse

func Parse(path string) (*mediafile.ParsedMetadata, error)

Types

type NCX

type NCX struct {
	XMLName xml.Name `xml:"ncx"`
	NavMap  struct {
		NavPoints []NCXNavPoint `xml:"navPoint"`
	} `xml:"navMap"`
}

NCX represents the EPUB 2 NCX structure.

type NCXNavPoint

type NCXNavPoint struct {
	ID       string `xml:"id,attr"`
	NavLabel struct {
		Text string `xml:"text"`
	} `xml:"navLabel"`
	Content struct {
		Src string `xml:"src,attr"`
	} `xml:"content"`
	Children []NCXNavPoint `xml:"navPoint"`
}

NCXNavPoint represents a navigation point in NCX.

type NavElement struct {
	Type string `xml:"type,attr"`
	OL   *NavOL `xml:"ol"`
}

NavElement represents a nav element in the navigation document.

type NavHTML struct {
	XMLName xml.Name `xml:"html"`
	Body    struct {
		Nav []NavElement `xml:"nav"`
	} `xml:"body"`
}

NavHTML represents the EPUB 3 navigation document structure.

type NavLI struct {
	A        *NavLink `xml:"a"`
	Span     *NavSpan `xml:"span"`
	Children *NavOL   `xml:"ol"`
}

NavLI represents a list item in the navigation.

type NavLink struct {
	Href string `xml:"href,attr"`
	Text string `xml:",chardata"`
}

NavLink represents an anchor element.

type NavOL struct {
	Items []NavLI `xml:"li"`
}

NavOL represents an ordered list in the navigation.

type NavSpan struct {
	Text string `xml:",chardata"`
}

NavSpan represents a span element (heading without link).

type OPF

type OPF struct {
	Title         string
	Subtitle      string
	Authors       []mediafile.ParsedAuthor
	Series        string
	SeriesNumber  *float64
	Genres        []string
	Tags          []string
	Description   string
	Publisher     string
	Imprint       string
	URL           string
	ReleaseDate   *time.Time
	CoverFilepath string
	CoverMimeType string
	CoverData     []byte
	Identifiers   []mediafile.ParsedIdentifier
	Chapters      []mediafile.ParsedChapter
}

type Package

type Package struct {
	XMLName          xml.Name `xml:"package"`
	Text             string   `xml:",chardata"`
	Xmlns            string   `xml:"xmlns,attr"`
	Version          string   `xml:"version,attr"`
	UniqueIdentifier string   `xml:"unique-identifier,attr"`
	Metadata         struct {
		Text    string `xml:",chardata"`
		Opf     string `xml:"opf,attr"`
		Dc      string `xml:"dc,attr"`
		Dcterms string `xml:"dcterms,attr"`
		Xsi     string `xml:"xsi,attr"`
		Calibre string `xml:"calibre,attr"`
		Title   []struct {
			Text string `xml:",chardata"`
			ID   string `xml:"id,attr"`
		} `xml:"title"`
		Creator []struct {
			Text   string `xml:",chardata"`
			ID     string `xml:"id,attr"`
			Role   string `xml:"role,attr"`
			FileAs string `xml:"file-as,attr"`
		} `xml:"creator"`
		Contributor struct {
			Text string `xml:",chardata"`
			Role string `xml:"role,attr"`
		} `xml:"contributor"`
		Description string   `xml:"description"`
		Subject     []string `xml:"subject"`
		Publisher   string   `xml:"publisher"`
		Identifier  []struct {
			Text   string `xml:",chardata"`
			ID     string `xml:"id,attr"`
			Scheme string `xml:"scheme,attr"`
		} `xml:"identifier"`
		Date     string   `xml:"date"`
		Relation []string `xml:"relation"`
		Source   []string `xml:"source"`
		Rights   string   `xml:"rights"`
		Language string   `xml:"language"`
		Meta     []struct {
			Text     string `xml:",chardata"`
			Name     string `xml:"name,attr"`
			Content  string `xml:"content,attr"`
			Refines  string `xml:"refines,attr"`
			Property string `xml:"property,attr"`
		} `xml:"meta"`
	} `xml:"metadata"`
	Manifest struct {
		Text string `xml:",chardata"`
		Item []struct {
			Text       string `xml:",chardata"`
			ID         string `xml:"id,attr"`
			Href       string `xml:"href,attr"`
			MediaType  string `xml:"media-type,attr"`
			Properties string `xml:"properties,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"`
			Type  string `xml:"type,attr"`
			Href  string `xml:"href,attr"`
			Title string `xml:"title,attr"`
		} `xml:"reference"`
	} `xml:"guide"`
}

type ParseOPFResult

type ParseOPFResult struct {
	OPF      *OPF
	Package  *Package
	BasePath string
}

ParseOPFResult contains the parsed OPF data along with the raw package and base path needed for resolving relative paths to other files in the EPUB.

func ParseOPF

func ParseOPF(filename string, r io.ReadCloser) (*ParseOPFResult, error)

Jump to

Keyboard shortcuts

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