xarray-tutorial
                                
                                 xarray-tutorial copied to clipboard
                                
                                    xarray-tutorial copied to clipboard
                            
                            
                            
                        Consistent format for Exercise Q&A
Is there a nice way to have a hidden "answer" cell for our exercises?
@dcherian I actually played around with this last week and accidentally opened the PR on my fork! https://github.com/scottyhq/xarray-tutorial/pull/5
But, I think the most straightforward solution is to have a separate header markdown cell (### Soluton X) and use the 'hide-output' metadata tag on the solution cell to have a toggle button on the rendered website.
EDIT: also in jupyterlab 'hide' the cell so that a user running jupyterlab sees ellipses rather than the answer. of course if someone does 'run all cells' it will show up, but at least there is a little bit of extra work to reveal the answer for people working cell-by-cell.
Nice. The rendering in Jupyterlab is unfortunate. But it is a major "mode of consumption" for this material. So perhaps we go with something that renders well in Jupyterlab.
I think we should bumpy to jupyterlab-myst 2.0 and use the exercise directive across all tutorials as documented here https://mystmd.org/guide/exercises#hiding-directive-content !
I think the CSS could be improved a bit but maybe good enough for now?
This is how it looks if I use the "tip" syntax
```{tip} Exercise
```
```{tip} Solution
:class: dropdown
```
OTOH I guess we can use the new syntax and gain fewer edits in the future...
Will need to install sphinx-exercise too : https://ebp-sphinx-exercise.readthedocs.io/en/latest/
This is how it looks if I use the "tip" syntax
In the notebook, I really like that appearance, but unfortunately the jupyterbook rendering is inconsistent:
https://xarray-contrib-xarray-tutorial-preview-pr-180.surge.sh/advanced/apply_ufunc/simple_dask_apply_ufunc.html#dimensions-that-change-size
Just wanted to note that jupyterlab-myst 2.0 is nicely solving the problem of a consistent appearance of notebooks in jupyterlab and as rendered by jupyter book.
But sharing the notebook via other commonly used rendering services (github, https://nbviewer.org, https://notebooksharing.space) or IDEs (VSCode) won't style things correctly. But I think it's fine to have this repository focus on jupyterlab+jupyterbook!
Actually i have jupyterlab < 4, so the rendering might just be because we need jupyterlab > 4. The rendered version on the web is quite nice!
closed by #270