Open HaoLi111 opened 3 years ago
Just realized that the hard part is the line folds when it is too long. Maybe if we detect gif() usage it would be better
Btw, if you really need this, this hack ought to do (am currently using it myself):
using Plots
function Weave.WeavePlots.add_plots_figure(report::Weave.Report, plot::Plots.AnimatedGif, ext)
chunk = report.cur_chunk
full_name, rel_name = Weave.get_figname(report, chunk, ext = ext)
# A `AnimatedGif` has been saved somewhere temporarily, so make a copy to `full_name`.
cp(plot.filename, full_name; force = true)
push!(report.figures, rel_name)
report.fignum += 1
return full_name
end
function Base.display(report::Weave.Report, m::MIME"text/plain", plot::Plots.AnimatedGif)
Weave.WeavePlots.add_plots_figure(report, plot, ".gif")
end
or if you have a package which uses Weave.jl, in which you need the following:
using Requires, Plots
function __init__()
@require Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80" begin
# HACK
function Weave.WeavePlots.add_plots_figure(report::Weave.Report, plot::Plots.AnimatedGif, ext)
chunk = report.cur_chunk
full_name, rel_name = Weave.get_figname(report, chunk, ext = ext)
# A `AnimatedGif` has been saved somewhere temporarily, so make a copy to `full_name`.
cp(plot.filename, full_name; force = true)
push!(report.figures, rel_name)
report.fignum += 1
return full_name
end
function Base.display(report::Weave.Report, m::MIME"text/plain", plot::Plots.AnimatedGif)
Weave.WeavePlots.add_plots_figure(report, plot, ".gif")
end
end
end
If I save a gif in the folder or path the file goes
It seems possible to detect pwd(), which is
and just substitute it with
and then check and match fig_path and finally get
so that we can get support for gif link to this relev proj.