Utility helpers for extracting text and attributes from Floki-parsed HTML.
Summary
Functions
Returns the value of name attribute from a single Floki node.
Returns nil for nil or empty string; passes other values through unchanged.
Extracts and normalises the text content of a list of Floki nodes.
Types
@type text_opts() :: [{:sep, String.t()}]
Functions
@spec attr(Floki.html_node(), String.t()) :: String.t() | nil
Returns the value of name attribute from a single Floki node.
Returns nil when the attribute is absent or its value is blank.
Returns nil for nil or empty string; passes other values through unchanged.
@spec text(Floki.html_tree() | nil, text_opts()) :: String.t() | nil
Extracts and normalises the text content of a list of Floki nodes.
Collapses consecutive whitespace into a single space, trims leading/trailing
whitespace, and returns nil for empty or blank results.
Returns nil when nodes is nil.
Options:
:sep- the separator between text nodes. Defaults to a single space (" ").