diff --git a/lib/floki/raw_html.ex b/lib/floki/raw_html.ex index 67993013..f57f453d 100644 --- a/lib/floki/raw_html.ex +++ b/lib/floki/raw_html.ex @@ -219,10 +219,13 @@ defmodule Floki.RawHTML do defp leftpad(:noop), do: "" defp leftpad(%{pad: pad}), do: pad - defp leftpad_content(:noop, string), do: string + defp leftpad_content(:noop, content), do: content - defp leftpad_content(padding, string) do - trimmed = String.trim(string) + defp leftpad_content(padding, content) do + trimmed = + content + |> IO.iodata_to_binary() + |> String.trim() if trimmed == "" do "" diff --git a/test/floki_test.exs b/test/floki_test.exs index 9ff30e28..b9a1f158 100644 --- a/test/floki_test.exs +++ b/test/floki_test.exs @@ -484,6 +484,10 @@ defmodule FlokiTest do
+ encoded content + & + ' + " @@ -517,6 +521,10 @@ defmodule FlokiTest do
+ encoded content + & + ' + " very deep content