You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
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)
The text was updated successfully, but these errors were encountered:
Good catch, thank you for the report. I think it's ok to ignore the 4th element in the tuple for now and revisit it later when we'd use Earmark to transform ast back to html (then the extra info in the 4th element might be useful). Could you send a PR that ignores the 4th element?
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.ex_doc/lib/ex_doc/autolink.ex
Line 84 in d272497
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#337The text was updated successfully, but these errors were encountered: