Skip to content

Commit 2db3aa3

Browse files
Fix Floki.text/2 when document contains a doctype declaration (#702)
This fixes #701. The fix is analogous to that in #696.
1 parent 82d021a commit 2db3aa3

2 files changed

Lines changed: 7 additions & 0 deletions

File tree

lib/floki/deep_text.ex

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ defmodule Floki.DeepText do
4444
defp get_text({"script", _, _}, acc, _, _, false, _), do: acc
4545
defp get_text({"style", _, _}, acc, _, _, _, false), do: acc
4646
defp get_text({:pi, _, _}, acc, _, _, _, _), do: acc
47+
defp get_text({:doctype, _, _, _}, acc, _, _, _, _), do: acc
4748

4849
defp get_text({"input", attrs, _}, acc, _, true, _, _) do
4950
[acc, Floki.TextExtractor.extract_input_value(attrs)]

test/floki/deep_text_test.exs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,4 +112,10 @@ defmodule Floki.DeepTextTest do
112112

113113
assert Floki.DeepText.get(nodes) == "foo"
114114
end
115+
116+
test "HTML that contains a doctype (<!doctype html>)" do
117+
nodes = [{:doctype, "html", "", ""}, "foo"]
118+
119+
assert Floki.DeepText.get(nodes) == "foo"
120+
end
115121
end

0 commit comments

Comments
 (0)