macros for Jupyter Notebooks
Project description
JPConvert
JPConvert is a simple tool to split up Jupyter Notebooks based on macros and remove unnecessary metadata.
Installation
JPConvert does not need any libraries. It is probably a good idea to use nbstripout
with it though.
The preferred way to use JPConvert is in a virtual environment:
python -m venv venv
source venv/bin/activate
Use pip to download and install JPConvert:
pip install jpconvert
Usage
python -m jpconvert <input> [<output>] [<options>]
If no input file is specified, stdin
is used instead. If no output file is specified, stdout
is used instead.
Macros and Options
option | description |
---|---|
--practice / -p |
keep cells containing #jp-practice |
--teaching / -t |
keep cells containing #jp-teaching |
--solution / -s |
keep cells containing #jp-solution |
--remove-without-macros |
remove cells that do not contain any macro |
--keep-empty |
do not remove empty cells |
--no-strip-lines |
do not remove space or tabs from line endings |
--keep-trailing |
do not remove trailing lines |
--no-embed-images |
do not embed images in output file |
Multiple macros can be used per cell. Only code cells with the macro matching the output options are kept. Macros themselves are removed from the code cells.
The special macro #jp-toc
can be used to create a table of contents. Up to two conditionals can be added to control the table's depth.
Any cells that do not contain #jp-practice
are set readonly. If you want to protect these cells from writing as well, add #jp-readonly
or use #jp-practice-ro
.
Example
Image two code cells inside your notebook:
#jp-solution
a = a + 1
#jp-practice
a = ...
If you call JPConvert with the --practice
option, the first cell is removed and the second cell is kept:
a = ...
If you call JPConvert with the --solution
option, the first cell is kept and the second cell is removed:
a = a + 1
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for jpconvert-0.3.8-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 36c7a16e2ceb1ca25ac07d817c03a0e8be88af352b7644d656117ce3bb2e8552 |
|
MD5 | 2fcb676dcf1ae2ac89b91f9633e26156 |
|
BLAKE2b-256 | 19566d111e1ac8beb4ed1495c6664d919c3c07f6169bc304f789c4e1eacd2b5a |