From 3fe2bc302d97132350ff2592aa86ac964ce9b553 Mon Sep 17 00:00:00 2001 From: Philip Sampaio Date: Mon, 18 Dec 2023 12:47:33 -0300 Subject: [PATCH] Improve example of `Floki.attribute/3` Closes https://github.com/philss/floki/issues/501 --- lib/floki.ex | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/lib/floki.ex b/lib/floki.ex index 883c9c80..bf76dc8d 100644 --- a/lib/floki.ex +++ b/lib/floki.ex @@ -631,11 +631,19 @@ defmodule Floki do iex> Floki.attribute([{"a", [{"href", "https://google.com"}], ["Google"]}], "a", "href") ["https://google.com"] - iex> Floki.attribute([{"a", [{"class", "foo"}, {"href", "https://google.com"}], ["Google"]}], "a", "class") + iex> Floki.attribute( + iex> [{"a", [{"class", "foo"}, {"href", "https://google.com"}], ["Google"]}], + iex> "a", + iex> "class" + iex> ) ["foo"] - iex> Floki.attribute([{"a", [{"href", "https://google.com"}, {"data-name", "google"}], ["Google"]}], "a[data-name]", "data-name") - ["google"] + iex> Floki.attribute( + iex> [{"a", [{"href", "https://e.corp.com"}, {"data-name", "e.corp"}], ["E.Corp"]}], + iex> "a[data-name]", + iex> "data-name" + iex> ) + ["e.corp"] """ @spec attribute(binary | html_tree | html_node, binary, binary) :: list