Help us shape the future of Go! Take the 2026 Go Developer Survey

element

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2025 License: BSD-3-Clause Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ElementToMap

func ElementToMap(e Element) map[string]interface{}

Types

type Attribute

type Attribute[T any] struct {
	Key   AttributeKey
	Value T
}

An attribute is an arbitrary key-value metadata pair.

func NewAttribute

func NewAttribute(key AttributeKey, value any) Attribute[any]

type AttributeKey

type AttributeKey string
const AcessibilityLabelAttributeKey AttributeKey = "accessibilityLabel"
const LanguageAttributeKey AttributeKey = "language"

type AttributesHolder

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

An object associated with a list of attributes.

func NewAttributesHolder

func NewAttributesHolder(attributes []Attribute[any]) AttributesHolder

func (AttributesHolder) AccessibilityLabel

func (ah AttributesHolder) AccessibilityLabel() string

func (AttributesHolder) Attributes

func (ah AttributesHolder) Attributes() AttributesHolder

func (AttributesHolder) Get

Gets all the attributes with the given [key].

func (AttributesHolder) GetFirst

func (ah AttributesHolder) GetFirst(key AttributeKey) *Attribute[any]

Gets the first attribute with the given [key].

func (AttributesHolder) Language

func (ah AttributesHolder) Language() string

type AudioElement

type AudioElement struct {
	AttributesHolder
	// contains filtered or unexported fields
}

An audio clip.

func NewAudioElement

func NewAudioElement(locator manifest.Locator, embeddedLink manifest.Link, attributes []Attribute[any]) AudioElement
func (e AudioElement) EmbeddedLink() manifest.Link

Implements EmbeddedElement

func (AudioElement) Locator

func (e AudioElement) Locator() manifest.Locator

Implements Element

func (AudioElement) MarshalJSON

func (e AudioElement) MarshalJSON() ([]byte, error)

func (AudioElement) Text

func (e AudioElement) Text() string

Implements TextualElement

type Body

type Body struct{}

Normal body of content.

func (Body) Role

func (b Body) Role() string

type Element

type Element interface {
	// AttributesHolder
	Language() string
	AccessibilityLabel() string
	Attributes() AttributesHolder

	Locator() manifest.Locator // Locator targeting this element in the Publication.
}

Represents a single semantic content element part of a publication.

type EmbeddedElement

type EmbeddedElement interface {
	// AttributesHolder
	Language() string
	AccessibilityLabel() string
	Attributes() AttributesHolder

	// Element
	Locator() manifest.Locator // Locator targeting this element in the Publication.

	EmbeddedLink() manifest.Link // Referenced resource in the publication.
}

An element referencing an embedded external resource.

type Footnote

type Footnote struct{}

A footnote at the bottom of a document.

func (Footnote) Role

func (f Footnote) Role() string

type Heading

type Heading struct {
	Level int // Heading importance, 1 being the highest.
}

Title of a section.

func (Heading) Role

func (h Heading) Role() string

type ImageElement

type ImageElement struct {
	AttributesHolder
	// contains filtered or unexported fields
}

A bitmap image. The caption is a short piece of text associated with the image.

func NewImageElement

func NewImageElement(locator manifest.Locator, embeddedLink manifest.Link, caption string, attributes []Attribute[any]) ImageElement
func (e ImageElement) EmbeddedLink() manifest.Link

Implements EmbeddedElement

func (ImageElement) Locator

func (e ImageElement) Locator() manifest.Locator

Implements Element

func (ImageElement) MarshalJSON

func (e ImageElement) MarshalJSON() ([]byte, error)

func (ImageElement) Text

func (e ImageElement) Text() string

Implements TextualElement

type Quote

type Quote struct {
	ReferenceURL   *url.URL // URL to the source for this quote.
	ReferenceTitle string   // Name of the source for this quote.
}

func (Quote) Role

func (q Quote) Role() string

type TextElement

type TextElement struct {
	AttributesHolder
	// contains filtered or unexported fields
}

A text element.

func NewTextElement

func NewTextElement(locator manifest.Locator, role TextRole, segments []TextSegment, attributes []Attribute[any]) TextElement

func (TextElement) Locator

func (e TextElement) Locator() manifest.Locator

Implements Element

func (TextElement) MarshalJSON

func (e TextElement) MarshalJSON() ([]byte, error)

func (TextElement) Role

func (e TextElement) Role() TextRole

func (TextElement) Text

func (e TextElement) Text() string

Implements TextualElement

type TextRole

type TextRole interface {
	Role() string
}

Represents a purpose of an element in the broader context of the document.

type TextSegment

type TextSegment struct {
	AttributesHolder                  // Attributes associated with this segment, e.g. language.
	Locator          manifest.Locator // Locator to the segment of text.
	Text             string           // Text in the segment.
}

Ranged portion of text with associated attributes.

type TextualElement

type TextualElement interface {
	// AttributesHolder
	Language() string
	AccessibilityLabel() string
	Attributes() AttributesHolder

	// Element
	Locator() manifest.Locator // Locator targeting this element in the Publication.

	Text() string // Human-readable text representation for this element.
}

An element which can be represented as human-readable text.

type VideoElement

type VideoElement struct {
	AttributesHolder
	// contains filtered or unexported fields
}

A video clip.

func NewVideoElement

func NewVideoElement(locator manifest.Locator, embeddedLink manifest.Link, attributes []Attribute[any]) VideoElement
func (e VideoElement) EmbeddedLink() manifest.Link

Implements EmbeddedElement

func (VideoElement) Locator

func (e VideoElement) Locator() manifest.Locator

Implements Element

func (VideoElement) MarshalJSON

func (e VideoElement) MarshalJSON() ([]byte, error)

func (VideoElement) Text

func (e VideoElement) Text() string

Implements TextualElement

Jump to

Keyboard shortcuts

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