Kreuzberg.Uri (kreuzberg v4.9.5)

Copy Markdown View Source

Structure representing a URI extracted from a document.

Matches the Rust Uri struct.

Fields

  • :url - The URL string
  • :label - Optional display label for the URI
  • :page - Optional page number where the URI appears
  • :kind - The kind of URI (e.g., "hyperlink", "image", "anchor")

Summary

Functions

Creates a Uri struct from a map.

Converts a Uri struct to a map.

Types

t()

@type t() :: %Kreuzberg.Uri{
  kind: String.t(),
  label: String.t() | nil,
  page: integer() | nil,
  url: String.t()
}

Functions

from_map(data)

@spec from_map(map()) :: t()

Creates a Uri struct from a map.

Examples

iex> Kreuzberg.Uri.from_map(%{
...>   "url" => "https://example.com",
...>   "label" => "Example",
...>   "page" => 1,
...>   "kind" => "hyperlink"
...> })
%Kreuzberg.Uri{
  url: "https://example.com",
  label: "Example",
  page: 1,
  kind: "hyperlink"
}

to_map(uri)

@spec to_map(t()) :: map()

Converts a Uri struct to a map.

Examples

iex> uri = %Kreuzberg.Uri{url: "https://example.com", kind: "hyperlink"}
iex> Kreuzberg.Uri.to_map(uri)
%{
  "url" => "https://example.com",
  "label" => nil,
  "page" => nil,
  "kind" => "hyperlink"
}