mirror of https://github.com/mpastell/Weave.jl
Merge branch 'pandoc-crossref'
commit
3c81cd5bf2
|
@ -371,7 +371,10 @@ end
|
||||||
|
|
||||||
function formatfigures(chunk, docformat::Pandoc)
|
function formatfigures(chunk, docformat::Pandoc)
|
||||||
fignames = chunk.figures
|
fignames = chunk.figures
|
||||||
|
length(fignames) > 0 || (return "")
|
||||||
|
|
||||||
caption = chunk.options[:fig_cap]
|
caption = chunk.options[:fig_cap]
|
||||||
|
label = get(chunk.options, :label, nothing)
|
||||||
result = ""
|
result = ""
|
||||||
figstring = ""
|
figstring = ""
|
||||||
attribs = ""
|
attribs = ""
|
||||||
|
@ -379,11 +382,11 @@ function formatfigures(chunk, docformat::Pandoc)
|
||||||
height = chunk.options[:out_height]
|
height = chunk.options[:out_height]
|
||||||
|
|
||||||
#Build figure attibutes
|
#Build figure attibutes
|
||||||
width == nothing || (attribs = "width=$width")
|
attribs = String[]
|
||||||
(attribs ≠ "" && height ≠ nothing ) && (attribs *= " ")
|
width == nothing || push!(attribs, "width=$width")
|
||||||
height == nothing || (attribs *= "height=$height")
|
height == nothing || push!(attribs, "height=$height")
|
||||||
attribs == "" || (attribs = "{$attribs}")
|
label == nothing || push!(attribs, "#fig:$label")
|
||||||
length(fignames) > 0 || (return "")
|
attribs = isempty(attribs) ? "" : "{" * join(attribs, " ") * "}"
|
||||||
|
|
||||||
if caption != nothing
|
if caption != nothing
|
||||||
result *= "![$caption]($(fignames[1]))$attribs\n"
|
result *= "![$caption]($(fignames[1]))$attribs\n"
|
||||||
|
|
|
@ -38,4 +38,4 @@ scatter!(rand(100),markersize=6,c=:orange)
|
||||||
![](figures/plotsjl_test_gr_3_1.png)\
|
![](figures/plotsjl_test_gr_3_1.png)\
|
||||||
|
|
||||||
|
|
||||||
![A random walk.](figures/plotsjl_test_gr_random_1.png)
|
![A random walk.](figures/plotsjl_test_gr_random_1.png){#fig:random}
|
||||||
|
|
|
@ -29,3 +29,5 @@ chunk.options[:out_width] = "100%"
|
||||||
@test Weave.formatfigures(chunk, Weave.multimarkdown) == "![Nice plot][figs/figures_plot1.png]\n\n[figs/figures_plot1.png]: figs/figures_plot1.png width=100%\n"
|
@test Weave.formatfigures(chunk, Weave.multimarkdown) == "![Nice plot][figs/figures_plot1.png]\n\n[figs/figures_plot1.png]: figs/figures_plot1.png width=100%\n"
|
||||||
@test Weave.formatfigures(chunk, Weave.adoc) == "image::figs/figures_plot1.png[width=100%,title=\"Nice plot\"]"
|
@test Weave.formatfigures(chunk, Weave.adoc) == "image::figs/figures_plot1.png[width=100%,title=\"Nice plot\"]"
|
||||||
|
|
||||||
|
chunk.options[:label] = "somefig"
|
||||||
|
@test Weave.formatfigures(chunk, Weave.pandoc) == "![Nice plot](figs/figures_plot1.png){width=100% #fig:somefig}\n"
|
||||||
|
|
Loading…
Reference in New Issue