Skip to main content

This is a port of knitr (http://yihui.name/knitr/) and rmarkdown (http://rmarkdown.rstudio.com/) to python.

To start with, you can run the example overview document. To convert to all defined output formats, run knitpy --to="all" -- examples\knitpy_overview.pymd. This will produce a html, docx and pdf output (if you have pdflatex in path). You can view a markdown rendered and a html rendered version of this file. It’s not yet as pretty as the knitr version…

For a description of the code format see http://rmarkdown.rstudio.com/ and replace {r <r style options>} by {python <python style options>} and of course use python code blocks…

It uses the IPython kernel infrastructure to execute code, so all kernels for IPython are (aem… can potentially be) supported.

What works:

  • code blocks and inline code

  • plots are shown inline

  • knitpy filename.pymd will convert filename filename.pymd to the defaul output format html.

  • output formats html, pdf and docx. Change with --to=<format>

  • --to=all will convert to all export formats specified in the yaml header

  • code chunk arguments eval, results (apart form “hold”), include and echo

  • errors in code chunks are shown in the document

  • uses the IPython display framework, so rich output for objects implementing _repr_html_() or _repr_markdown_(). Mimetypes not understood by the final output format are automatically converted via pandoc.

  • config files: generate an empty one with knitpy --init --profile-dir=.

  • using it from python (-> your app/ ipython notebook): import knitpy; knitpy.render(filename.pymd, output="html") will convert filename.pymd to filename.html. output=all will convert to all document types (as specified in the YAML header of the document). The call will return a list of converted documents.

  • debugging with `--debug, --kernel-debug=True, --output-debug=True

What does not work (=everything else :-) ):

  • most YAML headers are currently ignored

  • some advertised command-line options are ignored

  • most code chunk arguments (apart from the ones above) are ignored

  • probably lots of other stuff…

Todo

  • fix the above…

  • refactor the parsing, so that it is line based

  • errors make more sense, because it knows the line (“block starting at line….”)

  • add some traits for the default pdflatex/pandoc executeable, so they don’t have to be in path

  • the final output has to configure the “includeable” markup docs

  • html in html

  • latex in html?

  • …

  • more arguments for code blocks

  • more output formats? -> make output format configurable

  • more unit-/outputtests…

  • codeblocks + inline

  • yaml

  • errors

  • pandoc caller (via mocks?)

  • Documentation

  • what works? what is not supported?

  • differences to rmarkdown / knitr?

  • implement more kernel engines (R…) and make it possible to supply/change ones (for installed kernels for python2/3 or coda environments)

  • implement a nice default html template

  • Try https://github.com/timtylin/scholdoc-templates

  • implement “code tidying”

  • maybe use https://github.com/google/yapf?

  • use metadata in keep_md output (like rmarkdown does…

  • should output #<title>\n<author>\n<date> before the rest

  • remove the first yaml block, but keep everything else…

  • chunk caching

Metadata

Release files for knitpy 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for knitpy 0.1.1
File Size Uploaded
knitpy-0.1.1.zip 25.6 kB Details

Release files / knitpy-0.1.1.zip

Download URL knitpy-0.1.1.zip
Size 25.6 kB
Tags Source
SHA-256 checksum
How to use checksums
c4e7f99d1d827f87fe691c3f28dc674dedc52b2bd362b0d45b4a0b54cae4cb94
BLAKE2b-256 checksum
How to use checksums
03d59e5139a91ca35603b6a3d1767dece2f9b51535a764eb77b3dbef8c22c4e0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.1.1 This release

1 release file

0.1.0

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page