diff --git a/src/plots.jl b/src/plots.jl
index ddf4bac..8b50fc3 100644
--- a/src/plots.jl
+++ b/src/plots.jl
@@ -1,5 +1,6 @@
import Plots
+
"""Pre-execute hooks to set the plot size for the chunk """
function plots_set_size(chunk)
w = chunk.options[:fig_width] * chunk.options[:dpi]
@@ -73,3 +74,22 @@ end
function Base.display(report::Report, m::MIME"image/svg+xml", plot::Plots.Plot)
add_plots_figure(report, plot, ".svg")
end
+
+# write out html to view Animated gif
+function Base.display(report::Report, ::MIME"text/html", agif::Plots.AnimatedGif)
+ ext = agif.filename[end-2:end]
+ res = ""
+ if ext == "gif"
+ img = stringmime(MIME("image/gif"), read(agif.filename))
+ res = ""
+ elseif ext in ("mov", "mp4")
+ #Uncomment to embed mp4, make global or chunk option?
+ #img = stringmime(MIME("video/$ext"), read(agif.filename))
+ #res = ""
+ res = ""
+ else
+ error("Cannot show animation with extension $ext: $agif")
+ end
+
+ report.rich_output *= "\n" * res * "\n"
+end
diff --git a/src/run.jl b/src/run.jl
index 0d8ac2b..7edeed2 100644
--- a/src/run.jl
+++ b/src/run.jl
@@ -153,6 +153,8 @@ function img2base64(fig, cwd)
return "data:image/png;base64," * stringmime(MIME("image/png"), raw)
elseif ext == ".svg"
return "data:image/svg+xml;base64," * stringmime(MIME("image/svg+xml"), raw)
+ elseif ext == ".gif"
+ return "data:image/gif;base64," * stringmime(MIME("image/gif"), raw)
else
return(fig)
end