Skip to content
/ j2o Public

Python script for converting from Jupyter to Org file format without any dependencies.

License

Notifications You must be signed in to change notification settings

Anoncheg1/j2o

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

43 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Table of Contents

  1. j2o

  2. Command line usage

  3. How this works

  4. Info: Other useful projects

  5. Info: Format of ipynb

  6. features

    badge badge

j2o

Converter from Jupyter to Org file format without any dependencies.

Without this package your only alternative is to use nbconver or pandoc with 164 dependencies just to be able to convert simple JSON format.

TODO: make reverse convrter.

https://pypi.org/project/j2o/

Command line usage

usage: j2o myfile.ipynb [-w] [-j myfile.ipynb] [-o myfile.org]

Convert a Jupyter notebook to Org file (Emacs) and vice versa

positional arguments:
  jupfile_              Jupyter file

options:
  -h, --help            show this help message and exit
  -j JUPFILE, --jupfile JUPFILE
                        Jupyter file
  -o ORGFILE, --orgfile ORGFILE
                        Target filename of Org file. If not specified, it will
                        use the filename of the Jupyter file and append .ipynb
  -w, --overwrite       Flag whether to overwrite existing target file.

For Linux add this line to ~/.bashrc

  export PATH=$PATH:/home/youruser/.local/bin

How this works

  1. Loops through "cells".
  2. Extract "source"
  3. add Org header and tail around source ("#+begin_src python …", "#+end_src")

Info: Other useful projects

Info: Format of ipynb

JSON

{
  cells: [
    cell_type: "code/markdown",
    source: ["\n","\n",""],
    outputs: [{
      text: ["\n", "\n"],
      data: {
        image/png: "base64....",
        text/plain: "image description"}
      }
    ]
  ],
  metadata: {
    kernelspec: {
      language: "python"
    }
  }
}

features

  • in markdown cells conversion: source blocks, ‘#’ to ‘*’.
  • code cells: images
  • Tested for nbformat: 4.2.

About

Python script for converting from Jupyter to Org file format without any dependencies.

Topics

Resources

License

Stars

Watchers

Forks