mirror of https://github.com/mpastell/Weave.jl
fix case when `weave_options` are empty
parent
3f4ba672b3
commit
0f94c7b49c
|
@ -128,12 +128,13 @@ function weave(
|
|||
|
||||
# overwrites options with those specified in header, that are needed for running document
|
||||
# NOTE: these YAML options can NOT be given dynamically
|
||||
weave_options = get(doc.header, WEAVE_OPTION_NAME, Dict())
|
||||
weave_options = get(doc.header, WEAVE_OPTION_NAME, nothing)
|
||||
if haskey(doc.header, WEAVE_OPTION_NAME_DEPRECATED)
|
||||
@warn "Weave: `options` key is deprecated. Use `weave_options` key instead."
|
||||
weave_options = get(doc.header, WEAVE_OPTION_NAME_DEPRECATED, Dict())
|
||||
weave_options = get(doc.header, WEAVE_OPTION_NAME_DEPRECATED, nothing)
|
||||
end
|
||||
if !isempty(weave_options)
|
||||
|
||||
if !isnothing(weave_options)
|
||||
doctype = get(weave_options, "doctype", doctype)
|
||||
specific_options!(weave_options, doctype)
|
||||
if haskey(weave_options, "out_path")
|
||||
|
@ -173,7 +174,7 @@ function weave(
|
|||
|
||||
# overwrites options with those specified in header, that are needed for formatting document
|
||||
# NOTE: these YAML options can be given dynamically
|
||||
if !isempty(weave_options)
|
||||
if !isnothing(weave_options)
|
||||
if haskey(weave_options, "template")
|
||||
template = weave_options["template"]
|
||||
# resolve relative to this document
|
||||
|
|
|
@ -10,9 +10,9 @@ function WeaveDoc(source, informat = nothing)
|
|||
|
||||
# update default chunk options from header
|
||||
chunk_defaults = deepcopy(get_chunk_defaults())
|
||||
if haskey(header, WEAVE_OPTION_NAME)
|
||||
if (weave_options = get(header, WEAVE_OPTION_NAME, nothing)) !== nothing
|
||||
for key in keys(chunk_defaults)
|
||||
if (val = get(header[WEAVE_OPTION_NAME], string(key), nothing)) !== nothing
|
||||
if (val = get(weave_options, string(key), nothing)) !== nothing
|
||||
chunk_defaults[key] = val
|
||||
end
|
||||
end
|
||||
|
|
|
@ -39,6 +39,16 @@ end
|
|||
end
|
||||
|
||||
|
||||
@testset "empty header" begin
|
||||
str = """
|
||||
---
|
||||
weave_options:
|
||||
---
|
||||
"""
|
||||
@test (mock_doc(str; run = true); true) # no throw
|
||||
end
|
||||
|
||||
|
||||
@testset "dynamic header specifications" begin
|
||||
|
||||
let
|
||||
|
|
Loading…
Reference in New Issue