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 ¶
- Variables
- type Document
- func (d *Document) Close() error
- func (d *Document) Describe(ctx context.Context) (info ivy.Info, err error)
- func (d *Document) Page(ctx context.Context, n int) (ivy.Page, error)
- func (d *Document) PageCount(ctx context.Context) (int, error)
- func (d *Document) Previews(ctx context.Context) iter.Seq2[ivy.Preview, error]
- type Option
Constants ¶
This section is empty.
Variables ¶
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 ¶
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) Describe ¶
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 ¶
Page satisfies the ivy.Pager interface. It lays out the document only as far as page n.
func (*Document) PageCount ¶
PageCount satisfies the ivy.Pager interface. It lays out the whole document on its first call.
type Option ¶
type Option func(*options)
Option is an option of Open.
func WithConfig ¶
WithConfig sets the configuration that every format shares.
func WithDir ¶
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).