Inrterface wrapper for Stitch/Knotr: reproducible report generation tool via Jupyter, Pandoc and Markdown. Export to Jupyter notebook via Notedown.
Project description
Knitty
Knitty is a Pandoc filter and Atom/Hydrogen friendly inrterface wrapper for Stitch/Knotr: reproducible report generation tool via Jupyter, Pandoc and Markdown. Insert python code (or other Jupyter kernel code) to the Markdown document and have code's results in the output document. Exports to Jupyter notebook via Notedown.
See Knitty documentation.
You can use vscode-ipynb-py-converter to convert .ipynb to .py to use with Knitty.
Install
Install as part of Pandoctools - convenient interface and works out of the box.
Needs Python 3.6+ but you can have other versions via Jupyter kernels as Knitty can use any installed kernel.
Via conda:
conda install -c defaults -c conda-forge knitty
Via pip:
pip install knitty
Optional install
If you would like to use knotedown
to import from R Markdown you need installed knitr
:
conda install r-knitr r-reticulate
Usage
Unix:
export PYTHONIOENCODING=utf-8
input_file="doc.md"
metadata="metadata.yml"
reader_args=(-f markdown)
writer_args=(-t html --standalone --self-contained)
cat "${input_file}" | \
pre-knitty "${input_file}" --yaml "$metadata" | \
pandoc "${reader_args[@]}" -t json | \
knitty "${input_file}" "${reader_args[@]}" "${writer_args[@]}" | \
pandoc -f json "${writer_args[@]}" -o "${input_file}.html"
Windows:
chcp 65001 > NUL
set PYTHONIOENCODING=utf-8
set input_file=doc.md
set metadata=metadata.yml
set reader_args=-f markdown
set writer_args=-t html --standalone --self-contained
type "%input_file%" | ^
pre-knitty "%input_file%" --yaml "%metadata%" | ^
pandoc %reader_args% -t json | ^
knitty "%input_file%" %reader_args% %writer_args% | ^
pandoc -f json %writer_args% -o "%input_file%.html"
Jupyter kernel specification in metadata section:
---
kernelspec:
display_name: R
language: R
name: ir
...
Export to Jupyter notebook with cross-references (using pandoc-crossref: download) and execute it:
export PYTHONIOENCODING=utf-8
input_file="doc.md"
metadata="metadata.yml"
reader_args=(-f markdown)
jupymd="markdown-bracketed_spans-fenced_divs-link_attributes-simple_tables\
-multiline_tables-grid_tables-pipe_tables-fenced_code_attributes\
-markdown_in_html_blocks-table_captions-smart"
writer_args=(-t "$jupymd" --standalone --self-contained --filter pandoc-crossref)
cat "${input_file}" | \
pre-knitty "${input_file}" --yaml "$metadata" | \
pandoc "${reader_args[@]}" -t json | \
knitty "${input_file}" "${reader_args[@]}" "${writer_args[@]}" --to-ipynb | \
pandoc -f json "${writer_args}" | \
post-knitty --to-ipynb | \
jupyter nbconvert --to notebook --execute --stdin --stdout > \
"${input_file}.ipynb"
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.