update deps and deprecated
This commit is contained in:
parent
133044f50c
commit
2ed20b6fe1
|
@ -208,7 +208,7 @@ defmodule Readability do
|
||||||
Regex.replace(tags_to_br, html_str, &"\n#{&1}")
|
Regex.replace(tags_to_br, html_str, &"\n#{&1}")
|
||||||
|> Floki.parse()
|
|> Floki.parse()
|
||||||
|> Floki.text()
|
|> Floki.text()
|
||||||
|> String.strip()
|
|> String.trim()
|
||||||
end
|
end
|
||||||
|
|
||||||
@doc """
|
@doc """
|
||||||
|
|
|
@ -25,7 +25,7 @@ defmodule Readability.AuthorFinder do
|
||||||
meta
|
meta
|
||||||
|> Floki.attribute("content")
|
|> Floki.attribute("content")
|
||||||
|> Enum.join(" ")
|
|> Enum.join(" ")
|
||||||
|> String.strip()
|
|> String.trim()
|
||||||
end)
|
end)
|
||||||
|> Enum.reject(&(is_nil(&1) || String.length(&1) == 0))
|
|> Enum.reject(&(is_nil(&1) || String.length(&1) == 0))
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,8 @@ defmodule Readability.Candidate.Cleaner do
|
||||||
defp unlikely_tree?({tag, attrs, _}) do
|
defp unlikely_tree?({tag, attrs, _}) do
|
||||||
idclass_str =
|
idclass_str =
|
||||||
attrs
|
attrs
|
||||||
|> Enum.filter_map(&(elem(&1, 0) =~ ~r/id|class/i), &elem(&1, 1))
|
|> Enum.filter(&(elem(&1, 0) =~ ~r/id|class/i))
|
||||||
|
|> Enum.map(&elem(&1, 1))
|
||||||
|> Enum.join("")
|
|> Enum.join("")
|
||||||
|
|
||||||
str = tag <> idclass_str
|
str = tag <> idclass_str
|
||||||
|
|
|
@ -84,7 +84,8 @@ defmodule Readability.Candidate.Scoring do
|
||||||
defp calc_grand_children_content_score({_, _, children_tree}) do
|
defp calc_grand_children_content_score({_, _, children_tree}) do
|
||||||
score =
|
score =
|
||||||
children_tree
|
children_tree
|
||||||
|> Enum.filter_map(&is_tuple(&1), &elem(&1, 2))
|
|> Enum.filter(&is_tuple(&1))
|
||||||
|
|> Enum.map(&elem(&1, 2))
|
||||||
|> List.flatten()
|
|> List.flatten()
|
||||||
|> Enum.filter(&(is_tuple(&1) && Helper.candidate_tag?(&1)))
|
|> Enum.filter(&(is_tuple(&1) && Helper.candidate_tag?(&1)))
|
||||||
|> calc_content_score
|
|> calc_content_score
|
||||||
|
|
|
@ -84,7 +84,7 @@ defmodule Readability.Helper do
|
||||||
"""
|
"""
|
||||||
@spec text_length(html_tree) :: number
|
@spec text_length(html_tree) :: number
|
||||||
def text_length(html_tree) do
|
def text_length(html_tree) do
|
||||||
html_tree |> Floki.text() |> String.strip() |> String.length()
|
html_tree |> Floki.text() |> String.trim() |> String.length()
|
||||||
end
|
end
|
||||||
|
|
||||||
@doc """
|
@doc """
|
||||||
|
|
|
@ -77,13 +77,13 @@ defmodule Readability.TitleFinder do
|
||||||
end
|
end
|
||||||
|
|
||||||
defp clean_title([title]) when is_binary(title) do
|
defp clean_title([title]) when is_binary(title) do
|
||||||
String.strip(title)
|
String.trim(title)
|
||||||
end
|
end
|
||||||
|
|
||||||
defp clean_title(html_tree) do
|
defp clean_title(html_tree) do
|
||||||
html_tree
|
html_tree
|
||||||
|> Floki.text()
|
|> Floki.text()
|
||||||
|> String.strip()
|
|> String.trim()
|
||||||
end
|
end
|
||||||
|
|
||||||
defp good_title?(title) do
|
defp good_title?(title) do
|
||||||
|
|
4
mix.exs
4
mix.exs
|
@ -2,7 +2,7 @@ defmodule Readability.Mixfile do
|
||||||
@moduledoc """
|
@moduledoc """
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@version "0.9.1"
|
@version "0.10.0"
|
||||||
@description """
|
@description """
|
||||||
Readability library for extracting and curating articles.
|
Readability library for extracting and curating articles.
|
||||||
"""
|
"""
|
||||||
|
@ -43,7 +43,7 @@ defmodule Readability.Mixfile do
|
||||||
{:floki, "~> 0.20"},
|
{:floki, "~> 0.20"},
|
||||||
{: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.9", only: [:dev, :test]},
|
||||||
{:dialyxir, "~> 0.3", only: [:dev]},
|
{:dialyxir, "~> 0.3", only: [:dev]},
|
||||||
{:mock, "~> 0.2.0", only: :test}
|
{:mock, "~> 0.2.0", only: :test}
|
||||||
]
|
]
|
||||||
|
|
3
mix.lock
3
mix.lock
|
@ -1,7 +1,7 @@
|
||||||
%{
|
%{
|
||||||
"bunt": {:hex, :bunt, "0.2.0", "951c6e801e8b1d2cbe58ebbd3e616a869061ddadcc4863d0a2182541acae9a38", [:mix], []},
|
"bunt": {:hex, :bunt, "0.2.0", "951c6e801e8b1d2cbe58ebbd3e616a869061ddadcc4863d0a2182541acae9a38", [:mix], []},
|
||||||
"certifi": {:hex, :certifi, "2.0.0", "a0c0e475107135f76b8c1d5bc7efb33cd3815cb3cf3dea7aefdd174dabead064", [:rebar3], []},
|
"certifi": {:hex, :certifi, "2.0.0", "a0c0e475107135f76b8c1d5bc7efb33cd3815cb3cf3dea7aefdd174dabead064", [:rebar3], []},
|
||||||
"credo": {:hex, :credo, "0.6.1", "a941e2591bd2bd2055dc92b810c174650b40b8290459c89a835af9d59ac4a5f8", [:mix], [{:bunt, "~> 0.2.0", [hex: :bunt, optional: false]}]},
|
"credo": {:hex, :credo, "0.9.3", "76fa3e9e497ab282e0cf64b98a624aa11da702854c52c82db1bf24e54ab7c97a", [:mix], [{:bunt, "~> 0.2.0", [hex: :bunt, repo: "hexpm", optional: false]}, {:poison, ">= 0.0.0", [hex: :poison, repo: "hexpm", optional: false]}], "hexpm"},
|
||||||
"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]}]},
|
||||||
|
@ -15,6 +15,7 @@
|
||||||
"mimerl": {:hex, :mimerl, "1.0.2", "993f9b0e084083405ed8252b99460c4f0563e41729ab42d9074fd5e52439be88", [:rebar3], []},
|
"mimerl": {:hex, :mimerl, "1.0.2", "993f9b0e084083405ed8252b99460c4f0563e41729ab42d9074fd5e52439be88", [:rebar3], []},
|
||||||
"mochiweb": {:hex, :mochiweb, "2.15.0", "e1daac474df07651e5d17cc1e642c4069c7850dc4508d3db7263a0651330aacc", [:rebar3], []},
|
"mochiweb": {:hex, :mochiweb, "2.15.0", "e1daac474df07651e5d17cc1e642c4069c7850dc4508d3db7263a0651330aacc", [:rebar3], []},
|
||||||
"mock": {:hex, :mock, "0.2.1", "bfdba786903e77f9c18772dee472d020ceb8ef000783e737725a4c8f54ad28ec", [:mix], [{:meck, "~> 0.8.2", [hex: :meck, optional: false]}]},
|
"mock": {:hex, :mock, "0.2.1", "bfdba786903e77f9c18772dee472d020ceb8ef000783e737725a4c8f54ad28ec", [:mix], [{:meck, "~> 0.8.2", [hex: :meck, optional: false]}]},
|
||||||
|
"poison": {:hex, :poison, "3.1.0", "d9eb636610e096f86f25d9a46f35a9facac35609a7591b3be3326e99a0484665", [:mix], [], "hexpm"},
|
||||||
"ssl_verify_fun": {:hex, :ssl_verify_fun, "1.1.1", "28a4d65b7f59893bc2c7de786dec1e1555bd742d336043fe644ae956c3497fbe", [:make, :rebar], []},
|
"ssl_verify_fun": {:hex, :ssl_verify_fun, "1.1.1", "28a4d65b7f59893bc2c7de786dec1e1555bd742d336043fe644ae956c3497fbe", [:make, :rebar], []},
|
||||||
"unicode_util_compat": {:hex, :unicode_util_compat, "0.3.1", "a1f612a7b512638634a603c8f401892afbf99b8ce93a45041f8aaca99cadb85e", [:rebar3], []},
|
"unicode_util_compat": {:hex, :unicode_util_compat, "0.3.1", "a1f612a7b512638634a603c8f401892afbf99b8ce93a45041f8aaca99cadb85e", [:rebar3], []},
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue