diff --git a/src/recipes.jl b/src/recipes.jl index 31aa25b1..ae4bd35c 100644 --- a/src/recipes.jl +++ b/src/recipes.jl @@ -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 diff --git a/test/recipe_test.jl b/test/recipe_test.jl index 47e41eb9..74e58a1d 100644 --- a/test/recipe_test.jl +++ b/test/recipe_test.jl @@ -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$" + +