-
-
Notifications
You must be signed in to change notification settings - Fork 155
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add
include_inputs?
option to Floki.text (#459)
Closes #391
- Loading branch information
1 parent
07bb4cc
commit 34fb89a
Showing
6 changed files
with
128 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
defmodule Floki.TextExtractor do | ||
@moduledoc false | ||
|
||
@allowed_input_types [ | ||
"color", | ||
"date", | ||
"datetime-local", | ||
"email", | ||
"month", | ||
"number", | ||
"search", | ||
"tel", | ||
"text", | ||
"time", | ||
"url", | ||
"week" | ||
] | ||
|
||
def extract_input_value(attrs) do | ||
{"type", t} = Enum.find(attrs, {"type", "text"}, &match?({"type", _}, &1)) | ||
|
||
if t in @allowed_input_types do | ||
extract_value(attrs) | ||
else | ||
"" | ||
end | ||
end | ||
|
||
defp extract_value(attrs) do | ||
Enum.find_value(attrs, "", fn | ||
{"value", v} -> v | ||
_ -> nil | ||
end) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters