html

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2026 License: MIT Imports: 14 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package html opens HTML files and HTMLZ files.

An HTMLZ file is a zip archive that calibre writes: index.html, with its images and style sheets, metadata.opf and a cover image. The cover image is the preview, and metadata.opf gives the metadata. An HTML file has no preview, and its head gives the metadata. An HTMLZ file whose entries ZipCrypto or the AES of WinZip encrypts opens with the password of ivy.Config, or with its function PasswordFunc (D12).

The layout of phase 4 puts the document on pages (D10, D15): a page of US Letter for an HTML file, and the page of an ebook, 6 by 9 inches, for an HTMLZ file. Page lays out the document only as far as the page that a program asks for. An HTML file reads the files that it links to from the folder of WithDir (D22).

The package html of ivy has the same name as the package html of okage and of the standard library. A program that imports two of them renames one.

Index

Constants

This section is empty.

Variables

View Source
var Format = ivy.Format{
	Name:  "html",
	Mimes: []string{"text/html", "application/xhtml+xml", "application/htmlz+zip"},
	Exts:  []string{"html", "htm", "xhtml", "xht", "htmlz"},
	Open: func(ctx context.Context, src ivy.Source, cfg ivy.Config) (ivy.Document, error) {
		return Open(ctx, src, WithConfig(cfg))
	},
}

Format describes the package for the registry of a program.

Functions

This section is empty.

Types

type Document

type Document struct {
	// contains filtered or unexported fields
}

Document is an open HTML or HTMLZ file.

func Open

func Open(ctx context.Context, src ivy.Source, opts ...Option) (d *Document, err error)

Open opens an HTML file or an HTMLZ file. A source that starts as a zip archive is an HTMLZ file, and any other source is an HTML file. It returns an error that wraps ivy.ErrFormat if an HTMLZ file holds no HTML document, one that wraps ivy.ErrPassword if no password opens an encrypted HTMLZ file, and one that wraps ivy.ErrLimit if an HTML file is larger than Limits.MaxMemory.

func (*Document) Close

func (d *Document) Close() error

Close satisfies the ivy.Document interface.

func (*Document) Describe

func (d *Document) Describe(ctx context.Context) (info ivy.Info, err error)

Describe satisfies the ivy.Describer interface. For an HTMLZ file, it reads metadata.opf. If that gives no title, or for an HTML file, it reads the head of the document: its title, its language, and the meta elements of the author, the subject and the program that made it.

func (*Document) Page

func (d *Document) Page(ctx context.Context, n int) (ivy.Page, error)

Page satisfies the ivy.Pager interface. It lays out the document only as far as page n.

func (*Document) PageCount

func (d *Document) PageCount(ctx context.Context) (int, error)

PageCount satisfies the ivy.Pager interface. It lays out the whole document on its first call.

func (*Document) Previews

func (d *Document) Previews(ctx context.Context) iter.Seq2[ivy.Preview, error]

Previews satisfies the ivy.Previewer interface. It lists the cover image of an HTMLZ file: the cover that metadata.opf names, or a file named cover.jpg or cover.png in the root. An HTML file has no preview.

type Option

type Option func(*options)

Option is an option of Open.

func WithConfig

func WithConfig(cfg ivy.Config) Option

WithConfig sets the configuration that every format shares.

func WithDir

func WithDir(dir fs.FS) Option

WithDir gives the folder of an HTML file. The layout reads the style sheets, the images and the fonts that the file links to from it. The file is at the root of the folder, so a link out of the folder is not read, and a file of the folder with the name index.html or index.xhtml is hidden. An HTMLZ file holds its own files, and it ignores the folder. Without a folder, the layout reads no file that an HTML file links to (D22).

Jump to

Keyboard shortcuts

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