ebook

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2023 License: MIT Imports: 24 Imported by: 0

Documentation

Overview

Copyright 2022 Hal Canary Use of this program is governed by the file LICENSE.

Index

Constants

This section is empty.

Variables

View Source
var UnsupportedUrlError = errors.New("unsupported url")

Returned by a EbookGeneratorFunction when the URL can not be handled.

Functions

func ConvertToEbook

func ConvertToEbook(src, dst string, arguments ...string) error

func PopulateInfo added in v0.1.1

func PopulateInfo(info *EbookInfo, doc *dom.Node)

func RegisterEbookGenerator added in v1.0.0

func RegisterEbookGenerator(downloadFunction EbookGeneratorFunction)

Register the given function.

Types

type Chapter

type Chapter struct {
	Title    string
	Url      string
	Content  *Node
	Modified time.Time
}

type EbookGeneratorFunction added in v1.0.0

type EbookGeneratorFunction func(url string, doPopulate bool) (EbookInfo, error)

type EbookInfo

type EbookInfo struct {
	Authors  string
	Comments string
	Title    string
	Source   string
	Language string
	Chapters []Chapter
	Modified time.Time
	Cover    []byte
}

Ebook content and metadata.

func DownloadEbook added in v1.0.0

func DownloadEbook(url string, doPopulate bool) (EbookInfo, error)

Return the result of the first registered download function that does not return UnsupportedUrlError. @param url - the URL of the title page of the book. @param doPopulate - if true, download and populate the entire EbookInfo data structure, not just its metadata.

func (EbookInfo) CalculateLastModified

func (info EbookInfo) CalculateLastModified() time.Time

Return the time of most recently modified chapter.

func (EbookInfo) Print added in v0.1.2

func (info EbookInfo) Print(dst io.Writer)

func (EbookInfo) Write

func (info EbookInfo) Write(dst io.Writer) error

Write the ebook as an Epub.

func (EbookInfo) WriteHtml

func (info EbookInfo) WriteHtml(dst io.Writer) error

type Node

type Node = dom.Node

func Cleanup

func Cleanup(node *Node) *Node

Clean up a HTML fragment.

func ResolveLinks(node *Node, ref *url.URL) *Node

Jump to

Keyboard shortcuts

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