     |> Kernel.<>("\u2026")
   end
 
-  defp do_generate_preview(_html, _), do: ""
+  defp do_generate_preview(_html_tree, _), do: ""
 end

  def generate_preview(_html, {_, l}) when is_integer(l) and l <= 0, do: ""

  def generate_preview(html, l) when is_integer(l) do
    do_generate_preview(html, {:chars, l})
  end

  def generate_preview(html, {_, l} = lspec) when is_integer(l) do
    do_generate_preview(html, lspec)
  end

  def generate_preview(_html, _), do: ""

  @spec do_generate_preview(binary(), {term(), non_neg_integer()}) :: binary()
  defp do_generate_preview(html, lspec)

  defp do_generate_preview(html, {:chars, l}) do
    html
    |> Floki.text(sep: " ")
    |> String.trim()
    |> String.replace(~r/\s+/, " ")

    |> Kernel.<>("\u2026")
  end

  defp do_generate_preview(html_tree, {:words, l}) do
    html_tree
    |> Floki.text(sep: " ")
    |> String.split(~r/\s/, trim: true)
    |> Enum.take(l)
