Skip to content

Commit

Permalink
Fix code to deal with AST with irregular format in EarkMarkParser
Browse files Browse the repository at this point in the history
  • Loading branch information
eksperimental committed Jul 17, 2020
1 parent d67bb34 commit 46fd405
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
5 changes: 5 additions & 0 deletions lib/ex_doc/autolink.ex
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ defmodule ExDoc.Autolink do
ast
end

# TODO: remove this when this AST format is deprecate in EarkMarkParser
defp walk({:pre, _metadata, _} = ast, _config) do
ast
end

defp walk({:a, metadata, attrs, inner} = ast, config) do
cond do
url = custom_link(attrs, config) ->
Expand Down
9 changes: 9 additions & 0 deletions lib/ex_doc/markdown/ast.ex
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,15 @@ defmodule ExDoc.Markdown.AST do
]
end

# TODO: remove this when this AST format is deprecate in EarkMarkParser
defp to_html({:pre, attributes, text}, _options, _verbatim) when is_binary(text) do
[
open_element(:pre, attributes),
to_html([text]),
"</pre>\n"
]
end

# Element with no children
defp to_html({tag, _metadata, attributes, []}, _options, _verbatim) do
[open_element(tag, attributes), "</#{tag}>", "\n"]
Expand Down
2 changes: 1 addition & 1 deletion lib/ex_doc/markdown/earmark.ex
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ defmodule ExDoc.Markdown.Earmark do
fixup({tag, attrs, ast, %{}}, options, meta)
end

defp fixup({:comment, children}, _options, meta) do
defp fixup({:comment, _, children, %{comment: true}}, _options, meta) do
{nil, Map.put(meta, :comment, true), [], children}
end

Expand Down

0 comments on commit 46fd405

Please sign in to comment.