notedown 1.3.1

Convert markdown to IPython notebook.

Homepage: http://github.com/aaren/notedown

Platform: Pypi

Language: Python

License: BSD-3-Clause-Clear

Repository: https://github.com/aaren/notedown

View on registry: https://pypi.python.org/pypi/notedown/


Now supporting IPython 3!

Convert IPython Notebooks to markdown (and back)

notedown is a simple tool to create IPython notebooks from markdown (and r-markdown).

notedown separates your markdown into code and not code. Code blocks (fenced or indented) go into input cells, everything else goes into markdown cells.

Usage:

notedown input.md > output.ipynb

Installation:

pip install notedown

or the latest on github:

pip install https://github.com/aaren/notedown/tarball/master

Conversion to markdown

Convert a notebook into markdown, stripping all outputs:

notedown input.ipynb --to markdown --strip > output.md

Convert a notebook into markdown, with output JSON intact:

notedown input.ipynb --to markdown > output_with_outputs.md

The outputs are placed as JSON in a code-block immediately after the corresponding input code-block. notedown understands this convention as well, so it is possible to convert this markdown-with-json back into a notebook.

This means it is possible to edit markdown, convert to notebook, play around a bit and convert back to markdown.

NB: currently, notebook and cell metadata is not preserved in the conversion.

Strip the output cells from markdown:

notedown with_output_cells.md --to markdown --strip > no_output_cells.md

Running an IPython Notebook

notedown notebook.md --run > executed_notebook.ipynb

R-markdown

You can use notedown to convert r-markdown as well. We just need to tell notedown to use knitr to convert the r-markdown. This requires that you have R installed with knitr.

Convert r-markdown into markdown:

notedown input.Rmd --to markdown --knit > output.md

Convert r-markdown into an IPython notebook:

notedown input.Rmd --knit > output.ipynb
  • --rmagic will add %load_ext rpy2.ipython at the start of the notebook, allowing you to execute code cells using the rmagic extension (requires rpy2). notedown does the appropriate %R cell magic automatically.

Magic

Fenced code blocks annotated with a language other than python are read into cells using IPython's %% cell magic.

You can disable this with --nomagic.

  • --pre lets you add arbitrary code to the start of the notebook. e.g. notedown file.md --pre '%matplotlib inline' 'import numpy as np'

How do I put a literal code block in my markdown?

By using the --match argument. notedown defaults to converting all code-blocks into code-cells. This behaviour can be changed by giving a different argument to --match:

  • --match=all: convert all code blocks (the default)
  • --match=fenced: only convert fenced code blocks
  • --match=language: only convert fenced code blocks with 'language' as the syntax specifier.
  • --match=strict: only convert code blocks with Pandoc style attributes containing 'python' and 'input' as classes. i.e. code blocks must look like

     ```{.python .input}
     code
     ```
    

This isn't very interactive!

You can get an interactive ipython session in vim by using vim-ipython, which allows you to connect to a running ipython kernel. You can send code from vim to ipython and get code completion from the running kernel. Try it!

Where's my syntax highlighting?!

Try using either vim-markdown or vim-pandoc. Both are clever enough to highlight code in markdown.

Rendering outputs in markdown

This is experimental!

Convert a notebook into markdown, rendering cell outputs as native markdown elements:

notedown input.ipynb --render

This means that e.g. png outputs become ![](data-uri) images and that text is placed in the document.

Of course, you can use this in conjuntion with runipy to produce markdown-with-code-and-figures from markdown-with-code:

notedown input.md --run --render > output.md

Not a notebook in sight!

The --render flag forces the output format to markdown.

TODO

  • IPython 3 support
  • Allow kernel specification
веселые картинки развлекательные гифки интресные факты смешные видео смешные истории из соцсетей

GitHub Repository

aaren/notedown aaren/notedown

convert markdown to an IPython notebook

Language: Python

Created: February 17, 2014 17:28

Last updated: March 25, 2015 00:14

Last pushed: March 25, 2015 00:14

Size: 810 KB

Stars: 52

Forks: 6

Watchers: 6

Open issues: 3

Top Contributors

Aaron O'Leary

Releases

  • 1.3.1 - March 25, 2015 00:06
  • 1.3.0 - March 24, 2015 23:53
  • 1.2.10 - March 13, 2015 08:19
  • 1.2.9 - March 04, 2015 14:10
  • 1.2.8 - February 24, 2015 18:33
  • 1.2.7 - February 24, 2015 18:08
  • 1.2.6 - February 24, 2015 17:19
  • 1.2.5 - October 16, 2014 12:34
  • 1.2.4-dev - October 16, 2014 12:32
  • 1.2.3-dev - October 16, 2014 12:29
See all 17 releases

Related Projects

bookmarkd 0.1
Convert between IPython notebooks and markdown
Pypi - Other - Published 4 months ago
brythonmagic 0.1.1
Magics to use brython in IPython notebook.
Pypi - Python - MIT - Updated 7 days ago - 21 stars
callipy 0.3
Calling IPython notebooks with arguments
Pypi - Python - Other - Published 5 months ago
imolecule 0.1.4
View molecules in the IPython notebook.
Pypi - HTML - MIT - Updated 4 days ago - 18 stars
ipnb 0.1.0
IPython Notebook code reuse
Pypi - Python - Other - Published 9 months ago - 6 stars
веселые картинки развлекательные гифки интресные факты смешные видео смешные истории из соцсетей