Skip to content

Commit

Permalink
changed with syntax, refactored cond -> if/else
Browse files Browse the repository at this point in the history
  • Loading branch information
bradhanks committed Jan 9, 2024
1 parent c1d7f4a commit 1c298df
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
4 changes: 2 additions & 2 deletions lib/earmark.ex
Original file line number Diff line number Diff line change
Expand Up @@ -260,8 +260,8 @@ defmodule Earmark do
`iex` usage.
"""
def version() do
with {:ok, version} = :application.get_key(:earmark, :vsn),
do: to_string(version)
with {:ok, version} <- :application.get_key(:earmark, :vsn),
do: to_string(version)
end

defp _as_ast(lines, options)
Expand Down
6 changes: 3 additions & 3 deletions lib/earmark_parser.ex
Original file line number Diff line number Diff line change
Expand Up @@ -614,7 +614,7 @@ defmodule Earmark.Parser do
end

def as_ast(_, options) do
raise ArgumentError, "#{inspect options} not a legal options map or keyword list"
raise ArgumentError, "#{inspect(options)} not a legal options map or keyword list"
end

defp _as_ast(lines, options) do
Expand All @@ -627,8 +627,8 @@ defmodule Earmark.Parser do
`iex` usage.
"""
def version() do
with {:ok, version} = :application.get_key(:earmark_parser, :vsn),
do: to_string(version)
with {:ok, version} <- :application.get_key(:earmark_parser, :vsn),
do: to_string(version)
end
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,12 @@ defmodule Test.Acceptance.Earmark.Postprocessor.ReplaceSubtreeTest do
defp render_code_node({"code", attrs, _content, meta} = node) do
classes = Earmark.AstTools.find_att_in_node(node, "class") || ""

cond do
classes =~ "inline" -> node
true -> {:replace, {"code", attrs, "xxx", meta}}
if classes =~ "inline" do
node
else
{:replace, {"code", attrs, "xxx", meta}}
end
end
end

# SPDX-License-Identifier: Apache-2.0

0 comments on commit 1c298df

Please sign in to comment.