-
Notifications
You must be signed in to change notification settings - Fork 352
Description
In building the documentation for a package I came across an error in ExDoc when there was html in the markdown. This was the simplest test-case I found:
ExDoc.Markdown.to_ast("<p>\nTest\n</p>", []), calls into Earmark and it returns a 4 element tuple with %{meta: %{verbatim: true}} in the fourth element.
This is not being matched by ExDoc.Markdown.Earmark.fixup/1, see error below. Easy fix is to match it there and pass through the 4-element tuple but this leads to failures in other places the ast is walked over, e.g.
Line 84 in d272497
| defp walk({tag, attrs, ast}, config) do |
Other option is to ignore the fourth element and let fix_up/1 return a three element tuple but don't know the implications of that. Esp given this discussion in pragdave/earmark#337
1) test to_ast/1 generate AST (ExDoc.Markdown.EarmarkTest)
test/ex_doc/markdown/earmark_test.exs:9
** (FunctionClauseError) no function clause matching in ExDoc.Markdown.Earmark.fixup/1
The following arguments were given to ExDoc.Markdown.Earmark.fixup/1:
# 1
{"p", [], ["Test"], %{meta: %{verbatim: true}}}
Attempted function clauses (showing 3 out of 3):
defp fixup(list) when is_list(list)
defp fixup(binary) when is_binary(binary)
defp fixup({tag, attrs, ast})
code: assert Markdown.to_ast("<p>\nTest\n</p>", []) == [{:p, '', ["Test"]}]
stacktrace:
(ex_doc 0.22.0) lib/ex_doc/markdown/earmark.ex:58: ExDoc.Markdown.Earmark.fixup/1
(elixir 1.10.1) lib/enum.ex:1396: Enum."-map/2-lists^map/1-0-"/2
test/ex_doc/markdown/earmark_test.exs:12: (test)