mirror of https://github.com/mpastell/Weave.jl
parent
ff79618182
commit
d75ae6d86b
|
@ -111,6 +111,11 @@ function weave(source ; doctype = :auto, plotlib=:auto,
|
|||
outname = get_outname(out_path, doc, ext = "pdf")
|
||||
end
|
||||
|
||||
doctype == :auto && (doctype = detect_doctype(doc.source))
|
||||
if (contains(doctype, "2html") || contains(doctype, "2pdf")) && cache == :off
|
||||
rm(doc.fig_path, force = true, recursive = true)
|
||||
end
|
||||
|
||||
doc.cwd == pwd() && (outname = basename(outname))
|
||||
|
||||
info("Report weaved to $outname")
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
import JLD
|
||||
|
||||
function write_cache(doc::WeaveDoc, cache_path)
|
||||
cache_dir = "$(doc.cwd)/$cache_path"
|
||||
cache_dir = joinpath(doc.cwd, cache_path)
|
||||
isdir(cache_dir) || mkpath(cache_dir)
|
||||
JLD.save("$cache_dir/$(doc.basename).jld", Dict("doc" => doc))
|
||||
JLD.save(joinpath(cache_dir, doc.basename * ".jld"), Dict("doc" => doc))
|
||||
return nothing
|
||||
end
|
||||
|
||||
function read_cache(doc::WeaveDoc, cache_path)
|
||||
name = "$(doc.cwd)/$cache_path/$(doc.basename).jld"
|
||||
name = joinpath(doc.cwd, cache_path, doc.basename * ".jld")
|
||||
isfile(name) || return nothing
|
||||
return JLD.load(name)["doc"]
|
||||
end
|
||||
|
|
|
@ -71,8 +71,6 @@ function render_doc(formatted, doc::WeaveDoc, format::JMarkdown2HTML)
|
|||
template = Mustache.template_from_file(doc.template)
|
||||
end
|
||||
|
||||
rm(doc.fig_path, force = true, recursive = true)
|
||||
|
||||
return Mustache.render(template, themecss = theme_css,
|
||||
highlightcss = css, body = formatted, header_script = doc.header_script,
|
||||
source = wsource, wtime = wtime, wversion = wversion,
|
||||
|
|
|
@ -40,7 +40,6 @@ function pandoc2html(formatted::AbstractString, doc::WeaveDoc, outname::Abstract
|
|||
close(pandoc_in)
|
||||
proc_output = readstring(pandoc_out)
|
||||
cd(old_wd)
|
||||
rm(doc.fig_path, force = true, recursive = true)
|
||||
catch e
|
||||
cd(old_wd)
|
||||
warn("Error converting document to HTML")
|
||||
|
@ -77,7 +76,6 @@ function pandoc2pdf(formatted::AbstractString, doc::WeaveDoc, outname::AbstractS
|
|||
close(pandoc_in)
|
||||
proc_output = readstring(pandoc_out)
|
||||
cd(old_wd)
|
||||
rm(doc.fig_path, force = true, recursive = true)
|
||||
catch e
|
||||
cd(old_wd)
|
||||
warn("Error converting document to pdf")
|
||||
|
@ -98,7 +96,6 @@ function run_latex(doc::WeaveDoc, outname, latex_cmd = "pdflatex")
|
|||
rm(textmp, recursive=true)
|
||||
rm(xname)
|
||||
cd(old_wd)
|
||||
rm(doc.fig_path, force = true, recursive = true)
|
||||
return true
|
||||
catch e
|
||||
cd(old_wd)
|
||||
|
|
|
@ -28,7 +28,7 @@ function Base.run(doc::WeaveDoc; doctype = :auto, plotlib=:auto,
|
|||
doc.doctype = doctype
|
||||
doc.format = formats[doctype]
|
||||
|
||||
if contains(doctype, "2html") || contains(doctype, "2pdf")
|
||||
if (contains(doctype, "2html") || contains(doctype, "2pdf")) && cache == :off
|
||||
fig_path = mktempdir(doc.cwd)
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue