htmlser

package
v2.3.1 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2026 License: MIT Imports: 2 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 htmlser holds the HTML rules of Serialization 3.1 that both serialisers apply: the full one in xslt and fn:serialize's in xpath. xslt imports xpath, so neither can hold them for the other.

Index

Constants

View Source
const NSXHTML = "http://www.w3.org/1999/xhtml"

NSXHTML is the XHTML namespace.

Variables

This section is empty.

Functions

func Inline

func Inline(n *xdm.Node, xhtml, html5 bool) bool

Inline reports whether n is an inline element in the sense of Serialization 3.1 §7.4.3 (html) and §6.1.4 (xhtml), next to which indentation "MUST NOT" add whitespace: an element the method treats as HTML whose name is in inlineNames. The html method treats an element in no namespace as HTML, and one in the XHTML namespace under HTML5, matching names without regard to case; the xhtml method one in the XHTML namespace, or in none under HTML5. ponytail: area, link and meta, phrasing only in some positions, are left out.

func Island added in v2.3.0

func Island(n *xdm.Node, html5 bool) bool

Island reports whether the html method writes element n with XML syntax rather than HTML's: n is in a namespace that is neither absent nor, under HTML5, XHTML's. Serialization 3.1 §7.1 has the html method write an element differently from the xml method only "if the element is to be serialized as an HTML element", so such an "XML island" self-closes when empty: Serialization-html-5 and -6 embed <magic xmlns="..."/> and ask for it back self-closed, and -3 (HTML 4) wants the XHTML-namespace elements -4 (HTML5) writes as HTML self-closed too, since HTML 4 did not know that namespace.

func MetaContent

func MetaContent(mediaType, encoding string) string

MetaContent is the content attribute of the meta element the html and xhtml methods add (§7.4.13, §6.1.14): the media-type parameter, text/html when absent, and the charset, UTF-8 when no encoding is given.

func MetaEnd added in v2.3.0

func MetaEnd(head *xdm.Node, xhtml, html5 bool) string

MetaEnd is what closes the content-type meta the html and xhtml methods add to head, after its content value. xhtml is XML, so the element is closed, with the space the compatibility guidelines ask for (§6.1.14). Under html a head in an XML island -- a namespace other than none, or XHTML's below HTML5 -- is written as XML too (§7.1: the html method writes an element differently from the xml method only "if the element is to be serialized as an HTML element"), so its meta takes an end tag; result-document-1402 asks for that spelling. Anywhere else it is a bare HTML start tag.

func ReplacedMeta

func ReplacedMeta(head, n *xdm.Node) bool

ReplacedMeta reports whether n is a meta element the html and xhtml methods discard from head, the <head> they have added their own content-type meta to. §7.4.13 and §6.1.14: "any existing meta element child of the head element having an http-equiv attribute with the value "Content-Type", making the comparison without regard to case after first stripping leading and trailing spaces ... MUST be discarded". A child only: a meta deeper in head is left alone. The HTML5 charset spelling of the same declaration is discarded too, as Saxon does, since it would contradict the added one.

func SkipIndentBefore

func SkipIndentBefore(n, c *xdm.Node, xhtml, html5 bool) bool

SkipIndentBefore reports whether no indent may go before c, a child of n (c == nil meaning before n's end tag): next to an inline child, or before the end tag of an inline element. The boundaries inside an element follow Saxon, which the spec permits: an indent may follow the start tag of an inline element, but none goes before its end tag.

func Void added in v2.3.0

func Void(local string, html5 bool) bool

Void reports whether an HTML element named local, matched without regard to case, takes no end tag: the names void in every HTML version, plus HTML5's own under html5 and HTML 4's otherwise. The version decides for seven names (Serialization-html-1 writes the HTML 4 list, -2 the HTML5 one), so a single merged list answers both versions wrongly.

func XHTML5Doctype added in v2.3.0

func XHTML5Doctype(n *xdm.Node) bool

XHTML5Doctype reports whether the xhtml method, under html-version 5 with no doctype-system, writes a bare "<!DOCTYPE " + local name + ">" ahead of document element n. Serialization 3.1 §6.1.7: the first element "is recognized as an HTML element, the local part of the QName of which is equal to the string HTML, without regard to case". Under HTML5 the xhtml method recognises the XHTML namespace and no namespace (§6), so a foreign namespace (output-0214) or another name (output-0213) gets none.

Types

This section is empty.

Jump to

Keyboard shortcuts

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