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
- type Option
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, opts ...Option) (*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, opts ...Option) *HTMLConverter
func (*HTMLConverter) Convert ¶
func (c *HTMLConverter) Convert(doc *html.Node)
func (*HTMLConverter) Result ¶
func (c *HTMLConverter) Result() []guidednavigation.GuidedNavigationObject
type Option ¶ added in v0.16.0
type Option func(*HTMLConverter)
An Option configures an HTMLConverter.
func WithTextRefLocators ¶ added in v0.16.0
func WithTextRefLocators() Option
WithTextRefLocators makes every emitted object whose element carries roles reference its location in the source document through textref: the element's fragment id when it has one (e.g. "chapter.xhtml#par1"), a css() fragment with a unique CSS selector otherwise (e.g. "chapter.xhtml#css(body%20%3E%20p:nth-child(3))"). The selectors are anchored to the closest ancestor with an id when there is one.