{ "info": { "author": "Peter Zagubisalo", "author_email": "peter.zagubisalo@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Intended Audience :: Developers", "Intended Audience :: Science/Research", "License :: OSI Approved :: GNU General Public License v2 or later (GPLv2+)", "Operating System :: OS Independent", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.6", "Topic :: Scientific/Engineering :: Information Analysis", "Topic :: Software Development :: Build Tools" ], "description": "# Knitty\n\n[![Build Status](https://travis-ci.org/kiwi0fruit/knitty.svg?branch=master)](https://travis-ci.org/kiwi0fruit/knitty)\n\nKnitty is a Pandoc filter and [Atom/Hydrogen](https://atom.io/packages/hydrogen)-friendly reproducible report generation tool via Jupyter, Pandoc and Markdown (fork of the [Stitch](https://github.com/kiwi0fruit/knitty/blob/master/docs/stitch.md) that is a [Knitr](http://yihui.name/knitr/)-[RMarkdown](http://rmarkdown.rstudio.com)-like library in Python). Insert python code (or other Jupyter kernel code) to the Markdown document or **write in plain Python/Julia/R/any-kernel-lang** with block-commented Markdown and have code's results in the Pandoc output document.\n\nSee [**Knitty documentation**](https://github.com/kiwi0fruit/knitty/blob/master/docs/knitty.md). [Reddit introduction post](https://github.com/kiwi0fruit/knitty/blob/master/docs/reddit.md).\n\nYou can use:\n\n* [Pandoc >=2.6](https://pandoc.org/MANUAL.html#creating-jupyter-notebooks-with-pandoc) to export to .ipynb notebooks (optionally: [install Pandoc in Python](https://github.com/kiwi0fruit/py-pandoc)),\n* [ipynb-py-converter](https://github.com/kiwi0fruit/ipynb-py-converter) to convert .ipynb to .py to use with Knitty.\n\n\n## Install\n\nInstall as part of [Pandoctools](https://github.com/kiwi0fruit/pandoctools) - convenient interface and works out of the box.\n\nNeeds Python 3.6+ but you can have other versions via Jupyter kernels as Knitty can use any installed kernel.\n\nVia conda:\n```bash\nconda install -c defaults -c conda-forge knitty\n```\n\nVia pip:\n\n```bash\npip install knitty\n```\n\n\n#### Jupyter kernels\n\nSee important additional info on how to [**install Jupyter kernels in Conda environments**](https://github.com/kiwi0fruit/pandoctools/blob/master/docs/tips.md). \nSee main info on how to install Jupyter kernels in the Atom/Hydrogen documentstion (for example).\n\n\n#### Atom/Hydrogen\n\nKnitty is much better to be used with something like Atom/Hydrogen. See [Best Python/Jupyter/PyCharm experience + report generation with Pandoc filters](https://github.com/kiwi0fruit/pandoctools/blob/master/docs/best_python_jupyter_pycharm_experience.md) for more details. You can also try **VS Code** interface to Jupyter from [vscode-python](https://github.com/Microsoft/vscode-python) instead 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.\n\n\n#### Optional install\n\nModified version of [Notedown](https://github.com/kiwi0fruit/knitty/blob/master/docs/notedown.md) by Aaron O'Leary is included in Knitty as `knotedown`.\nIf you would like to use `knotedown` to import from R Markdown you need installed `knitr`:\n\n```bash\nconda install r-knitr r-reticulate\n```\n\n\n## Examples\n\nYou can see examples of using Knitty [**here**](https://github.com/kiwi0fruit/pandoctools/tree/master/examples). It's used together with some other CLI tools via Pandoctools there but cells management and options are from Knitty.\n\nAlso see [example from Knitty documentstion](https://github.com/kiwi0fruit/knitty/blob/master/docs/knitty.md#17-example-files-in-code-cells-mode).\n\n\n## Usage\n\nYou either can use Knitty as a standard Pandoc filter:\n\n```bash\ncat doc.md | pre-knitty | pandoc --filter knitty -o doc.ipynb\n```\nand 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.\n\nOr 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 only **save and tweak** shell script for this. There is a Bash example below. If on Windows I strongly recommend to install [Git together with Bash](https://git-scm.com/downloads).\n\n`./metadata.yaml`:\n```yaml\n---\nkernels-map:\n r: ir\n py: python\nstyles-map:\n py: python\ncomments-map:\n py: ['#', \"r'''\", \"'''\", \"'''\", \"'''\", \"r\\\"\\\"\\\"\", \"\\\"\\\"\\\"\", \"\\\"\\\"\\\"\", \"\\\"\\\"\\\"\"]\n js: [\"//\", \"/*\", \"*/\"]\n ts: [\"//\", \"/*\", \"*/\"]\n r: ['#', \"'\", \"'\", \"\\\"\", \"\\\"\"]\n...\n```\n\n`./knitty`:\n```bash\n#!/bin/bash\nhere=\"$(cd \"$(dirname \"${BASH_SOURCE[0]}\")\" && pwd)\"\nexport LANG=C.UTF-8\nexport PYTHONIOENCODING=utf-8\n\nin=\"$1\"\nyml=\"$here/metadata.yaml\"\nR=(-f markdown)\nW=(-t html --standalone --self-contained)\n\nt=\"$(pandoc-filter-arg \"${W[@]}\")\"\ncat \"$in\" |\npre-knitty \"$in\" --yaml \"$yml\" |\ncat - <(printf \"\\n\\n\") \"$yml\" |\npandoc \"${R[@]}\" -t json |\nknitty $t \"$in\" \"${R[@]}\" \"${W[@]}\" |\npandoc -f json \"${W[@]}\" -o \"$in.html\"\n```\n(`$t` is an arg that Pandoc passes to it's filters).\n\nThen use it like `./knitty /path/to/doc.py` that would save `/path/to/doc.py.html`.\n\n\n#### Batch\n\nAnd if you don't like Bash there is a Windows batch example below (see [setvar](https://github.com/kiwi0fruit/knitty/blob/master/examples/setvar.bat)):\n```bat\nchcp 65001 > NUL\nset PYTHONIOENCODING=utf-8\n\nset in=doc.md\nset R=-f markdown\nset W=-t html --standalone --self-contained\n\npandoc-filter-arg %W% | call .\\setvar t\ntype \"%in%\" | pre-knitty | ^\npandoc %R% -t json | ^\nknitty %t% \"%in%\" %R% %W% | ^\npandoc -f json %W% -o \"%in%.html\"\n```\n\n\n#### To ipynb\n\nBefore 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 Pandoc [**here**](https://pandoc.org/MANUAL.html#creating-jupyter-notebooks-with-pandoc) (optionally: [install Pandoc in Python](https://github.com/kiwi0fruit/py-pandoc)). I also recommend using `knitty.self_contained_raw_html_img` Panflute filter (see [here](https://github.com/kiwi0fruit/knitty/blob/master/docs/knitty.md#self_contained_raw_html_img-panflute-filter)) to fix Pandoc attachments created when to .ipynb conversion.\n\n\n#### Using with pandoc-crossref\n\nWorth mentioning that you can use Knitty together with [pandoc-crossref](https://github.com/lierdakil/pandoc-crossref) (see [install instructions](https://github.com/kiwi0fruit/py-pandoc-crossref)). You may also need to tune output format in Pandoc and execute the notebook. See example without Knitty:\n\n```bash\npandoc doc.md --filter pandoc-crossref --to \"ipynb-bracketed_spans-fenced_divs\\\n-link_attributes-simple_tables-multiline_tables-grid_tables-pipe_tables\\\n-fenced_code_attributes-markdown_in_html_blocks-table_captions-smart\" | \\\njupyter nbconvert --to notebook --execute --stdin --stdout > doc.ipynb\n```", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/kiwi0fruit/knitty", "keywords": "atom hydrogen jupyter pandoc markdown report", "license": "GPLv2+", "maintainer": "", "maintainer_email": "", "name": "knitty", "package_url": "https://pypi.org/project/knitty/", "platform": "", "project_url": "https://pypi.org/project/knitty/", "project_urls": { "Homepage": "https://github.com/kiwi0fruit/knitty" }, "release_url": "https://pypi.org/project/knitty/0.5.6/", "requires_dist": null, "requires_python": ">=3.6", "summary": "Reproducible report generation tool via Jupyter, Pandoc and Markdown. Contains fork of the Notedown.", "version": "0.5.6" }, "last_serial": 4935217, "releases": { "0.4.19": [ { "comment_text": "", "digests": { "md5": "2008db105412f132ccd12bf1c2d59dbf", "sha256": "4c8e78ef3a07f68b35aa73571e3110393a629533c5c3ded765230fff62baff0b" }, "downloads": -1, "filename": "knitty-0.4.19.tar.gz", "has_sig": false, "md5_digest": "2008db105412f132ccd12bf1c2d59dbf", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6", "size": 65429, "upload_time": "2019-01-22T07:36:07", "url": "https://files.pythonhosted.org/packages/bf/48/2e467d2bd2f0526f3470072d4eaac054a19c4394537209f9642283e02ac0/knitty-0.4.19.tar.gz" } ], "0.4.20": [ { "comment_text": "", "digests": { "md5": "cd951bfbfe0e39bf33cde950cdce1c1e", "sha256": "6dbd3ae411f987498bc041fe633bf83a81a721ae3dd91d5a571a5b5af530d251" }, "downloads": -1, "filename": "knitty-0.4.20.tar.gz", "has_sig": false, "md5_digest": "cd951bfbfe0e39bf33cde950cdce1c1e", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6", "size": 65617, "upload_time": "2019-01-23T06:55:43", "url": "https://files.pythonhosted.org/packages/24/c0/242e2872cdcd511ac34f0831d8c0420fb2a67b8ade4ad8625649a1138e4e/knitty-0.4.20.tar.gz" } ], "0.5.0": [ { "comment_text": "", "digests": { "md5": "36dc99a1f7c11705384df3f92a02dc02", "sha256": "bb3d48e9dbdb742ca7747a070dc5e0daaa3c8815550ab808a0587fb72d79ee15" }, "downloads": -1, "filename": "knitty-0.5.0.tar.gz", "has_sig": false, "md5_digest": "36dc99a1f7c11705384df3f92a02dc02", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6", "size": 57717, "upload_time": "2019-02-18T11:08:49", "url": "https://files.pythonhosted.org/packages/ab/a1/377ba91d55bd3195f3d9dcc81e63a4617af9f183858825de1159051cc8e3/knitty-0.5.0.tar.gz" } ], "0.5.3": [ { "comment_text": "", "digests": { "md5": "ab37c05c930bd64e55f1111df869ced8", "sha256": "9f72d70908f9872f1b08559ce8776724020c373aaa150332a1421e4352be5d38" }, "downloads": -1, "filename": "knitty-0.5.3.tar.gz", "has_sig": false, "md5_digest": "ab37c05c930bd64e55f1111df869ced8", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6", "size": 57268, "upload_time": "2019-03-01T09:06:23", "url": "https://files.pythonhosted.org/packages/f2/71/8c0217b9a206690e69fd7e37a568144493b04ab56bc3c156a1541d9c2644/knitty-0.5.3.tar.gz" } ], "0.5.4": [ { "comment_text": "", "digests": { "md5": "615d6e2cea0203370773e6275806a0a2", "sha256": "128dfeead967f0a636b84c791b6cd2c6c48b277d09264c5b722a9b1f631a4d99" }, "downloads": -1, "filename": "knitty-0.5.4.tar.gz", "has_sig": false, "md5_digest": "615d6e2cea0203370773e6275806a0a2", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6", "size": 59191, "upload_time": "2019-03-12T15:56:02", "url": "https://files.pythonhosted.org/packages/e1/f5/a7302c2949bdee88680f6b8c669eba4eb24c349a411b3f76dcd43c55d4e8/knitty-0.5.4.tar.gz" } ], "0.5.5": [ { "comment_text": "", "digests": { "md5": "ba5ad09ca57229b99d7c014ddc287949", "sha256": "575db25655298a4bd2dd2ee773c93aa077abe577772558eb144ead050bd7fab6" }, "downloads": -1, "filename": "knitty-0.5.5.tar.gz", "has_sig": false, "md5_digest": "ba5ad09ca57229b99d7c014ddc287949", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6", "size": 59419, "upload_time": "2019-03-13T07:08:11", "url": "https://files.pythonhosted.org/packages/80/ac/e61eaceaae207b8c90eaaf12c43e93bdd3256086d8bca83bd8435bfe1196/knitty-0.5.5.tar.gz" } ], "0.5.6": [ { "comment_text": "", "digests": { "md5": "5a9e5a20908aaa54db08c3b8fea9ce3f", "sha256": "36018ebd9d37fe18bb4656cf744aa82888c242c217a5fa8be39c09fe1ddcd993" }, "downloads": -1, "filename": "knitty-0.5.6.tar.gz", "has_sig": false, "md5_digest": "5a9e5a20908aaa54db08c3b8fea9ce3f", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6", "size": 59259, "upload_time": "2019-03-13T15:48:53", "url": "https://files.pythonhosted.org/packages/54/a6/a6541f089550b5fc2f19ddae88daa3983af4c945da3636dae918b611d6ef/knitty-0.5.6.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "5a9e5a20908aaa54db08c3b8fea9ce3f", "sha256": "36018ebd9d37fe18bb4656cf744aa82888c242c217a5fa8be39c09fe1ddcd993" }, "downloads": -1, "filename": "knitty-0.5.6.tar.gz", "has_sig": false, "md5_digest": "5a9e5a20908aaa54db08c3b8fea9ce3f", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6", "size": 59259, "upload_time": "2019-03-13T15:48:53", "url": "https://files.pythonhosted.org/packages/54/a6/a6541f089550b5fc2f19ddae88daa3983af4c945da3636dae918b611d6ef/knitty-0.5.6.tar.gz" } ] }