This package automatically runs a julia source file and converts it to, e.g., a pdf or html while capturing output such as figures and text.
We convert a source .jl
file to markdown using Literate.jl and then weaves this markdown file to, e.g., pdf or html, using Weave.jl. Write your code file as if you were using Literate.jl
This package exports a single function
literateweave(source, args...; kwargs...)
args
and kwargs
goes to weave(s, args...; kwargs...)
literateweave("myfile.jl", doctype="md2pdf", latex_cmd="lualatex")
literateweave("myfile.jl", weave=notebook)
page = literateweave("myfile.jl", doctype="md2html"); run(`sensible-browser $page`)
- Figures are captured by Weave. If you have multiple plot commands producing multiple plots, separate them by
#
, e.g.:
plot(...)
#
plot(...)
- The Juno cell-separator
##
is treated as an inline comment by Literate and does thus not split a cell in the output. - Inline latex math is supported using
$x y$
I created this package to solve the following problem:
Literate.jl allows me to write code as normal and insert normal comments, and then converting this code to markdown. Unfortunately, Literate does not run the code or capture output.
Weave.jl does run the code and capture the output, but requires you to write a .jmd
file which is much less convenient to work with compared to a normal julia source file, which is often what you start out with.
All credits goes to the creators of Literate.jl and Weave.jl. This package just glues them together.