Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/recipes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,11 @@ function create_kw_body(func_signature::Expr)
@warn("Type annotations on keyword arguments not currently supported in recipes. Type information has been discarded")
end
push!(kw_body.args, :($k = kwargs[$(Meta.quot(k))]))
kw_dict[k] = v isa QuoteNode ? v.value : v
if v == :nothing
kw_dict[k] = nothing
else
kw_dict[k] = v isa QuoteNode ? v.value : v
end
end
args = args[2:end]
end
Expand Down
13 changes: 13 additions & 0 deletions test/recipe_test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -215,3 +215,16 @@ sum1 = MyModule.MySum(3, 4)
@test latexify(:(2 + $(sum1)^2)) == raw"$2 + \left( 3 + 4 \right)^{2}$"
@test latexify(:(2 - $(sum1))) == raw"$2 - \left( 3 + 4 \right)$"

struct NothingThing end
@latexrecipe function f(::NothingThing; keyword=nothing)
if isnothing(keyword)
return L"a"
elseif keyword == :nothing
return L"b"
end
end
@test latexify(NothingThing()) == raw"$a$"
@test latexify(NothingThing(); keyword=nothing) == raw"$a$"
@test latexify(NothingThing(); keyword=:nothing) == raw"$b$"