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.
|
Check html_tree can be candidate or not.
|
||||||
"""
|
"""
|
||||||
@spec candidate_tag?(html_tree) :: boolean
|
@spec candidate_tag?(html_tree) :: boolean
|
||||||
def candidate_tag?(html_tree) do
|
def candidate_tag?({tag, _, _} = html_tree) do
|
||||||
Enum.any?(candidates_selector(), fn(selector) ->
|
Enum.any?(["p", "td"], fn(candidate_tag) ->
|
||||||
Floki.Selector.match?(html_tree, selector)
|
tag == candidate_tag
|
||||||
&& (text_length(html_tree)) >= Readability.default_options[:min_text_length]
|
&& (text_length(html_tree)) >= Readability.default_options[:min_text_length]
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
@ -99,12 +99,4 @@ defmodule Readability.Helper do
|
||||||
|> Floki.parse
|
|> Floki.parse
|
||||||
|> Floki.filter_out(:comment)
|
|> Floki.filter_out(:comment)
|
||||||
end
|
end
|
||||||
|
|
||||||
defp candidates_selector do
|
|
||||||
["p", "td"]
|
|
||||||
|> Enum.map(fn(s) ->
|
|
||||||
tokens = Floki.SelectorTokenizer.tokenize(s)
|
|
||||||
Floki.SelectorParser.parse(tokens)
|
|
||||||
end)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue