Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

process cell tags remove-input and remove-output #543

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions doc/hidden-cells.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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": {},
Expand All @@ -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": {
Expand Down
6 changes: 6 additions & 0 deletions src/nbsphinx.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down