You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/source/syntax.md
+42-4Lines changed: 42 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -18,6 +18,9 @@ An exercise directive can be included using the `exercise` pattern. The directiv
18
18
*`nonumber` : flag (empty)
19
19
20
20
Turns off exercise auto numbering.
21
+
*`hidden` : flag (empty)
22
+
23
+
Removes the directive from the final output.
21
24
22
25
**Example**
23
26
@@ -76,6 +79,9 @@ A solution directive can be included using the `solution` pattern. It takes in t
76
79
*`class` : text
77
80
78
81
Value of the solution’s class attribute which can be used to add custom CSS or JavaScript.
82
+
*`hidden` : flag (empty)
83
+
84
+
Removes the directive from the final output.
79
85
80
86
```{note}
81
87
The title of the solution directive links directly to the referred directive.
@@ -184,11 +190,13 @@ static int factorial(int n){
184
190
````
185
191
186
192
187
-
## How to Hide Directives
193
+
## Hide or Remove Directives
194
+
195
+
### Hide Content
188
196
189
-
Directives can be hidden using the `dropdown` class which is available through [Sphinx Book Theme](https://sphinx-book-theme.readthedocs.io/en/latest/index.html). For Sphinx projects, add `"sphinx_book_theme"` to your `html_theme` in the `conf.py` to activate the theme in your Sphinx configuration
197
+
The content of directives can be hidden using the `dropdown` class which is available through [Sphinx Book Theme](https://sphinx-book-theme.readthedocs.io/en/latest/index.html). For Sphinx projects, add `"sphinx_book_theme"` to your `html_theme` in the `conf.py` to activate the theme in your Sphinx configuration
Jupyter Book's default theme is Sphinx Book Theme; therefore, Jupyter Book projects can utilize `dropdown` without having to activate the theme in your Sphinx configuration.
198
206
199
207
200
-
To hide the directive, simply add `:class: dropdown` as a directive option.
208
+
To hide the content, simply add `:class: dropdown` as a directive option.
201
209
202
210
**Example**
203
211
@@ -231,6 +239,36 @@ for any positive integer $n$.
231
239
```
232
240
````
233
241
242
+
### Remove Directives
243
+
244
+
Any specific directive can be hidden by introducing the `:hidden:` option. For example, the following example will not be displayed
245
+
246
+
````md
247
+
```{exercise}
248
+
:hidden:
249
+
250
+
This is a hidden exercise directive.
251
+
```
252
+
````
253
+
254
+
```{exercise}
255
+
:hidden:
256
+
257
+
This is a hidden exercise directive.
258
+
```
259
+
260
+
### Remove All Solutions
261
+
262
+
All solution directives can be removed from the final output by setting `hide_solutions` to `True`. For Sphinx projects, add the configuration key in the `conf.py` file. Jupyter Book projects, should set the configuration key in `_config.yml` as follows
263
+
264
+
```yaml
265
+
...
266
+
sphinx:
267
+
config:
268
+
hide_solutions: True
269
+
...
270
+
```
271
+
234
272
## Custom CSS or JavaScript
235
273
236
274
Custom JavaScript scripts and CSS rules will allow you to add additional functionality or customize how elements are displayed. If you'd like to include custom CSS or JavaScript scripts in Jupyter Book, simply add any files ending in `.css` or `.js` under a `_static` folder. Any files under this folder will be automatically copied into the built book.
0 commit comments