Working with Jupyter notebooks
Weaving from Jupyter notebooks
Weave supports using Jupyter Notebooks as input format. This means you can weave
notebooks to any supported formats; by default, it will be weaved to HTML.
weave("notebook.ipynb") # will be weaved to HTML
You can't use chunk options with notebooks.
Output to Jupyter notebooks
As of Weave 0.5.1. there is new notebook
method to convert Weave documents to Jupyter notebooks using nbconvert.
Weave.notebook
— Functionnotebook(source::AbstractString; kwargs...)
Convert Weave document source
to Jupyter Notebook and execute the code using nbconvert
. Ignores all chunk options.
Keyword options
out_path::Union{Symbol,AbstractString} = :pwd
: Path where the output is generated can be either of::doc
: Path of the source document:pwd
: Julia working directory (default)"somepath"
:String
of output directory e.g."~/outdir"
, or of filename e.g."~/outdir/outfile.tex"
timeout = -1
: nbconvert cell timeout in seconds. Defaults to-1
(no timeout)nbconvert_options::AbstractString = ""
:String
of additional options to pass to nbconvert, such as"--allow-errors"
jupyter_path::AbstractString = "jupyter"
: Path/command for the Jupyter you want to use. Defaults to"jupyter"
, which runs whatever is linked/alias to that
In order to just convert Weave document to Jupyter Notebook, use convert_doc
instead.
You can specify jupyter
used to execute the notebook with the jupyter_path
keyword argument (this defaults to the "jupyter"
, i.e. whatever you have linked to that location).
Instead, you might want to use the convert_doc
method below and run the code in Jupyter.
Converting between formats
You can convert between all supported input formats using the convert_doc
function.
To convert from script to notebook:
convert_doc("examples/FIR_design.jl", "FIR_design.ipynb")
and from notebook to Markdown use:
convert_doc("FIR_design.ipynb", "FIR_design.jmd")
Weave.convert_doc
— Functionconvert_doc(infile::AbstractString, outfile::AbstractString; outformat::Union{Nothing,AbstractString} = nothing)
Convert Weave documents between different formats
infile
: Path of the input documentoutfile
: Path of the output documentoutformat = nothing
: Output document format (optional). By default (i.e. givennothing
) Weave will try to automatically detect it from theoutfile
's extension. You can also specify either of"script"
,"markdown"
,"notebook"
, or"noweb"