diff --git a/doc/hidden-cells.ipynb b/doc/hidden-cells.ipynb index a848aedc..ab13eebd 100644 --- a/doc/hidden-cells.ipynb +++ b/doc/hidden-cells.ipynb @@ -54,6 +54,26 @@ "answer" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Another way to hide sphinx is by adding a `remove-cell` cell tag. This is compatible with Jupyter Book." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "tags": [ + "remove-cell" + ] + }, + "outputs": [], + "source": [ + "answer" + ] + }, { "cell_type": "markdown", "metadata": {}, @@ -79,6 +99,42 @@ "source": [ "This is the cell after the hidden cell." ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Hidden input and output\n", + "\n", + "You can also only remove input and output of a notebook using the `remove-input` and `remove-output` cell tags.\n", + "Unlike for hiding entire cells, no metadata-based hiding of input and output is provided." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "tags": [ + "remove-output" + ] + }, + "outputs": [], + "source": [ + "\"Cell with hidden output\"" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "tags": [ + "remove-input" + ] + }, + "outputs": [], + "source": [ + "\"Did you see the input?\"" + ] } ], "metadata": { diff --git a/src/nbsphinx.py b/src/nbsphinx.py index 4482dfcc..83d2b986 100644 --- a/src/nbsphinx.py +++ b/src/nbsphinx.py @@ -785,6 +785,12 @@ def replace_attachments(text): 'HighlightMagicsPreprocessor': {'enabled': True}, # Work around https://github.com/jupyter/nbconvert/issues/720: 'RegexRemovePreprocessor': {'enabled': False}, + 'TagRemovePreprocessor': { + 'enabled': True, + 'remove_cell_tags': ('remove-cell',), + 'remove_all_outputs_tags': ('remove-output',), + 'remove_input_tags': ('remove-input',), + }, }), filters={ 'convert_pandoc': convert_pandoc,