converter

package
v0.15.1 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2026 License: BSD-3-Clause Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertElementToSSMLTag

func ConvertElementToSSMLTag(a atom.Atom) (string, []xml.Attr)

ConvertElementToSSMLTag maps an HTML element to the SSML tag its text should be wrapped in. https://www.w3.org/TR/speech-synthesis11/#S3.2.2

func ExtractNamespaces

func ExtractNamespaces(el *html.Node) (namespaces map[string]string)

Crawl up the tree and extract all namespaces. This is technically an incorrect implementation because it doesn't distinguish between XHTML and HTML. These namespaces are ignored in HTML documents, but we still support them.

func ExtractNodeAria

func ExtractNodeAria(el *html.Node) (*guidednavigation.GuidedNavigationText, bool)

https://www.w3.org/TR/accname/#terminology Returns the node's accessibility text if existent, and whether or not the node is visible in the first place.

func ExtractNodeRoles

func ExtractNodeRoles(el *html.Node) (roles []guidednavigation.GuidedNavigationRole)

ExtractNodeRoles determines the Guided Navigation roles of an element, combining the roles derived from the element type itself with the ones from its ARIA `role` and `epub:type` attributes, e.g. <section epub:type="chapter"> -> [section, chapter]. An ARIA role of "presentation"/"none" strips the element of its native semantics.

func ParseXHTML

func ParseXHTML(r io.Reader) (*html.Node, error)

ParseXHTML parses an XHTML document into the tree shape html.Parse produces, so consumers written against html.Parse output work unchanged. Unlike html.Parse, self-closing elements like <span epub:type="pagebreak"/> are handled per XML rules instead of being treated as unclosed tags that swallow the content following them.

Types

type HTMLConverter

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

func NewHTMLConverter

func NewHTMLConverter(baseLocator manifest.Locator) *HTMLConverter

func (*HTMLConverter) Convert

func (c *HTMLConverter) Convert(doc *html.Node)

func (*HTMLConverter) Result

Jump to

Keyboard shortcuts

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