TXT2PYNB
Converts text script to iPython notebook
Details
Installs
- Total 382
- Win 260
- Mac 83
- Linux 39
Dec 26 | Dec 25 | Dec 24 | Dec 23 | Dec 22 | Dec 21 | Dec 20 | Dec 19 | Dec 18 | Dec 17 | Dec 16 | Dec 15 | Dec 14 | Dec 13 | Dec 12 | Dec 11 | Dec 10 | Dec 9 | Dec 8 | Dec 7 | Dec 6 | Dec 5 | Dec 4 | Dec 3 | Dec 2 | Dec 1 | Nov 30 | Nov 29 | Nov 28 | Nov 27 | Nov 26 | Nov 25 | Nov 24 | Nov 23 | Nov 22 | Nov 21 | Nov 20 | Nov 19 | Nov 18 | Nov 17 | Nov 16 | Nov 15 | Nov 14 | Nov 13 | Nov 12 | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Windows | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
Mac | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
Linux | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
Readme
- Source
- raw.githubusercontent.com
TXT2PYNB
TXT2PYNB is a Sublime Text package that takes a Python (or Julia) file with inline block-commented markdown blocks and turns it into an iPython (or iJulia) notebook (.ipynb
). Please view the “Tags” section below or the Examples
folder for examples of scripts. The package will output a notebook of the same name as the script in the same directory where the script is saved. (e.g. my_script.py
will output my_script.ipynb
in the same directory)
Download
This package can be dowloaded from package control in Sublime Text. Search for “TXT2PYNB” after installing package control and searching for it within the 'install packages' option.
Building Notebook
Once installed in Sublime Text, TXT2PYNB can be called as a build-system by pressing C + b
where C
is the command
key on Apple computers and ctrl
on others. For some users, the TXT2PYNB build system will be called by default with .py
or .jl
scripts, but others might need to select it from Tools->Build System->TXT2PYNB
.
Alternatively, TXT2PYNB can be searched and called using the Command Palette (cmd + shift + p
). This is particularly useful if a user regularly uses other build systems for Python or Julia scripts. The default call to the TXT2PYNB build system can be turned off by removing the TXT2PYNB.sublime-build
file in this package's folder.
Script Execution (For use outside of Sublime Text)
Example execution of code for a python script, Julia works similarly. The command-line-executable script txt2pynb.py is in the txt2pynb
folder.
python /path/to/txt2pynb.py /path/to/example_script.py
Tags
The beginning and ending tags for code and markdown follow a typical html-like format. It is recommended that the entire markdown blocks be commented out and also the code tags be commented out (as below) in order to preserve the script's capability to be ran as a Python file.
#<code>
# This is a comment inside of a code block
#</code>
'''<md>
This is markdown!
</md>'''
Space Delimiting
Having no code or markdown tags will result in the script being parsed with double space delimiting. Please view example number 2 to see this demonstrated. The markdown blocks must be in block comment format such as '''markdown''' (or “”“markdown”“” for Julia) in order to be correctly parsed. Also, markdown blocks can be squished on top of code blocks to allow for a markdown and code block in one double space-delimited block, as seen in Example_2 in the Examples
folder.
Examples
View Examples
folder for sample code and output.
Common Issues
C+b
doesn't output anything.- If a build system is already assigned by default for
.py
or.jl
files, it may be necessary to manually change the build system while the script is open by going toTools > Build System
and selectingTXT2PYNB
. Likewise, if a different build system is desired for an open.py
or.jl
file, switch it back using the same procedure.
- If a build system is already assigned by default for
To Do
- Add ability to 'pull back' code from edited notebook
- iPython 3+ compatability (output version 4 .ipynb)