Yex.XmlText (y_ex v0.7.3)
View SourceA shared type that represents an XML text node. Extends Y.Text to provide functionality for manipulating text content within XML nodes, including text formatting and navigation.
Summary
Functions
Applies a delta of changes to the text content. Returns :ok on success, :error on failure.
Converts the XML text node to a preliminary representation. This is useful when you need to serialize or transfer the text node's content and formatting.
Deletes text content starting at the specified index. Supports negative indices for deletion from the end. Returns :ok on success, :error on failure.
Applies formatting attributes to a range of text. Returns :ok on success, :error on failure.
Inserts text content at the specified index. Returns :ok on success, :error on failure.
Inserts text content with attributes at the specified index. Returns :ok on success, :error on failure.
Returns the length of the text content.
Returns the next sibling node of this text node. Returns nil if this is the last child of its parent.
Returns the parent node of this text node. Returns nil if this is a top-level XML node.
Returns the previous sibling node of this text node. Returns nil if this is the first child of its parent.
Returns the text content as a delta format, including any formatting attributes.
Returns the text content as a string, including any formatting tags.
Types
@type delta() :: Yex.Text.delta()
Functions
Applies a delta of changes to the text content. Returns :ok on success, :error on failure.
@spec as_prelim(t()) :: Yex.XmlTextPrelim.t()
Converts the XML text node to a preliminary representation. This is useful when you need to serialize or transfer the text node's content and formatting.
Deletes text content starting at the specified index. Supports negative indices for deletion from the end. Returns :ok on success, :error on failure.
Applies formatting attributes to a range of text. Returns :ok on success, :error on failure.
@spec insert(t(), integer(), Yex.input_type()) :: :ok | :error
Inserts text content at the specified index. Returns :ok on success, :error on failure.
@spec insert(t(), integer(), Yex.input_type(), map()) :: :ok | :error
Inserts text content with attributes at the specified index. Returns :ok on success, :error on failure.
Returns the length of the text content.
@spec next_sibling(t()) :: Yex.XmlElement.t() | t() | nil
Returns the next sibling node of this text node. Returns nil if this is the last child of its parent.
@spec parent(t()) :: Yex.XmlElement.t() | Yex.XmlFragment.t() | nil
Returns the parent node of this text node. Returns nil if this is a top-level XML node.
@spec prev_sibling(t()) :: Yex.XmlElement.t() | t() | nil
Returns the previous sibling node of this text node. Returns nil if this is the first child of its parent.
Returns the text content as a delta format, including any formatting attributes.
Returns the text content as a string, including any formatting tags.