Skip to content

Commit bbf8d84

Browse files
authored
Replace EasyHTML and Floki with LazyHTML (#2106)
closes #2105
1 parent eae144f commit bbf8d84

File tree

5 files changed

+21
-17
lines changed

5 files changed

+21
-17
lines changed

mix.exs

+1-2
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,7 @@ defmodule ExDoc.Mixfile do
4646
{:makeup_c, ">= 0.1.0", optional: true},
4747
{:makeup_html, ">= 0.1.0", optional: true},
4848
{:jason, "~> 1.2", only: :test},
49-
{:floki, "~> 0.0", only: :test},
50-
{:easyhtml, "~> 0.0", only: :test}
49+
{:lazy_html, "~> 0.1.0", only: :test}
5150
]
5251
end
5352

mix.lock

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
%{
2+
"cc_precompiler": {:hex, :cc_precompiler, "0.1.10", "47c9c08d8869cf09b41da36538f62bc1abd3e19e41701c2cea2675b53c704258", [:mix], [{:elixir_make, "~> 0.7", [hex: :elixir_make, repo: "hexpm", optional: false]}], "hexpm", "f6e046254e53cd6b41c6bacd70ae728011aa82b2742a80d6e2214855c6e06b22"},
23
"earmark_parser": {:hex, :earmark_parser, "1.4.44", "f20830dd6b5c77afe2b063777ddbbff09f9759396500cdbe7523efd58d7a339c", [:mix], [], "hexpm", "4778ac752b4701a5599215f7030989c989ffdc4f6df457c5f36938cc2d2a2750"},
3-
"easyhtml": {:hex, :easyhtml, "0.3.2", "050adfc8074f53b261f7dfe83303d864f1fbf5988245b369f8fdff1bf4c4b3e6", [:mix], [{:floki, "~> 0.35", [hex: :floki, repo: "hexpm", optional: false]}], "hexpm", "b6a936f91612a4870aa3e828cd8da5a08d9e3b6221b4d3012b6ec70b87845d06"},
4-
"floki": {:hex, :floki, "0.36.2", "a7da0193538c93f937714a6704369711998a51a6164a222d710ebd54020aa7a3", [:mix], [], "hexpm", "a8766c0bc92f074e5cb36c4f9961982eda84c5d2b8e979ca67f5c268ec8ed580"},
4+
"elixir_make": {:hex, :elixir_make, "0.9.0", "6484b3cd8c0cee58f09f05ecaf1a140a8c97670671a6a0e7ab4dc326c3109726", [:mix], [], "hexpm", "db23d4fd8b757462ad02f8aa73431a426fe6671c80b200d9710caf3d1dd0ffdb"},
5+
"fine": {:hex, :fine, "0.1.0", "9bb99a5ff9b968f12c3b458fa1277c39e9a620b23a9439103703a25917293871", [:mix], [], "hexpm", "1d6485bf811b95dc6ae3d197c0e6f994880b86167a827983bb29cbfc03a02684"},
56
"jason": {:hex, :jason, "1.4.4", "b9226785a9aa77b6857ca22832cffa5d5011a667207eb2a0ad56adb5db443b8a", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "c5eb0cab91f094599f94d55bc63409236a8ec69a21a67814529e8d5f6cc90b3b"},
7+
"lazy_html": {:hex, :lazy_html, "0.1.0", "619c4c124a7375ecbf66263de90270d221ffc7479afde436717a4e5cceaac954", [:make, :mix], [{:cc_precompiler, "~> 0.1", [hex: :cc_precompiler, repo: "hexpm", optional: false]}, {:elixir_make, "~> 0.9.0", [hex: :elixir_make, repo: "hexpm", optional: false]}, {:fine, "~> 0.1.0", [hex: :fine, repo: "hexpm", optional: false]}], "hexpm", "a212f417b0e546055b7d5d72d302fce747b63ac9dfe0cf491c1f9af6d198e256"},
68
"makeup": {:hex, :makeup, "1.2.1", "e90ac1c65589ef354378def3ba19d401e739ee7ee06fb47f94c687016e3713d1", [:mix], [{:nimble_parsec, "~> 1.4", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "d36484867b0bae0fea568d10131197a4c2e47056a6fbe84922bf6ba71c8d17ce"},
79
"makeup_c": {:hex, :makeup_c, "0.1.1", "14250b1a69770b1892f4113129417a2df098e2a72b9e1477aa9096e9e6c473a6", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "89e9cf45372822d354c19a7e18d77f84cfd70e2d206ac987eb15a1b8357f2869"},
810
"makeup_elixir": {:hex, :makeup_elixir, "0.16.2", "627e84b8e8bf22e60a2579dad15067c755531fea049ae26ef1020cad58fe9578", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 1.2.3 or ~> 1.3", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "41193978704763f6bbe6cc2758b84909e62984c7752b3784bd3c218bb341706b"},

test/ex_doc/formatter/html/erlang_test.exs

+5-2
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ defmodule ExDoc.Formatter.HTML.ErlangTest do
3030
""")
3131

3232
doc = generate_docs(c)
33-
html = Floki.raw_html(doc)
33+
html = LazyHTML.to_html(doc)
3434

3535
assert html =~
3636
~s|-spec</span> foo(<a href="#t:t/0">t</a>()) -&gt; <a href="#t:t/0">t</a>().|
@@ -54,6 +54,9 @@ defmodule ExDoc.Formatter.HTML.ErlangTest do
5454

5555
ExDoc.generate_docs(config[:project], config[:version], config)
5656

57-
[c.tmp_dir, "doc", "foo.html"] |> Path.join() |> File.read!() |> Floki.parse_document!()
57+
[c.tmp_dir, "doc", "foo.html"]
58+
|> Path.join()
59+
|> File.read!()
60+
|> LazyHTML.from_document()
5861
end
5962
end

test/ex_doc/formatter/html/templates_test.exs

+7-7
Original file line numberDiff line numberDiff line change
@@ -497,13 +497,13 @@ defmodule ExDoc.Formatter.HTML.TemplatesTest do
497497
end
498498
)
499499

500-
doc = EasyHTML.parse!(content)
501-
assert doc["#example-functions a[href='#example-functions']"]
502-
assert doc["#legacy a[href='#legacy']"]
503-
assert doc["#example-functions [id='example/2']"]
504-
refute doc["#legacy [id='example/2']"]
505-
assert doc["#functions [id='example_1/0']"]
506-
refute doc["#functions [id='example/2']"]
500+
doc = LazyHTML.from_document(content)
501+
assert Enum.count(doc["#example-functions a[href='#example-functions']"]) == 1
502+
assert Enum.count(doc["#legacy a[href='#legacy']"]) == 1
503+
assert Enum.count(doc["#example-functions [id='example/2']"]) == 1
504+
assert Enum.count(doc["#legacy [id='example/2']"]) == 0
505+
assert Enum.count(doc["#functions [id='example_1/0']"]) == 1
506+
assert Enum.count(doc["#functions [id='example/2']"]) == 0
507507
end
508508

509509
test "outputs deprecation information", context do

test/ex_doc/formatter/html_test.exs

+4-4
Original file line numberDiff line numberDiff line change
@@ -105,11 +105,11 @@ defmodule ExDoc.Formatter.HTMLTest do
105105

106106
generate_docs(config)
107107

108-
foo_content = EasyHTML.parse!(File.read!("#{c.tmp_dir}/html/readme-1.html"))["#content"]
109-
bar_content = EasyHTML.parse!(File.read!("#{c.tmp_dir}/html/readme-2.html"))["#content"]
108+
foo_content = "#{c.tmp_dir}/html/readme-1.html" |> File.read!() |> LazyHTML.from_document()
109+
bar_content = "#{c.tmp_dir}/html/readme-2.html" |> File.read!() |> LazyHTML.from_document()
110110

111-
assert to_string(foo_content["h1"]) == "README foo"
112-
assert to_string(bar_content["h1"]) == "README bar"
111+
assert LazyHTML.text(foo_content["h1"]) == "README foo"
112+
assert LazyHTML.text(bar_content["h1"]) == "README bar"
113113
end
114114

115115
test "warns when generating an index.html file with an invalid redirect",

0 commit comments

Comments
 (0)