mystmd icon indicating copy to clipboard operation
mystmd copied to clipboard

Removing cells causes their metadata to be removed from the MyST engine

Open choldgraf opened this issue 1 year ago • 2 comments

It is possible to remove cells with the remove-cell metadata tag. This causes the cell not to show up in the build output.

However, it also means that any outputs that have been labeled are no longer referenceable by MyST.

For example, if I have a cell with a remove-cell tag like this:

#| label: mycell
print("hi")

I cannot then reference it later like:

![](#mycell)

One of the most common use-cases for remove-cell is for people that want to define an output with computation, but don't want the code to be visible on the page. So making it possible to retain the labeled data, and still remove the cell, would be useful.

choldgraf avatar Apr 16 '24 19:04 choldgraf

Maybe this is the difference between hide-cell and remove-cell? The other use case is actually removing the cells code from the build output (including the AST and download, etc.). This use case is common enough in removing solution cells in courses, but also for removing some code etc. that you don't want a client to see. Both of those use cases, we don't really want the code to exist in the json representation, and I think that remove should actually remove it from the AST and be unable to access it through internal links, but we can still allow for hiding the source.

rowanc1 avatar Apr 16 '24 19:04 rowanc1

Ooh good point. I think those are different use-case targets that should both be supported somehow.

To me this feels like a case of documentation driven development 😅. If we wrote two how-two guides:

  • How to embed notebook outputs on a page without showing the cell content.
  • How to remove sensitive code outputs entirely from the MyST build.

Would it be possible? If so I'd say we can just document this rather than changing the code, and treat this as "expected behavior"

choldgraf avatar Apr 16 '24 19:04 choldgraf

I think this issue can be closed for now. Once we add support for hiding cells/outputs/inputs, we can add documentation for it.

agoose77 avatar Aug 09 '24 11:08 agoose77