kynan / nbstripout

strip output from Jupyter and IPython notebooks
Other
1.19k stars 95 forks source link

Support specifying keep_output as a cell tag #120

Closed scottcode closed 4 years ago

scottcode commented 4 years ago

I suggested in #117 that it would be nice to be able to mark a cell for keeping output via the cell tags. Cell tags are easier to see and modify (if you set View > cell toolbar > tags).

I have implemented this functionality in this pull request. I include tests as well, though I do so with pure pytest instead of cram, because cram does not work on Windows and that's what I have at the moment. In the test fixtures (notebooks),

"keep_output": true as a top-level cell key still works, but I raise an exception if it has both "keep_output": false and a keep_output tag, as that would be an explicit contradiction that the user should resolve.

Testing note: In my test fixtures I denote code cells as supposed to have (or not have) output using a comment line at the beginning of the code cell source. I specify the case where an exception should be raised also by a comment at the beginning of the corresponding code cell source.

scottcode commented 4 years ago

Hi @kynan, thanks for the suggestions! I've incorporated them and re-pushed.