Manually compare tag type for candidate
The match? method is no longer available starting Floki 0.15.0.
This commit is contained in:
parent
d409c3f74d
commit
9e43c454e7
|
@ -79,9 +79,9 @@ defmodule Readability.Helper do
|
|||
Check html_tree can be candidate or not.
|
||||
"""
|
||||
@spec candidate_tag?(html_tree) :: boolean
|
||||
def candidate_tag?(html_tree) do
|
||||
Enum.any?(candidates_selector(), fn(selector) ->
|
||||
Floki.Selector.match?(html_tree, selector)
|
||||
def candidate_tag?({tag, _, _} = html_tree) do
|
||||
Enum.any?(["p", "td"], fn(candidate_tag) ->
|
||||
tag == candidate_tag
|
||||
&& (text_length(html_tree)) >= Readability.default_options[:min_text_length]
|
||||
end)
|
||||
end
|
||||
|
@ -99,12 +99,4 @@ defmodule Readability.Helper do
|
|||
|> Floki.parse
|
||||
|> Floki.filter_out(:comment)
|
||||
end
|
||||
|
||||
defp candidates_selector do
|
||||
["p", "td"]
|
||||
|> Enum.map(fn(s) ->
|
||||
tokens = Floki.SelectorTokenizer.tokenize(s)
|
||||
Floki.SelectorParser.parse(tokens)
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue