Skip to content

Commit 10d8315

Browse files
committed
Ensure IDs rather than hrefs are stripped, closes #2175
1 parent 72bb755 commit 10d8315

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

lib/ex_doc/doc_ast.ex

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -171,12 +171,9 @@ defmodule ExDoc.DocAST do
171171
def synopsis([head | _]), do: synopsis(head)
172172
def synopsis(_other), do: ""
173173

174-
@doc """
175-
Remove ids from elements.
176-
"""
177-
def remove_ids(ast) do
174+
defp remove_ids(ast) do
178175
map_tags(ast, fn {tag, attrs, inner, meta} ->
179-
{tag, Keyword.delete(attrs, :href), inner, meta}
176+
{tag, Keyword.delete(attrs, :id), inner, meta}
180177
end)
181178
end
182179

test/ex_doc/doc_ast_test.exs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,16 @@ defmodule ExDoc.DocASTTest do
9898
describe "synopsis" do
9999
test "functionality" do
100100
assert synopsis("") == ""
101-
assert synopsis("<p>.</p>") == "<p>.</p>"
102-
assert synopsis("<p>::</p>") == "<p></p>"
103-
assert synopsis("<p>Description:</p>") == "<p>Description</p>"
104-
assert synopsis("<p>abcd</p>") == "<p>abcd</p>"
101+
assert synopsis(".") == "<p>.</p>"
102+
assert synopsis("::") == "<p></p>"
103+
assert synopsis("abcd") == "<p>abcd</p>"
104+
assert synopsis("Description:") == "<p>Description</p>"
105+
106+
assert synopsis("[Access](Access.html)") ==
107+
"<p><a href=\"Access.html\">Access</a></p>"
108+
109+
assert synopsis("[Access](Access.html) {: #foo}") ==
110+
"<p><a href=\"Access.html\">Access</a></p>"
105111
end
106112

107113
test "should not end have trailing periods or semicolons" do

0 commit comments

Comments
 (0)