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

Support "Hide cell contents" directives #160

Closed
matthewturk opened this issue Jan 26, 2023 · 4 comments
Closed

Support "Hide cell contents" directives #160

matthewturk opened this issue Jan 26, 2023 · 4 comments
Assignees
Labels
enhancement New feature or request

Comments

@matthewturk
Copy link

Context

I'd like to specify some cells in jupyter notebooks as being hidden, using either the YAML frontmatter options or using the cell metadata tags, as specified in the MySTNB documentation. At present, neither suppresses when using .ipynb as content sources and myst start to serve.

Proposal

I think either allowing these configuration options, or support direct transclusion of figures from notebooks would be sufficient to enable generating figures/diagrams using jupyter notebooks. (i.e., not a thumbnail, but a direct embedding of the cell outputs using figure references.) My particular use case is where I'm doing some internal API manipulations to expose behavior and methods, so the underlying code may just serve to confuse.

Tasks and updates

No response

@matthewturk matthewturk added the enhancement New feature or request label Jan 26, 2023
@fwkoch
Copy link
Collaborator

fwkoch commented Jan 26, 2023

@matthewturk - thanks for the issue, and great timing!

In the latest release we added functionality to reference notebook output as a figure.

First, label the cell using cell metadata like so (following the style of quarto):

#| label: my-cell
5 + 5

Then you can reference the label in a figure directive:

```{figure} #my-cell

This figure shows the output of some simple math. It will also work with images, html outputs, etc!
```

Doing so will embed the output as a figure. Sounds like this matches the second option in your proposals? There isn't a ton of flexibility yet, e.g. you can't hide cells directly in the notebook, only when including elsewhere. Give it a try and let us know what else you need to make this any more usable!

@matthewturk
Copy link
Author

Thank you! What I was missing was indeed referencing it using {figure} #my-cell -- I had been trying to do it using the inline references, not realizing that I could specify a label as the argument to the {figure} directive. That's awesome!

I'm fine with closing the issue, although if you want to use it to track getting cell metadata like mystnb that's OK with me too.

@fwkoch
Copy link
Collaborator

fwkoch commented Jan 31, 2023

I added info about figures referencing cell output to the docs in #177

I'll close this now, and we can open a new issue when we start thinking more about cell metadata.

@davidtrem
Copy link

Is there any plan to support myst-nb cell tags like hide-input, remove-cell...
like mentioned in jupyter-book/myst-theme#50 ?
This is a roadblock for me today.
Is there any (easy) way around it (i.e. remove notebook cell tagged with remove-cell during pdf or html build) ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants