jupyter-book icon indicating copy to clipboard operation
jupyter-book copied to clipboard

Nest code-cells inside of admonitions and block-level syntax in myst notebooks

Open dennissxz opened this issue 5 years ago • 9 comments

Can I nest a code-cell under a dropdown cell? i.e.

````{dropdown} title 
text content
```{code-cell}
code content
```
text content
````

There is a warning message WARNING: Found an unexpected `code-cell` directive. Either this file was not converted to a notebook, because Jupytext header content was missing, or the `code-cell` was not converted, because it is nested.

If this is not possible, is there any way that I can hide/toggle a block of text + executable code?

dennissxz avatar Jan 16 '21 02:01 dennissxz

Thanks for bringing this up - right now it's not possible since we are using a 1-to-1 mapping of myst notebooks onto ipynb files, and ipynb has no concept of "nesting" code cell inside of other things. I know that @jstac and @mmcky have brough this up before as well but I couldn't find where, so I'm updating the title of this to be a bit more descriptive and flagging this as an enhancement request 👍

In the meantime, perhaps you could ask around in the discussion forum to see if anyone has solved this particular issue in some other way?

choldgraf avatar Jan 17 '21 14:01 choldgraf

@choldgraf we discussed this in the context of solutions to exercises in sphinx-exercise extension. Here is some past discussions on identifying an way forward for this: https://github.com/executablebooks/sphinx-exercise/issues/24 but no final approach has been decided and a solution has not yet been implemented.

mmcky avatar Jan 17 '21 23:01 mmcky

Hello, I'm looking forward to using the output of an executable code cell to nest it with a csv-table directive. I would like to know if there has been any approach to the solution of this matter. Thank you in advance!

latourfranco avatar Dec 22 '21 13:12 latourfranco

@latourfranco in https://github.com/executablebooks/sphinx-exercise/pull/45 we are working on a gated syntax for directives that would enable code-cell to be executed as it remains as the root level of the document. This approach is useful for admonition style directives.

It sounds like you are looking for a copy and paste style of code-cell such that the output can be used in a table?

https://github.com/executablebooks/jupyter-book/issues/1585

mmcky avatar Jan 03 '22 23:01 mmcky

@mmcky yeah that is what i´m looking forward to achieving. I could manage to do it another way using Python to generate the csv file that is read by the csv-table directive. Anyway, it would be great to hear if there is any approach to the issue.

latourfranco avatar Jan 05 '22 17:01 latourfranco

Why is this not listed on the Feature voting board?

Note: this is also discussed here - https://github.com/executablebooks/meta/discussions/159, which I think is supposed to be the main place for discussion?

mforbes avatar Mar 11 '23 03:03 mforbes

Why is this not listed on the Feature voting board?

Good spot! There's a bug in our voting logic that we've identified and will look to fixing :)

agoose77 avatar Mar 11 '23 21:03 agoose77

This is still not listed on Feature voting board...

mforbes avatar Nov 18 '24 03:11 mforbes

Yeah, I would love to see this reolved.

arm61 avatar May 02 '25 13:05 arm61