epub

package
v0.0.0-...-876207e Latest Latest
Warning

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

Go to latest
Published: May 31, 2017 License: GPL-3.0 Imports: 16 Imported by: 2

Documentation

Overview

Package epub provides function to write EPUB and xhtml files.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrBookClosed        = errors.New("attempt to write in a closed book")
	ErrNoTitle           = errors.New("document title not set")
	ErrWrongSectionLevel = errors.New("wrong section level")
	ErrWrongFileType     = errors.New("wrong file type")
)

Functions

This section is empty.

Types

type Book

type Book struct {
	UUID         uuid.UUID
	LastModified string
	Language     string

	Title   string
	Authors []string

	Spine        []*File
	Files        map[string]*File
	Nav          []TOCEntry
	NavPath      string
	CSSPath      string
	CoverImageID string
	CoverID      string
	ContentName  string

	SectionNumber SecNo
	SectionLevel  int
	// contains filtered or unexported fields
}

func NewEpubWriter

func NewEpubWriter(out io.Writer, identifier string) (
	*Book, error)

func NewXhtmlWriter

func NewXhtmlWriter(baseDir string, identifier string) (
	*Book, error)

func (*Book) AddCoverImage

func (w *Book) AddCoverImage(r io.Reader) error

func (*Book) AddSection

func (w *Book) AddSection(level int, title string, secID string) error

func (*Book) AddTitle

func (w *Book) AddTitle(title string, authors []string) error

func (*Book) Close

func (w *Book) Close() error

func (*Book) CreateFile

func (w *Book) CreateFile(file *File) (io.WriteCloser, error)

func (*Book) RegisterFile

func (w *Book) RegisterFile(baseName, mimeType string, inSpine bool) *File

func (*Book) WriteString

func (w *Book) WriteString(s string) error

type File

type File struct {
	ID        string
	MediaType string
	Path      string
}

type SecNo

type SecNo []int

SecNo represents a section number in a document, e.g. `SecNo{1, 2}` represents section 1.2 and `SecNo{1}` represents chapter 1.

func (*SecNo) Inc

func (s *SecNo) Inc(level int)

Inc increases the section number at a given level by 1. Level should be 1 to increase the chapter number, 2 to increase the section number etc.

func (SecNo) String

func (s SecNo) String() string

String formats a section number as a string, in the form "1.2.3".

type TOCEntry

type TOCEntry struct {
	Level int
	Title string
	Path  string
	ID    string
	// contains filtered or unexported fields
}

func (*TOCEntry) Down

func (t *TOCEntry) Down() []struct{}

func (*TOCEntry) Up

func (t *TOCEntry) Up() []struct{}

Jump to

Keyboard shortcuts

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