keep latex figures

pull/302/head
Fredrik Bagge Carlson 2020-02-09 20:11:29 +08:00
parent 67126a515a
commit 7e88052db3
2 changed files with 31 additions and 41 deletions

View File

@ -131,7 +131,6 @@ function weave(
#theme != nothing && (doc.theme = theme) #Reserved for themes #theme != nothing && (doc.theme = theme) #Reserved for themes
css != nothing && (doc.css = css) css != nothing && (doc.css = css)
try
doc = run(doc, doctype = doctype, doc = run(doc, doctype = doctype,
mod = mod, mod = mod,
out_path=out_path, args = args, out_path=out_path, args = args,
@ -158,22 +157,13 @@ function weave(
rm(mdname) rm(mdname)
elseif doc.doctype == "md2pdf" elseif doc.doctype == "md2pdf"
success = run_latex(doc, outname, latex_cmd) success = run_latex(doc, outname, latex_cmd)
success && rm(doc.fig_path, force = true, recursive = true)
success || return success || return
outname = get_outname(out_path, doc, ext = "pdf") outname = get_outname(out_path, doc, ext = "pdf")
end end
doc.cwd == pwd() && (outname = basename(outname)) doc.cwd == pwd() && (outname = basename(outname))
@info "Report weaved to $outname" @info("Report weaved to $outname")
return abspath(outname) return abspath(outname)
# catch err
# @warn "Something went wrong during weaving"
# @error sprint(showerror, err)
# return nothing
finally
doctype == :auto && (doctype = detect_doctype(doc.source))
occursin(r"2(pdf|html)", doctype) && rm(doc.fig_path, force = true, recursive = true)
end
end end
weave(doc::AbstractString, doctype::Union{Symbol,AbstractString}) = weave(doc::AbstractString, doctype::Union{Symbol,AbstractString}) =

View File

@ -108,7 +108,7 @@ function run_latex(doc::WeaveDoc, outname, latex_cmd = "xelatex")
old_wd = pwd() old_wd = pwd()
cd(doc.cwd) cd(doc.cwd)
xname = basename(outname) xname = basename(outname)
@info("Weaved code to $outname. Running $latex_cmd") @info("Weaved code to $outname . Running $latex_cmd") # space before '.' added for link to be clickable in Juno terminal
textmp = mktempdir(".") textmp = mktempdir(".")
try try
out = read(`$latex_cmd -shell-escape $xname -aux-directory $textmp -include-directory $(doc.cwd)`, String) out = read(`$latex_cmd -shell-escape $xname -aux-directory $textmp -include-directory $(doc.cwd)`, String)