Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DCCreator ¶
type DCCreator struct {
ID string // id attribute (used as refines target in EPUB 3)
Value string
Role string // opf:role attribute (EPUB 2)
}
DCCreator represents a dc:creator element with optional opf:role.
type DCIdentifier ¶
DCIdentifier is a dc:identifier element with optional id attribute.
type EPUB ¶
type EPUB struct {
Path string
ZipFile *zip.ReadCloser
Files map[string]*zip.File // path -> zip.File
// Parsed from container.xml
RootfilePath string
AllRootfiles []Rootfile // all rootfile elements from container.xml
ContainerLinks []string // hrefs from <links> in container.xml
ContainerData []byte // raw container.xml bytes
// Parsed from OPF
Package *Package
// Raw OPF parse info (set during ParseOPF)
OPFParseError error
HasMetadata bool
HasManifest bool
HasSpine bool
}
EPUB represents a parsed EPUB file.
func Open ¶
Open opens an EPUB file and parses its structure. The caller must call Close() when done.
func (*EPUB) ParseContainer ¶
ParseContainer parses META-INF/container.xml and sets RootfilePath.
func (*EPUB) ParseOPF ¶
ParseOPF parses the OPF package document and populates ep.Package. It uses raw XML scanning to detect structural issues like missing elements.
func (*EPUB) ResolveHref ¶
ResolveHref resolves a relative href from the OPF file to a full path within the EPUB. Manifest hrefs are IRI-encoded (e.g. spaces as %20), but ZIP entry names use decoded forms, so we percent-decode before joining.
type GuideReference ¶
GuideReference represents a guide reference element in EPUB 2.
type ManifestItem ¶
type ManifestItem struct {
ID string
Href string
MediaType string
Properties string
Fallback string
HasID bool // false when id attribute is missing
MediaOverlay string // media-overlay attribute
}
ManifestItem represents a single item in the OPF manifest.
type MetaRefines ¶
type MetaRefines struct {
ID string // id attribute on the meta element itself
Refines string // the refines attribute value (e.g., "#id")
Property string
Value string
}
MetaRefines represents a meta element with a refines attribute.
type Metadata ¶
type Metadata struct {
Titles []DCTitle
Identifiers []DCIdentifier
Languages []string
Modified string // dcterms:modified value
Dates []string
Sources []string
Creators []DCCreator
Contributors []DCCreator // dc:contributor elements (same structure as dc:creator)
DCElementIDs []string // id attributes from all dc:* elements (publisher, subject, description, etc.)
}
Metadata holds the OPF metadata section.
type Package ¶
type Package struct {
UniqueIdentifier string
Version string
Dir string // dir attribute on package element
Prefix string // prefix attribute on package element
Metadata Metadata
Manifest []ManifestItem
Spine []SpineItemref
SpineToc string // EPUB 2 spine toc attribute
RenditionLayout string // "pre-paginated" or "reflowable"
RenditionFlow string // rendition:flow property
Guide []GuideReference
HasGuide bool // whether a <guide> element was present
ModifiedCount int // number of dcterms:modified meta elements
RenditionOrientation string
RenditionSpread string
PageProgressionDirection string // spine page-progression-direction attribute
MetaRefines []MetaRefines // meta elements with refines attribute
MetaIDs []string // id attributes from all meta elements in metadata
ElementOrder []string // order of top-level OPF elements (metadata, manifest, spine, guide)
}
Package represents the OPF package document.
type SpineItemref ¶
type SpineItemref struct {
IDRef string
Properties string
Linear string // linear attribute value ("yes", "no", or empty)
}
SpineItemref represents a single itemref in the OPF spine.