htmlentity

package
v1.3.5 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2026 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package htmlentity is the HTML vocabulary an xmlro.Reader needs to tokenize HTML-flavoured XML: the named character references of HTML 4 and the elements that end with their start tag. It is a separate package so that a reader of Office parts, which needs neither, links neither table.

r := xmlro.NewReader(src, xmlro.Options{
	Entities:  htmlentity.Lookup,
	AutoClose: htmlentity.AutoClose,
	Lenient:   true,
})

is the reader encoding/xml builds from Strict false, Entity = xml.HTMLEntity and AutoClose = xml.HTMLAutoClose, and a document reads the same through both.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AutoClose

func AutoClose(name []byte) bool

AutoClose reports whether name is an HTML element that ends with its start tag: br, img, hr and the rest of encoding/xml.HTMLAutoClose. The comparison ignores ASCII case and a namespace prefix, as encoding/xml's does, so xhtml:br inside an SVG foreignObject is one too. A colon that is the first or the last byte is part of the name, not a prefix, as encoding/xml also has it. It is an xmlro.Options.AutoClose.

func Lookup

func Lookup(name []byte) (string, bool)

Lookup resolves one of the 252 named character references of HTML 4, the set encoding/xml.HTMLEntity holds, by the name between & and ;. It is an xmlro.Options.Entities, allocates nothing, and does not know the five references XML predefines, which the reader resolves before asking.

Types

This section is empty.

Jump to

Keyboard shortcuts

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