Documentation
¶
Overview ¶
Package epub creates EPUB files.
Index ¶
- type Identifier
- type Manifest
- type ManifestItem
- type Metadata
- type Package
- type Spine
- type SpineItem
- type TOC
- type TOCMeta
- type TOCNav
- type TOCNavSrc
- type Writer
- func (c *Writer) AddChapter(id, title, name string, r io.Reader) error
- func (c *Writer) AddFile(id, name, mediaType string, r io.Reader) error
- func (c *Writer) AddImage(id, name string, r io.Reader) error
- func (c *Writer) Bootstrap() (err error)
- func (c *Writer) SetCreator(value string)
- func (c *Writer) SetID(value string)
- func (c *Writer) SetLanguage(value string)
- func (c *Writer) SetTitle(value string)
- func (c *Writer) WritePackage() error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Identifier ¶
type Identifier struct {
XMLName xml.Name `xml:"dc:identifier"`
Value string `xml:",chardata"`
ID string `xml:"id,attr"`
Scheme string `xml:"opf:scheme,attr"`
}
Identifier is the metadata>dc:identifier tag.
type Manifest ¶
type Manifest struct {
XMLName xml.Name `xml:"manifest"`
Items []ManifestItem
}
Manifest is the package>manifest tag.
type ManifestItem ¶
type ManifestItem struct {
XMLName xml.Name `xml:"item"`
ID string `xml:"id,attr"`
Href string `xml:"href,attr"`
MediaType string `xml:"media-type,attr"`
}
ManifestItem is a manifest>item tag.
type Metadata ¶
type Metadata struct {
XMLName xml.Name `xml:"metadata"`
XMLnsDC string `xml:"xmlns:dc,attr"`
XMLnsOPF string `xml:"xmlns:opf,attr"`
Identifier Identifier `xml:"dc:identifier"`
Language string `xml:"dc:language"`
Title string `xml:"dc:title"`
Creator string `xml:"dc:creator"`
}
Metadata is the package>metadata tag.
type Package ¶
type Package struct {
XMLName xml.Name `xml:"package"`
Version string `xml:"version,attr"`
XMLns string `xml:"xmlns,attr"`
UniqueID string `xml:"unique-identifier,attr"`
Metadata Metadata
Manifest Manifest
Spine Spine
}
Package is the root of content.opf.
func NewPackage ¶
func NewPackage() Package
NewPackage returns a new Package instance with default values.
type SpineItem ¶
type SpineItem struct {
XMLName xml.Name `xml:"itemref"`
IDRef string `xml:"idref,attr"`
Title string `xml:"-"`
Src string `xml:"-"`
}
SpineItem is a spine>itemref tag.
type TOC ¶
type TOC struct {
XMLName xml.Name `xml:"ncx"`
XMLns string `xml:"xmlns,attr"`
Version string `xml:"version,attr"`
Meta []TOCMeta `xml:"head>meta"`
Title string `xml:"docTitle>text"`
Author string `xml:"docAuthor>text"`
}
TOC is the root of the toc.ncx file.
type Writer ¶
Writer is an EPUB container. It's basically a wrapper around a zip.Writer with some additional methods to handle epub specificities.
func (*Writer) AddChapter ¶
AddChapter adds a new chapter to the book.
func (*Writer) SetCreator ¶
SetCreator sets the book's creator.
func (*Writer) SetLanguage ¶
SetLanguage sets the book's main language.
func (*Writer) WritePackage ¶
WritePackage finishes the book creation by adding a content.opf and a toc.ncx files based on all the files added earlier.