Fix for out_path only working for directories

pull/413/head
PGunnink 2021-03-02 17:02:16 +01:00
parent c9fc740d72
commit 8dc0441b90
2 changed files with 20 additions and 2 deletions

View File

@ -244,8 +244,16 @@ function specific_options!(weave_options, doctype)
end
get_out_path(doc, out_path, ext::Nothing = nothing) = get_out_path(doc, out_path, doc.format.extension)
get_out_path(doc, out_path, ext) = abspath(get_cwd(doc, out_path), string(doc.basename , '.', ext))
function get_out_path(doc, out_path, ext)
if (out_path === :doc) || (out_path === :pwd)
abspath(get_cwd(doc, out_path), string(doc.basename, '.', ext))
elseif isempty(splitext(out_path)[2]) # directory given
abspath(get_cwd(doc, out_path), string(doc.basename, '.', ext))
else
# out_path is given, but if extension is explitly provided override this will override the extension
abspath(string(splitext(out_path)[1], '.', ext))
end
end
"""
notebook(source::AbstractString; kwargs...)

View File

@ -46,4 +46,14 @@ Core.eval(m, :(const a = $ary))
Weave.clear_module!(m)
@test_broken Base.summarysize(m) < size
julia_markdown_body = """
this is just to test the `out_path` option
"""
f_in = tempname()
f_out = tempname() * ".md"
write(f_in, julia_markdown_body)
f = weave(f_in; out_path=f_out)
@test isfile(f_out)
end # @testset "clear_module!"