Package: knitty
KnittyKnitty is a Pandoc filter andAtom/Hydrogen-friendly reproducible report generation tool via Jupyter, Pandoc and Markdown (fork of theStitchthat is aKnitr-RMarkdown-like library in Python). Insert python code (or other Jupyter kernel code) to the Markdown document orwrite in plain Python/Julia/R/any-kernel-langwith block-commented Markdown and have code's results in the Pandoc output document.SeeKnitty documentation.Reddit introduction post.You can use:Pandoc >=2.6to export to .ipynb notebooks (optionally:install Pandoc in Python),ipynb-py-converterto convert .ipynb to .py to use with Knitty.InstallInstall as part ofPandoctools- 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:condainstall-cdefaults-cconda-forgeknittyVia pip:pipinstallknittyJupyter kernelsSee important additional info on how toinstall Jupyter kernels in Conda environments.See main info on how to install Jupyter kernels in the Atom/Hydrogen documentstion (for example).Atom/HydrogenKnitty is much better to be used with something like Atom/Hydrogen. SeeBest Python/Jupyter/PyCharm experience + report generation with Pandoc filtersfor more details. You can also tryVS Codeinterface to Jupyter fromvscode-pythoninstead of Atom/Hydrogen. I highly recommend to try to think about ipynb as merely an output format like pdf (albeit dynamic and rich) instead of main format or intermediate format.ExamplesYou can see examples of using Knittyhere. It's used together with some other CLI tools via Pandoctools there but cells management and options are from Knitty.Also seeexample from Knitty documentstion.UsageYou either can use Knitty as a standard Pandoc filter:catdoc.md|pre-knitty|pandoc--filterknitty-odoc.ipynband specify some subset of Knitty options in metadata:self_contained: True,standalone: True. But this way you cannot switch from Markdown to RST for example.Or you can set all Knitty options (including those in metadata) by using it as a Pandoc filter with multiple arguments. Knitty is intended to be used in Pandoctools bash profiles (so it's CLI is split-up) but you can easily use Knitty independently. You should onlysave and tweakshell script for this. There is a Bash example below. If on Windows I strongly recommend to installGit together with Bash../metadata.yaml:---kernels-map:r:irpy:pythonstyles-map:py:pythoncomments-map:py:['#',"r'''","'''","'''","'''","r\"\"\"","\"\"\"","\"\"\"","\"\"\""]js:["//","/*","*/"]ts:["//","/*","*/"]r:['#',"'","'","\"","\""]..../knitty:#!/bin/bashhere="$(cd"$(dirname"${BASH_SOURCE[0]}")"&&pwd)"exportLANG=C.UTF-8exportPYTHONIOENCODING=utf-8in="$1"yml="$here/metadata.yaml"R=(-fmarkdown)W=(-thtml--standalone--self-contained)t="$(pandoc-filter-arg"${W[@]}")"cat"$in"|pre-knitty"$in"--yaml"$yml"|cat"$yml"<(printf"\n\n")-|pandoc"${R[@]}"-tjson|knitty$t"$in""${R[@]}""${W[@]}"|pandoc-fjson"${W[@]}"-o"$in.html"($tis an arg that Pandoc passes to it's filters).Then use it like./knitty /path/to/doc.pythat would save/path/to/doc.py.html.BatchAnd if you don't like Bash there is a Windows batch example below (seesetvar):chcp 65001>NULsetPYTHONIOENCODING=utf-8setin=doc.mdsetR=-f markdownsetW=-t html --standalone --self-contained

pandoc-filter-arg%W%|call.\setvar ttype"%in%"|pre-knitty|^pandoc%R%-t json|^knitty%t%"%in%"%R%%W%|^pandoc -f json%W%-o"%in%.html"To ipynbBefore v0.5.0 Knitty supported conversion to .ipynb via Notedown but since v0.5.0 it is adapted to be used with Pandoc >=2.6. You can learn how to convert to ipynb via Pandochere(optionally:install Pandoc in Python). I also recommend usingknitty.self_contained_raw_html_imgPanflute filter (seehere) to fix Pandoc attachments created when to .ipynb conversion.Using with pandoc-crossrefWorth mentioning that you can use Knitty together withpandoc-crossref(seeinstall instructions). You may also need to tune output format in Pandoc and execute the notebook. See example without Knitty:pandocdoc.md--filterpandoc-crossref--to"ipynb-bracketed_spans-fenced_divs\-link_attributes-simple_tables-multiline_tables-grid_tables-pipe_tables\-fenced_code_attributes-markdown_in_html_blocks-table_captions-smart"|\jupyternbconvert--tonotebook--execute--stdin--stdout>doc.ipynb