Skip to content

Commit 6d2336b

Browse files
Add docs on how to strip from Markdown notebooks
1 parent a7dd4db commit 6d2336b

File tree

1 file changed

+39
-5
lines changed

1 file changed

+39
-5
lines changed

docs/configuration.md

Lines changed: 39 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ to your JupyterLite deployment.
5353
jupyterlite_config = "jupyterlite_config.json"
5454
```
5555

56-
## Strip particular tagged cells from IPython Notebooks
56+
## Strip particular tagged cells from notebooks
5757

5858
When using the `NotebookLite`, `JupyterLite`, or `Voici` directives with a notebook passed to them, you can
5959
strip particular tagged cells from the notebook before rendering it in the JupyterLite console.
@@ -64,7 +64,7 @@ This behaviour can be enabled by setting the following config:
6464
strip_tagged_cells = True
6565
```
6666

67-
and then by tagging the cells you want to strip with the tag `jupyterlite_sphinx_strip` in the JSON metadata
67+
and then by tagging the cells you want to strip with the `jupyterlite_sphinx_strip` tag in the JSON metadata
6868
of the cell, like this:
6969

7070
```json
@@ -77,7 +77,7 @@ of the cell, like this:
7777

7878
This is useful when you want to remove some cells from the rendered notebook in the JupyterLite
7979
console, for example, cells that are used for adding reST-based directives or other
80-
Sphinx-specific content.
80+
Sphinx-specific content. It can be used to remove either code cells or Markdown cells.
8181

8282
For example, you can use this feature to remove the `toctree` directive from the rendered notebook
8383
in the JupyterLite console:
@@ -115,9 +115,43 @@ in the JupyterLite console:
115115
where the cell with the `toctree` directive will be removed from the rendered notebook in
116116
the JupyterLite console.
117117

118+
In the case of a MyST notebook, you can use the following syntax to tag the cells:
119+
120+
````markdown
121+
122+
+++ {"tags": ["jupyterlite_sphinx_strip"]}
123+
124+
# Heading 1
125+
126+
This is a Markdown cell that will be stripped from the rendered notebook in the
127+
JupyterLite console.
128+
129+
+++
130+
131+
```{code-cell} ipython3
132+
:tags: [jupyterlite_sphinx_strip]
133+
134+
# This is a code cell that will be stripped from the rendered notebook in the
135+
# JupyterLite console.
136+
def foo():
137+
print(3)
138+
```
139+
140+
```{code-cell} ipython3
141+
# This cell will not be stripped
142+
def bar():
143+
print(4)
144+
```
145+
````
146+
147+
The Markdown cells are not wrapped, and hence the `+++` and `+++` markers are used to
148+
indicate where the cells start and end. For more details around writing and customising
149+
MyST-flavoured notebooks, please refer to the
150+
[MyST Markdown overview](https://jupyterbook.org/en/stable/content/myst.html).
151+
118152
Note that this feature is only available for the `NotebookLite`, `JupyterLite`, and the
119-
`Voici` directives and works with the `.ipynb` files passed to them. It is not implemented
120-
for the `TryExamples` directive.
153+
`Voici` directives and works with the `.md` (MyST) or `.ipynb` files passed to them. It
154+
is not implemented for the `TryExamples` directive.
121155

122156
## Disable the `.ipynb` docs source binding
123157

0 commit comments

Comments
 (0)