2018-01-03 09:07:55 +01:00
|
|
|
using Weave
|
2018-07-23 12:37:25 +02:00
|
|
|
using Test
|
2018-01-03 09:07:55 +01:00
|
|
|
|
|
|
|
# Make a dummy codehunk with figure
|
|
|
|
chunk = Weave.CodeChunk("plot(x)", 1, 1, "", Dict())
|
|
|
|
options = merge(Weave.rcParams[:chunk_defaults], chunk.options)
|
|
|
|
merge!(chunk.options, options)
|
|
|
|
chunk.figures = ["figs/figures_plot1.png"]
|
|
|
|
|
|
|
|
@test Weave.formatfigures(chunk, Weave.md2tex) == "\\includegraphics{figs/figures_plot1.png}\n"
|
2019-08-25 09:39:03 +02:00
|
|
|
@test Weave.formatfigures(chunk, Weave.tex) == "\\includegraphics{figs/figures_plot1.png}\n"
|
|
|
|
@test Weave.formatfigures(chunk, Weave.texminted) == "\\includegraphics{figs/figures_plot1.png}\n"
|
2018-01-03 09:07:55 +01:00
|
|
|
@test Weave.formatfigures(chunk, Weave.pandoc) == "![](figs/figures_plot1.png)\\ \n\n"
|
|
|
|
@test Weave.formatfigures(chunk, Weave.github) == "![](figs/figures_plot1.png)\n"
|
|
|
|
@test Weave.formatfigures(chunk, Weave.hugo) == "{{< figure src=\"../figs/figures_plot1.png\" >}}"
|
|
|
|
@test Weave.formatfigures(chunk, Weave.multimarkdown) == "![][figs/figures_plot1.png]\n\n[figs/figures_plot1.png]: figs/figures_plot1.png \n"
|
|
|
|
@test Weave.formatfigures(chunk, Weave.md2html) == "<img src=\"figs/figures_plot1.png\" />\n"
|
|
|
|
|
2018-01-03 11:34:00 +01:00
|
|
|
chunk.options[:out_width] = "100%"
|
2018-08-14 11:32:51 +02:00
|
|
|
@test Weave.formatfigures(chunk, Weave.adoc) == "image::figs/figures_plot1.png[width=100%]\n"
|
|
|
|
@test Weave.formatfigures(chunk, Weave.rst) == ".. image:: figs/figures_plot1.png\n :width: 100%\n\n"
|
|
|
|
|
|
|
|
chunk.options[:fig_cap] = "Nice plot"
|
2019-08-25 19:19:31 +02:00
|
|
|
@test Weave.formatfigures(chunk, Weave.tex) == "\\begin{figure}[!h]\n\\center\n\\includegraphics[width=1.0\\linewidth]{figs/figures_plot1.png}\n\\caption{Nice plot}\n\\end{figure}\n"
|
2018-01-03 11:34:00 +01:00
|
|
|
@test Weave.formatfigures(chunk, Weave.pandoc) == "![Nice plot](figs/figures_plot1.png){width=100%}\n"
|
2019-08-25 19:19:31 +02:00
|
|
|
@test Weave.formatfigures(chunk, Weave.md2tex) == "\\begin{figure}[!h]\n\\center\n\\includegraphics[width=1.0\\linewidth]{figs/figures_plot1.png}\n\\caption{Nice plot}\n\\end{figure}\n"
|
2018-01-03 11:34:00 +01:00
|
|
|
@test Weave.formatfigures(chunk, Weave.md2html) == "<figure>\n<img src=\"figs/figures_plot1.png\" width=\"100%\" />\n<figcaption>Nice plot</figcaption>\n</figure>\n"
|
|
|
|
@test Weave.formatfigures(chunk, Weave.rst) == ".. figure:: figs/figures_plot1.png\n :width: 100%\n\n Nice plot\n\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\"]"
|
2018-01-03 09:07:55 +01:00
|
|
|
|
2018-07-27 09:22:30 +02:00
|
|
|
chunk.options[:label] = "somefig"
|
|
|
|
@test Weave.formatfigures(chunk, Weave.pandoc) == "![Nice plot](figs/figures_plot1.png){width=100% #fig:somefig}\n"
|
2019-08-25 19:19:31 +02:00
|
|
|
@test Weave.formatfigures(chunk, Weave.tex) == "\\begin{figure}[!h]\n\\center\n\\includegraphics[width=1.0\\linewidth]{figs/figures_plot1.png}\n\\caption{Nice plot}\n\\label{fig:somefig}\n\\end{figure}\n"
|
2018-07-27 09:42:14 +02:00
|
|
|
@test Weave.formatfigures(chunk, Weave.tex) == Weave.formatfigures(chunk, Weave.md2tex)
|
2019-08-25 10:25:57 +02:00
|
|
|
|
|
|
|
chunk.options[:label] = nothing
|
|
|
|
chunk.options[:fig_cap] = nothing
|
|
|
|
chunk.options[:fig_env] = "center"
|
|
|
|
chunk.options[:fig_pos] = ""
|
2019-08-25 19:19:31 +02:00
|
|
|
@test Weave.formatfigures(chunk, Weave.tex) == "\\begin{center}\n\\includegraphics[width=1.0\\linewidth]{figs/figures_plot1.png}\n\\end{center}\n"
|
|
|
|
|
|
|
|
chunk.options[:out_width] = "50%"
|
|
|
|
chunk.options[:out_height] = "75 %"
|
|
|
|
@test Weave.formatfigures(chunk, Weave.tex) == "\\begin{center}\n\\includegraphics[width=0.5\\linewidth,height=0.75\\paperheight]{figs/figures_plot1.png}\n\\end{center}\n"
|
|
|
|
|
|
|
|
chunk.options[:out_width] = "A%"
|
|
|
|
chunk.options[:out_height] = "0.5\\textwidth"
|
|
|
|
@test Weave.formatfigures(chunk, Weave.tex) == "\\begin{center}\n\\includegraphics[width=A%,height=0.5\\textwidth]{figs/figures_plot1.png}\n\\end{center}\n"
|
|
|
|
|