From 1a08395466897cb3ab23b6d46584a69ebdd352f3 Mon Sep 17 00:00:00 2001 From: Sebastian Date: Sat, 20 Apr 2024 00:10:34 +0200 Subject: [PATCH] Fix: read encode_raw_html config as default for raw_html encode option (#561) --- lib/floki/raw_html.ex | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/lib/floki/raw_html.ex b/lib/floki/raw_html.ex index 108812ce..f0d3ea99 100644 --- a/lib/floki/raw_html.ex +++ b/lib/floki/raw_html.ex @@ -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 = @@ -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