Skip to content

Automatic convertion from .jl file to pdf/html using Literate.jl -> Weave.jl

Notifications You must be signed in to change notification settings

baggepinnen/LiterateWeave.jl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LiterateWeave.jl

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...)

Examplea

literateweave("myfile.jl", doctype="md2pdf", latex_cmd="lualatex")
literateweave("myfile.jl", weave=notebook)
page = literateweave("myfile.jl", doctype="md2html"); run(`sensible-browser $page`)

Notes

  • 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$

Why a package

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.

Credits

All credits goes to the creators of Literate.jl and Weave.jl. This package just glues them together.

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •