JunoLab / Weave.jl

Scientific reports/literate programming for Julia
http://weavejl.mpastell.com
MIT License
830 stars 96 forks source link

#+ fig_ext=".png" not respected #130

Closed baggepinnen closed 5 years ago

baggepinnen commented 6 years ago

In test.jl

#' Test
#+ fig_ext=".png"
using Plots
#+ fig_ext=".png"
plot(randn(19))
julia> weave("/tmp/test.jl", doctype="github", out_path="build")

produces an .svg figure instead of .png

tlnagy commented 6 years ago

I can confirm this bug, but with using Gadfly

test.jmd:

```{julia; fig_ext=".png"}
using Gadfly
plot(x=[1,2,3], y=[1,2,3], Geom.line)

On Julia v0.6 with Weave 0.5.2

julia> weave("test.jmd", doctype="pandoc") INFO: Weaving chunk 1 from line 1 INFO: Report weaved to test.md



produces the expected result: `figures/test_1_1.png`

On Julia v1.0 with Weave#master, the same command gives a SVG file. This is problematic because embedding figures in PDFs fails on master since Weave attempts to embed a SVG instead of a PNG file like it used to.
kleinschmidt commented 5 years ago

I encountered this too, using Plots. I think the issue in my case is that displaying a Report uses the mimetypes in the formatter, without looking at the fig_ext parameter. So because image/png is first in the mimetypes for pandoc (in my case), the method that gets called is display(report, ::mime"image/png", ::Plots.plot), and fig_ext is never checked. When I change the :mimetypes entry in the format dict for pandoc to have "application/pdf" first, I get PDF figures like I want.