With this tool, one can define pieces of a notebook that belong to teachers and should not be exposed to students.
Project description
nbprune
typical use case is, a teacher writes a notebook, with solution(s) to a problem that students must solve
so this means 2 versions, one for the teacher(s) with the solutions, and one for the students
this tool defines annotations that the teacher can use to define the parts that will be automatically removed by the tool
keywords
here are the recognized keywords
tag | meaning |
---|---|
prune-cell |
remove this cell from the output |
prune-begin |
remove this cell and the ones below from the output |
prune-end |
remove this cell, but resume insertion on the next cell |
prune-begin-next (*) |
keep this cell from the output, and start pruning at the next one |
prune-end-previous (*) |
stop pruning, and insert the current cell |
prune-line (*) |
remove just that one line from the output |
prune-line-begin (**) |
remove that line and the following ones |
prune-line-end (**) |
remove that line but the following ones will show up |
NOTES
- (*) because
prune-begin-next
andprune-end-previous
appear in a cell that is visible, the whole line containing the tag is removed from the output, so it is probably best to keep these tags on a separate line - (**)
prune-line
variants of course are not relevant, and are ignored, if set in the cell's metadata tags
line format
the tool will consider a tag is present in a cell if any line in the cell
contains one of the above keywords, with the beginning of the line containing
only #
and spaces or tabs
so for exemple
line | match |
---|---|
prune-cell | yes |
# prune-cell | yes |
# # prune-cell | yes |
some code prune-cell | no |
cell metadata
the tags can also be set in the cell's metadata as well (except for prune-line
) ; something like this
{
"tags": [
"prune-cell"
]
}
examples
so that these 2 scenarios are equivalent
cell | tag | preserved |
---|---|---|
1 | y | |
2 | prune-cell |
n |
3 | y | |
4 | y | |
5 | prune-begin-next |
y |
6 | n | |
7 | n | |
8 | n | |
9 | prune-end-previous |
y |
10 | y |
or
cell | tag | preserved |
---|---|---|
1 | y | |
2 | prune-cell |
n |
3 | y | |
4 | y | |
5 | y | |
6 | prune-begin |
n |
7 | n | |
8 | prune-end |
n |
9 | y | |
10 | y |
Project details
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
File details
Details for the file nbprune-0.4.0.tar.gz
.
File metadata
- Download URL: nbprune-0.4.0.tar.gz
- Upload date:
- Size: 5.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.12.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 04c15a3f612e0f5bb72b7b0d07488a3b7fc1803bb407fc10ba060659217df764 |
|
MD5 | 78f4a3ba32efc0be7def67a88ad433b3 |
|
BLAKE2b-256 | 2f43ddb20610159202800a2965eaab8f0158391f209718be3aa61b2df16da086 |
File details
Details for the file nbprune-0.4.0-py3-none-any.whl
.
File metadata
- Download URL: nbprune-0.4.0-py3-none-any.whl
- Upload date:
- Size: 5.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.12.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 35427bfd500b90fb37fcde2ab222e6238971fa1a0d29d6fc78c2f067702612fd |
|
MD5 | 6dd46ec00fefab647d414882562017a8 |
|
BLAKE2b-256 | fb7b7331bdaf243c5a9893638fdf8ad7b3052707134befb7d52625af2e9a80dd |