Documentation
¶
Index ¶
- func ConvertEPUBRole(role string) guidednavigation.GuidedNavigationRole
- func ConvertElementToSSMLTag(a atom.Atom) (string, []xml.Attr)
- func Do(ctx context.Context, resource fetcher.Resource, locator manifest.Locator) (*guidednavigation.GuidedNavigationDocument, error)
- func ExtractNamespaces(el *html.Node) (namespaces map[string]string)
- func ExtractNodeAria(el *html.Node) (*guidednavigation.GuidedNavigationText, bool)
- func ExtractNodeRoles(el *html.Node) (roles []guidednavigation.GuidedNavigationRole)
- func ParseXHTML(r io.Reader) (*html.Node, error)
- type HTMLConverter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConvertEPUBRole ¶
func ConvertEPUBRole(role string) guidednavigation.GuidedNavigationRole
func ConvertElementToSSMLTag ¶
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 Do ¶
func Do(ctx context.Context, resource fetcher.Resource, locator manifest.Locator) (*guidednavigation.GuidedNavigationDocument, error)
func ExtractNamespaces ¶
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 ¶
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 ¶
func (c *HTMLConverter) Result() []guidednavigation.GuidedNavigationObject