HtmlToMarkdown (html_to_markdown v2.22.5)

View Source

High-level Elixir interface for the Rust html-to-markdown engine.

Summary

Functions

Convert HTML to Markdown.

Convert HTML to Markdown and raise on failure.

Convert HTML and collect inline image assets.

Convert HTML to Markdown and extract metadata.

Convert HTML using a reusable options handle.

Variant of convert_with_options/2 that raises on failure.

Create a reusable options handle (opaque reference).

Start Rust-side profiling and write a flamegraph to the given output path.

Stop Rust-side profiling and flush the flamegraph.

Types

inline_config_input()

@type inline_config_input() ::
  HtmlToMarkdown.InlineImageConfig.t() | map() | keyword() | nil

metadata_config_input()

@type metadata_config_input() ::
  HtmlToMarkdown.MetadataConfig.t() | map() | keyword() | nil

options_input()

@type options_input() :: HtmlToMarkdown.Options.t() | map() | keyword() | nil

Functions

convert(html, options \\ nil)

@spec convert(String.t(), options_input()) :: {:ok, String.t()} | {:error, term()}

Convert HTML to Markdown.

The options argument accepts an %HtmlToMarkdown.Options{} struct, a map/keyword list with option keys, or nil (defaults).

convert!(html, options \\ nil)

@spec convert!(String.t(), options_input()) :: String.t()

Convert HTML to Markdown and raise on failure.

convert_with_inline_images(html, options \\ nil, inline_config \\ nil)

@spec convert_with_inline_images(String.t(), options_input(), inline_config_input()) ::
  {:ok, String.t(), [HtmlToMarkdown.InlineImage.t()],
   [HtmlToMarkdown.InlineImageWarning.t()]}
  | {:error, term()}

Convert HTML and collect inline image assets.

Returns {:ok, markdown, inline_images, warnings}.

convert_with_inline_images!(html, options \\ nil, inline_config \\ nil)

Bang variant of convert_with_inline_images/3.

convert_with_metadata(html, options \\ nil, metadata_config \\ nil)

@spec convert_with_metadata(String.t(), options_input(), metadata_config_input()) ::
  {:ok, String.t(), map()} | {:error, term()}

Convert HTML to Markdown and extract metadata.

Returns {:ok, markdown, metadata}.

convert_with_metadata!(html, options \\ nil, metadata_config \\ nil)

@spec convert_with_metadata!(String.t(), options_input(), metadata_config_input()) ::
  {String.t(), map()}

Bang variant of convert_with_metadata/3.

convert_with_options(html, handle)

@spec convert_with_options(String.t(), reference()) ::
  {:ok, String.t()} | {:error, term()}

Convert HTML using a reusable options handle.

convert_with_options!(html, handle)

@spec convert_with_options!(String.t(), reference()) :: String.t()

Variant of convert_with_options/2 that raises on failure.

options(opts \\ nil)

@spec options(options_input()) :: reference()

Create a reusable options handle (opaque reference).

The handle can be passed to convert_with_options/2.

start_profiling(output_path, frequency \\ 1000)

@spec start_profiling(String.t(), integer()) :: :ok | {:error, term()}

Start Rust-side profiling and write a flamegraph to the given output path.

stop_profiling()

@spec stop_profiling() :: :ok | {:error, term()}

Stop Rust-side profiling and flush the flamegraph.