 
   defp set_header_ids(tree, state), do: {tree, state}
 
-  @spec generate_id(Html.tree()) :: binary()
+  @spec generate_id(Floki.html_tag()) :: binary()
   defp generate_id(tree) do
-    tree
+    [tree]
     |> Floki.text()
     |> String.downcase()
     |> String.replace(~r/\s/, "-")

  @doc "Creates a new `Fragment` struct."
  @spec new(binary() | nil, binary(), map(), binary()) :: Result.t(t())
  def new(file, output, metadata, data) do
    data
    |> Floki.parse()
    |> Html.traverse(%{}, &set_header_ids/2)
    |> elem(0)
    |> Plugin.rendering_fragment(metadata)
    |> case do
      {:ok, html_tree} ->
        fragment = %__MODULE__{
          file: file,
          output: output,
          metadata: Map.put(metadata, :images, extract_images(html_tree)),
          data: Floki.raw_html(html_tree)
        }

        {:ok, fragment}

      {:error, _} = error ->
        error
    end
  end

  @spec set_header_ids(Html.tree(), map()) :: {Html.tree(), map()}
  defp set_header_ids(tree, state)

  defp set_header_ids({<<?h, ch::8>>, _, _} = tree, state) when ch in ?1..?6 do

  @spec increase_count(map(), binary()) :: map()
  defp increase_count(map, id), do: Map.update(map, id, 1, &(&1 + 1))

  @spec extract_images(Floki.html_tree()) :: [binary()]
  defp extract_images(tree) do
    tree
    |> Floki.find("img")
