MyST-NB icon indicating copy to clipboard operation
MyST-NB copied to clipboard

Utilising tags set on markdown cells

Open ajz34 opened this issue 4 years ago • 9 comments

Is your feature request related to a problem? Please describe.

When using jupyter-notebook generated document, toggle-button only works on code cell, but not markdown cell, if metadata of cell changed to

{"tags": ["hide_cell"]}

Toggle-button still works if using something like

    ```{toggle}
    Something not to be divulged
    ```

However, this is somehow not convenience.

In my first edition of issue, I does not know there could be four ```` before {toggle} (T.T) So just ignore the following text in the un-edited issue:

Furthermore, I want to write code inside toggled text:

    ```{toggle}
    ```python
    np.allclose(np.exp(complex(0, 1) * np.pi) + 1, 0)
    ```
    That's one of many Euler's fomulars.
    ```

That kind of code is probably not working well.

Describe the solution you'd like

Adding hide-cell support to markdown cell metadata.

ajz34 avatar Aug 13 '20 08:08 ajz34

Thanks for opening your first issue here! Engagement like this is essential for open source projects! :hugs:
If you haven't done so already, check out EBP's Code of Conduct. Also, please try to follow the issue template as it helps other community members to contribute more effectively.
If your issue is a feature request, others may react to it, to raise its prominence (see Feature Voting).
Welcome to the EBP community! :tada:

welcome[bot] avatar Aug 13 '20 08:08 welcome[bot]

I wander if this issue is related to https://github.com/executablebooks/jupyter-book/issues/212 I'm really new to this fancy theme (T.T)

ajz34 avatar Aug 13 '20 08:08 ajz34

hey @ajz34 I'm going to move issue to myst-nb

chrisjsewell avatar Aug 13 '20 12:08 chrisjsewell

Thanks for opening your first issue here! Engagement like this is essential for open source projects! :hugs:
If you haven't done so already, check out EBP's Code of Conduct. Also, please try to follow the issue template as it helps other community members to contribute more effectively.
If your issue is a feature request, others may react to it, to raise its prominence (see Feature Voting).
Welcome to the EBP community! :tada:

welcome[bot] avatar Aug 13 '20 12:08 welcome[bot]

Chris :smile: Looking forward!

ajz34 avatar Aug 13 '20 12:08 ajz34

Thanks @ajz34, so to "wrap" an entire markdown cell is not possible with the current implementation I'm afraid. (at least I cannot see a way)

The reason for this is due to the hierarchy of the underlying document structure. For example, if you have [markdown,code,markdown] cells:

# H1 a
## H2 a
text1
print("hi")
## H2 b
text2
# H1 b

this turns into:

<h1 a>
  <h2 a>
    text1
    <codecell tags="hide_cell">
      print("hi")
  <h2 b>
    text2
<h1 b>

which is fundamentally incompatible (at least to my knowledge) with a structure like:

<mdcell 1 tags="">
  elements...
<mdcell 2 tags="hide_cell">
  elements...

does that explanation make sense?

chrisjsewell avatar Aug 13 '20 13:08 chrisjsewell

and of course if you have any suggestions for a workaround 😬

chrisjsewell avatar Aug 13 '20 13:08 chrisjsewell

Got that! (actually I'm not considering wraping title :sweat_smile:) (is that some technical concerns you may encounter? :open_mouth:)

ajz34 avatar Aug 13 '20 13:08 ajz34

actually I'm not considering wraping title

For a general implementation though, we have to account for this possibility.

There may be some workaround, like a sphinx setting to "force" this wrapping, that comes with the caveat that it could break the build.

I'm going to have a re-look at the way we handle cell metadata soonish in #84, and so will bear this in mind

chrisjsewell avatar Aug 13 '20 13:08 chrisjsewell