Skip to content

Commit

Permalink
ensure a proplist as options is in use to retrieve filename
Browse files Browse the repository at this point in the history
  • Loading branch information
Manuel Rubio committed Apr 3, 2021
1 parent c8d4516 commit cabbcbc
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/earmark/message.ex
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,11 @@ defmodule Earmark.Message do
messages
|> Enum.each(&emit_message(file, &1))
end
def emit_messages(messages, _) do
def emit_messages(messages, proplist) when is_list(proplist) do
messages
|> Enum.each(&emit_message(proplist[:file] || "<args>", &1))
end
def emit_messages(messages, options) do
messages
|> Enum.each(&emit_message("<args>", &1))
end
Expand Down
8 changes: 8 additions & 0 deletions test/acceptance/html/illegal_options_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,12 @@ defmodule Test.Acceptance.Html.IllegalOptionsTest do
end)
assert error_messages == "<args>:0: warning: Unrecognized option oops: Earmark ignored\n"
end

test "with as_html! defining filename" do
error_messages =
capture_io(:stderr, fn ->
as_html!("hello", oops: Earmark, file: "test.md")
end)
assert error_messages == "test.md:0: warning: Unrecognized option oops: Earmark ignored\n"
end
end

0 comments on commit cabbcbc

Please sign in to comment.