Documentation
¶
Overview ¶
Package epubdoc provides EPUB document parsing.
Index ¶
- Variables
- type Chapter
- type ExtractOptions
- type ManifestItem
- type Metadata
- type Package
- type Reader
- func (r *Reader) ChapterCount() int
- func (r *Reader) Chapters() []*Chapter
- func (r *Reader) Close() error
- func (r *Reader) Document() (*model.Document, error)
- func (r *Reader) Markdown() (string, error)
- func (r *Reader) MarkdownWithOptions(opts ExtractOptions) (string, error)
- func (r *Reader) Metadata() Metadata
- func (r *Reader) TableOfContents() *TableOfContents
- func (r *Reader) Text() (string, error)
- func (r *Reader) TextWithOptions(opts ExtractOptions) (string, error)
- type SpineItem
- type TOCEntry
- type TableOfContents
Constants ¶
This section is empty.
Variables ¶
var ( ErrNoContainer = errors.New("epub: missing META-INF/container.xml") ErrInvalidContainer = errors.New("epub: invalid container.xml") ErrNoRootfile = errors.New("epub: no rootfile found in container.xml") )
Container-related errors.
var ( ErrNoOPF = errors.New("epub: missing package document (OPF)") ErrInvalidOPF = errors.New("epub: invalid package document") ErrEmptySpine = errors.New("epub: no content in spine") )
OPF-related errors.
var ( ErrInvalidArchive = errors.New("epub: invalid or corrupted archive") ErrInvalidMimetype = errors.New("epub: invalid mimetype (not an EPUB)") ErrMissingContent = errors.New("epub: referenced content file not found") )
Reader-related errors.
var (
ErrDRMProtected = errors.New("epub: DRM-protected content cannot be processed")
)
DRM-related errors.
Functions ¶
This section is empty.
Types ¶
type Chapter ¶
type Chapter struct {
ID string
Title string
Index int
Href string
Content []byte // Raw XHTML content
}
Chapter represents extracted content from one spine item.
type ExtractOptions ¶
type ExtractOptions struct {
// Uses htmldoc.NavigationExclusionMode values.
NavigationExclusion int
}
ExtractOptions configures content extraction.
type ManifestItem ¶
type ManifestItem struct {
ID string
Href string
MediaType string
Properties []string // "nav", "cover-image", etc.
}
ManifestItem represents a file in the EPUB.
type Metadata ¶
type Metadata struct {
Title string
Creator []string // Multiple authors possible
Language string
Identifier string // ISBN, UUID, etc.
Publisher string
Date string
Description string
Subjects []string
Rights string
Modified time.Time
}
Metadata contains EPUB metadata (Dublin Core).
type Package ¶
type Package struct {
Metadata Metadata
Manifest map[string]ManifestItem // keyed by ID
Spine []SpineItem
Version string // "2.0" or "3.0"
}
Package represents the parsed OPF document.
type Reader ¶
type Reader struct {
// contains filtered or unexported fields
}
Reader provides access to EPUB content.
func OpenReader ¶
OpenReader opens an EPUB from an io.ReaderAt.
func (*Reader) ChapterCount ¶
ChapterCount returns the number of chapters.
func (*Reader) MarkdownWithOptions ¶
func (r *Reader) MarkdownWithOptions(opts ExtractOptions) (string, error)
MarkdownWithOptions extracts content as markdown with the given options.
func (*Reader) TableOfContents ¶
func (r *Reader) TableOfContents() *TableOfContents
TableOfContents returns the parsed table of contents.
func (*Reader) TextWithOptions ¶
func (r *Reader) TextWithOptions(opts ExtractOptions) (string, error)
TextWithOptions extracts plain text with the given options.
type TableOfContents ¶
TableOfContents represents the navigation structure.