Skip to content

Commit a084cb0

Browse files
garazdawiclaude
andcommitted
Skip HTML comments when computing synopsis
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 90f4862 commit a084cb0

2 files changed

Lines changed: 5 additions & 0 deletions

File tree

lib/ex_doc/doc_ast.ex

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ defmodule ExDoc.DocAST do
166166
to_html({:p, [], remove_ids(inner), meta})
167167
end
168168

169+
def synopsis([{:comment, _, _, _} | rest]), do: synopsis(rest)
169170
def synopsis([head | _]), do: synopsis(head)
170171
def synopsis(_other), do: ""
171172

test/ex_doc/doc_ast_test.exs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,10 @@ defmodule ExDoc.DocASTTest do
147147
"<p>Example function: Summary should display trailing period :.</p>"
148148
end
149149

150+
test "skips html comments" do
151+
assert synopsis("<!-- comment -->\nSynopsis.") == "<p>Synopsis.</p>"
152+
end
153+
150154
defp synopsis(markdown) do
151155
markdown
152156
|> parse!("text/markdown")

0 commit comments

Comments
 (0)