Skip to content

Commit

Permalink
Fix: read encode_raw_html config as default for raw_html encode option (
Browse files Browse the repository at this point in the history
  • Loading branch information
Sgoettschkes committed Apr 19, 2024
1 parent b3a255b commit 1a08395
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions lib/floki/raw_html.ex
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,12 @@ defmodule Floki.RawHTML do
@no_encoder &Function.identity/1

def raw_html(html_tree, opts) do
opts = Keyword.validate!(opts, encode: true, pretty: false)
opts = Keyword.validate!(opts, encode: use_default_encoder?(), pretty: false)

encoder =
case opts[:encode] do
true -> @encoder
false -> @no_encoder
:error -> default_encoder()
end

padding =
Expand Down Expand Up @@ -196,12 +195,8 @@ defmodule Floki.RawHTML do
]
end

defp default_encoder do
if Application.get_env(:floki, :encode_raw_html, true) do
@encoder
else
@no_encoder
end
defp use_default_encoder? do
Application.get_env(:floki, :encode_raw_html, true)
end

# helpers
Expand Down

0 comments on commit 1a08395

Please sign in to comment.