mirror of https://github.com/mpastell/Weave.jl
Added support for figure width in pandoc, updated tests
parent
47317b512b
commit
0132cdd33b
4
NEWS.md
4
NEWS.md
|
@ -10,6 +10,10 @@
|
|||
* New output options `md2pdf` and `md2html`, both use pandoc to output pdf
|
||||
and html files directly with own templates.
|
||||
* Restored and improved Winston support.
|
||||
* New input format: scripts with markup in comments
|
||||
* New output format: MultiMarkdown
|
||||
* Added support for figure width in Pandoc
|
||||
* Autodetect input and output formats based on filename
|
||||
|
||||
### v0.1.0
|
||||
|
||||
|
|
|
@ -184,6 +184,7 @@ const pandoc = Pandoc("Pandoc markdown",
|
|||
:outputstart=>"~~~~{.julia}",
|
||||
:outputend=>"~~~~~~~~~~~~~\n\n",
|
||||
:fig_ext=>".png",
|
||||
:out_width=>nothing,
|
||||
:extension=>"md",
|
||||
:doctype=>"pandoc"
|
||||
))
|
||||
|
@ -332,18 +333,21 @@ function formatfigures(chunk, docformat::Pandoc)
|
|||
caption = chunk.options[:fig_cap]
|
||||
result = ""
|
||||
figstring = ""
|
||||
attribs = ""
|
||||
width = chunk.options[:out_width]
|
||||
width == nothing || (attribs = "{width=$width}")
|
||||
|
||||
length(fignames) > 0 || (return "")
|
||||
|
||||
if caption != nothing
|
||||
result *= "![$caption]($(fignames[1]))\n"
|
||||
result *= "![$caption]($(fignames[1]))$attribs\n"
|
||||
for fig = fignames[2:end]
|
||||
result *= "![]($fig)\n"
|
||||
result *= "![]($fig)$attribs\n"
|
||||
println("Warning, only the first figure gets a caption\n")
|
||||
end
|
||||
else
|
||||
for fig in fignames
|
||||
result *= "![]($fig)\\ \n\n"
|
||||
result *= "![]($fig)$attribs\\ \n\n"
|
||||
end
|
||||
end
|
||||
return result
|
||||
|
|
|
@ -0,0 +1,74 @@
|
|||
|
||||
|
||||
````julia
|
||||
using Gadfly
|
||||
x = linspace(0, 2π, 200)
|
||||
plot(x=x, y = sin(x), Geom.line)
|
||||
````
|
||||
|
||||
|
||||
![sin(x) function.][figures/gadfly_formats_test_sin_fun_1.png]
|
||||
|
||||
[figures/gadfly_formats_test_sin_fun_1.png]: figures/gadfly_formats_test_sin_fun_1.png
|
||||
|
||||
|
||||
|
||||
![cos(x) function.][figures/gadfly_formats_test_2_1.png]
|
||||
|
||||
[figures/gadfly_formats_test_2_1.png]: figures/gadfly_formats_test_2_1.png
|
||||
|
||||
|
||||
|
||||
![][figures/gadfly_formats_test_cos2_fun_1.png]
|
||||
|
||||
[figures/gadfly_formats_test_cos2_fun_1.png]: figures/gadfly_formats_test_cos2_fun_1.png
|
||||
|
||||
|
||||
|
||||
````julia
|
||||
julia> x = linspace(0, 2π, 200)
|
||||
|
||||
linspace(0.0,6.283185307179586,200)
|
||||
julia> plot(x=x, y = sin(x), Geom.line)
|
||||
|
||||
````
|
||||
|
||||
|
||||
![][figures/gadfly_formats_test_4_1.png]
|
||||
|
||||
[figures/gadfly_formats_test_4_1.png]: figures/gadfly_formats_test_4_1.png
|
||||
|
||||
````julia
|
||||
julia> y = 20
|
||||
|
||||
20
|
||||
julia> plot(x=x, y = cos(x), Geom.line)
|
||||
````
|
||||
|
||||
|
||||
![][figures/gadfly_formats_test_4_2.png]
|
||||
|
||||
[figures/gadfly_formats_test_4_2.png]: figures/gadfly_formats_test_4_2.png
|
||||
|
||||
|
||||
|
||||
````julia
|
||||
x = linspace(0, 2π, 200)
|
||||
plot(x=x, y = sin(x), Geom.line)
|
||||
|
||||
````
|
||||
|
||||
|
||||
![][figures/gadfly_formats_test_5_1.png]
|
||||
|
||||
[figures/gadfly_formats_test_5_1.png]: figures/gadfly_formats_test_5_1.png width=15cm
|
||||
|
||||
````julia
|
||||
y = 20
|
||||
plot(x=x, y = cos(x), Geom.line)
|
||||
````
|
||||
|
||||
|
||||
![][figures/gadfly_formats_test_5_2.png]
|
||||
|
||||
[figures/gadfly_formats_test_5_2.png]: figures/gadfly_formats_test_5_2.png width=15cm
|
|
@ -52,7 +52,7 @@ plot(x=x, y = sin(x), Geom.line)
|
|||
~~~~~~~~~~~~~
|
||||
|
||||
|
||||
![](figures/gadfly_formats_test_5_1.png)\
|
||||
![](figures/gadfly_formats_test_5_1.png){width=15cm}\
|
||||
|
||||
|
||||
~~~~{.julia}
|
||||
|
@ -61,5 +61,5 @@ plot(x=x, y = cos(x), Geom.line)
|
|||
~~~~~~~~~~~~~
|
||||
|
||||
|
||||
![](figures/gadfly_formats_test_5_2.png)\
|
||||
![](figures/gadfly_formats_test_5_2.png){width=15cm}\
|
||||
|
||||
|
|
|
@ -52,7 +52,7 @@ plot(x=x, y = sin(x), Geom.line)
|
|||
~~~~~~~~~~~~~
|
||||
|
||||
|
||||
![](figures/gadfly_formats_test_5_1.svg)\
|
||||
![](figures/gadfly_formats_test_5_1.svg){width=15cm}\
|
||||
|
||||
|
||||
~~~~{.julia}
|
||||
|
@ -61,5 +61,5 @@ plot(x=x, y = cos(x), Geom.line)
|
|||
~~~~~~~~~~~~~
|
||||
|
||||
|
||||
![](figures/gadfly_formats_test_5_2.svg)\
|
||||
![](figures/gadfly_formats_test_5_2.svg){width=15cm}\
|
||||
|
||||
|
|
|
@ -33,12 +33,16 @@ result = @compat readstring(open("documents/gadfly_formats_test.md"))
|
|||
ref = @compat readstring(open("documents/gadfly_formats_test_jssvg_ref.md"))
|
||||
@test result == ref
|
||||
|
||||
|
||||
weave("documents/gadfly_formats_test.txt", doctype="rst", plotlib="gadfly")
|
||||
result = @compat readstring(open("documents/gadfly_formats_test.rst"))
|
||||
ref = @compat readstring(open("documents/gadfly_formats_test_ref.rst"))
|
||||
@test result == ref
|
||||
|
||||
weave("documents/gadfly_formats_test.txt", doctype="multimarkdown", plotlib="gadfly")
|
||||
result = @compat readstring(open("documents/gadfly_formats_test.md"))
|
||||
ref = @compat readstring(open("documents/gadfly_formats_test_mmd_ref.md"))
|
||||
@test result == ref
|
||||
|
||||
weave("documents/gadfly_formats_test.txt", doctype="asciidoc", plotlib="gadfly",
|
||||
out_path="documents/output")
|
||||
result = @compat readstring(open("documents/output/gadfly_formats_test.txt"))
|
||||
|
|
Loading…
Reference in New Issue