Vibe.Plugins.WebSearch.HTML (vibe v0.2.3)

Copy Markdown View Source

HTML parsing and extraction helpers for Vibe.Plugins.WebSearch.

This module intentionally delegates HTML parsing to Floki. It does not parse HTML with regular expressions.

Summary

Functions

Parses HTML from a fetch result or binary string with Floki.

Parses HTML with Floki and raises when parsing fails.

Returns raw HTML for nodes matching a CSS selector.

Converts HTML to Markdown using a small Floki-tree renderer.

Converts HTML to plain text using Floki.

Types

html_tree()

@type html_tree() :: Floki.html_tree()

Functions

parse(html)

@spec parse(Vibe.Plugins.WebSearch.FetchResult.t() | String.t()) ::
  {:ok, html_tree()} | {:error, term()}

Parses HTML from a fetch result or binary string with Floki.

parse!(value)

Parses HTML with Floki and raises when parsing fails.

select_html(value, selector)

@spec select_html(
  Vibe.Plugins.WebSearch.FetchResult.t() | String.t() | html_tree(),
  String.t()
) ::
  {:ok, String.t()} | {:error, term()}

Returns raw HTML for nodes matching a CSS selector.

to_markdown(value)

@spec to_markdown(Vibe.Plugins.WebSearch.FetchResult.t() | String.t() | html_tree()) ::
  {:ok, String.t()} | {:error, term()}

Converts HTML to Markdown using a small Floki-tree renderer.

to_text(value)

@spec to_text(Vibe.Plugins.WebSearch.FetchResult.t() | String.t() | html_tree()) ::
  {:ok, String.t()} | {:error, term()}

Converts HTML to plain text using Floki.