support elixir 1.5.1
This commit is contained in:
parent
aca14e3aef
commit
e2c5a4beed
|
@ -4,3 +4,4 @@ elixir:
|
||||||
- 1.2.6
|
- 1.2.6
|
||||||
- 1.3.4
|
- 1.3.4
|
||||||
- 1.4.1
|
- 1.4.1
|
||||||
|
- 1.5.0
|
||||||
|
|
|
@ -58,13 +58,15 @@ defmodule Readability.ArticleBuilder do
|
||||||
|
|
||||||
defp find_article(candidates, html_tree) do
|
defp find_article(candidates, html_tree) do
|
||||||
best_candidate = CandidateFinder.find_best_candidate(candidates)
|
best_candidate = CandidateFinder.find_best_candidate(candidates)
|
||||||
unless best_candidate do
|
article_trees = if best_candidate do
|
||||||
best_candidate = case html_tree |> Floki.find("body") do
|
find_article_trees(best_candidate, candidates)
|
||||||
[tree|_] -> %Candidate{html_tree: tree}
|
else
|
||||||
_ -> %Candidate{html_tree: {}}
|
fallback_candidate = case html_tree |> Floki.find("body") do
|
||||||
end
|
[tree|_] -> %Candidate{html_tree: tree}
|
||||||
end
|
_ -> %Candidate{html_tree: {}}
|
||||||
article_trees = find_article_trees(best_candidate, candidates)
|
end
|
||||||
|
find_article_trees(fallback_candidate, candidates)
|
||||||
|
end
|
||||||
{"div", [], article_trees}
|
{"div", [], article_trees}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -73,11 +75,12 @@ defmodule Readability.ArticleBuilder do
|
||||||
|
|
||||||
candidates
|
candidates
|
||||||
|> Enum.filter(&(&1.tree_depth == best_candidate.tree_depth))
|
|> Enum.filter(&(&1.tree_depth == best_candidate.tree_depth))
|
||||||
|> Enum.filter_map(fn(candidate) ->
|
|> Enum.filter(fn(candidate) ->
|
||||||
candidate == best_candidate
|
candidate == best_candidate
|
||||||
|| candidate.score >= score_threshold
|
|| candidate.score >= score_threshold
|
||||||
|| append?(candidate)
|
|| append?(candidate)
|
||||||
end, &(to_article_tag(&1.html_tree)))
|
end)
|
||||||
|
|> Enum.map(&(to_article_tag(&1.html_tree)))
|
||||||
end
|
end
|
||||||
|
|
||||||
defp append?(%Candidate{html_tree: html_tree}) when elem(html_tree, 0) == "p" do
|
defp append?(%Candidate{html_tree: html_tree}) when elem(html_tree, 0) == "p" do
|
||||||
|
|
2
mix.exs
2
mix.exs
|
@ -40,7 +40,7 @@ defmodule Readability.Mixfile do
|
||||||
#
|
#
|
||||||
# Type "mix help deps" for more examples and options
|
# Type "mix help deps" for more examples and options
|
||||||
defp deps do
|
defp deps do
|
||||||
[{:floki, "~> 0.18.0"},
|
[{:floki, "~> 0.14.0"},
|
||||||
{:httpoison, "~> 0.13.0"},
|
{:httpoison, "~> 0.13.0"},
|
||||||
{:ex_doc, "~> 0.14", only: :dev},
|
{:ex_doc, "~> 0.14", only: :dev},
|
||||||
{:credo, "~> 0.6.1", only: [:dev, :test]},
|
{:credo, "~> 0.6.1", only: [:dev, :test]},
|
||||||
|
|
2
mix.lock
2
mix.lock
|
@ -4,7 +4,7 @@
|
||||||
"dialyxir": {:hex, :dialyxir, "0.5.1", "b331b091720fd93e878137add264bac4f644e1ddae07a70bf7062c7862c4b952", [:mix], []},
|
"dialyxir": {:hex, :dialyxir, "0.5.1", "b331b091720fd93e878137add264bac4f644e1ddae07a70bf7062c7862c4b952", [:mix], []},
|
||||||
"earmark": {:hex, :earmark, "1.2.3", "206eb2e2ac1a794aa5256f3982de7a76bf4579ff91cb28d0e17ea2c9491e46a4", [:mix], []},
|
"earmark": {:hex, :earmark, "1.2.3", "206eb2e2ac1a794aa5256f3982de7a76bf4579ff91cb28d0e17ea2c9491e46a4", [:mix], []},
|
||||||
"ex_doc": {:hex, :ex_doc, "0.16.3", "cd2a4cfe5d26e37502d3ec776702c72efa1adfa24ed9ce723bb565f4c30bd31a", [:mix], [{:earmark, "~> 1.1", [hex: :earmark, optional: false]}]},
|
"ex_doc": {:hex, :ex_doc, "0.16.3", "cd2a4cfe5d26e37502d3ec776702c72efa1adfa24ed9ce723bb565f4c30bd31a", [:mix], [{:earmark, "~> 1.1", [hex: :earmark, optional: false]}]},
|
||||||
"floki": {:hex, :floki, "0.18.0", "643d5e4bb325905328d250760ea622faebac4f7e1521f770d35fbb43d8dd4f5f", [:mix], [{:mochiweb, "~> 2.15", [hex: :mochiweb, optional: false]}]},
|
"floki": {:hex, :floki, "0.14.0", "91a6be57349e10a63cf52d7890479a19012cef9185fa93c305d4fe42e6a50dee", [:mix], [{:mochiweb, "~> 2.15", [hex: :mochiweb, optional: false]}]},
|
||||||
"hackney": {:hex, :hackney, "1.9.0", "51c506afc0a365868469dcfc79a9d0b94d896ec741cfd5bd338f49a5ec515bfe", [:rebar3], [{:certifi, "2.0.0", [hex: :certifi, optional: false]}, {:idna, "5.1.0", [hex: :idna, optional: false]}, {:metrics, "1.0.1", [hex: :metrics, optional: false]}, {:mimerl, "1.0.2", [hex: :mimerl, optional: false]}, {:ssl_verify_fun, "1.1.1", [hex: :ssl_verify_fun, optional: false]}]},
|
"hackney": {:hex, :hackney, "1.9.0", "51c506afc0a365868469dcfc79a9d0b94d896ec741cfd5bd338f49a5ec515bfe", [:rebar3], [{:certifi, "2.0.0", [hex: :certifi, optional: false]}, {:idna, "5.1.0", [hex: :idna, optional: false]}, {:metrics, "1.0.1", [hex: :metrics, optional: false]}, {:mimerl, "1.0.2", [hex: :mimerl, optional: false]}, {:ssl_verify_fun, "1.1.1", [hex: :ssl_verify_fun, optional: false]}]},
|
||||||
"httpoison": {:hex, :httpoison, "0.13.0", "bfaf44d9f133a6599886720f3937a7699466d23bb0cd7a88b6ba011f53c6f562", [:mix], [{:hackney, "~> 1.8", [hex: :hackney, optional: false]}]},
|
"httpoison": {:hex, :httpoison, "0.13.0", "bfaf44d9f133a6599886720f3937a7699466d23bb0cd7a88b6ba011f53c6f562", [:mix], [{:hackney, "~> 1.8", [hex: :hackney, optional: false]}]},
|
||||||
"idna": {:hex, :idna, "5.1.0", "d72b4effeb324ad5da3cab1767cb16b17939004e789d8c0ad5b70f3cea20c89a", [:rebar3], [{:unicode_util_compat, "0.3.1", [hex: :unicode_util_compat, optional: false]}]},
|
"idna": {:hex, :idna, "5.1.0", "d72b4effeb324ad5da3cab1767cb16b17939004e789d8c0ad5b70f3cea20c89a", [:rebar3], [{:unicode_util_compat, "0.3.1", [hex: :unicode_util_compat, optional: false]}]},
|
||||||
|
|
Loading…
Reference in New Issue