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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

馃悰 Correctly parse tags in {code-cell} #1128

Merged
merged 8 commits into from Apr 18, 2024
Merged

馃悰 Correctly parse tags in {code-cell} #1128

merged 8 commits into from Apr 18, 2024

Conversation

rowanc1
Copy link
Member

@rowanc1 rowanc1 commented Apr 18, 2024

This now correctly parses tags for {code-cell} directives, and works for visibility. The theme still does not do hide- but remove-input, remove-cell, and remove-output now all work in markdown notebooks.

This means that things like this:

:::{code-cell}
:tags: remove-input
!myst build -h
:::

Now show the output nicely in the docs, with the --execute flag on. Super cool.

cc @choldgraf

@choldgraf
Copy link
Member

Ah nice, this confused me as well. I've added a quick example to document this so that others know how to control it. If that example looks correct to @rowanc1 then I say we merge!

Copy link
Member

@choldgraf choldgraf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me in the docs!

https://deploy-preview-1128--mystmd.netlify.app/notebooks-with-markdown#add-tags-to-code-cell-directives

One thing that's not clear to me (please update if you wanna quickly change this) is how you'd specify multiple tags. E.g. would it be :tags: "one, two, three". Or would it be:

:tags:
  - one
  - two
  - three

?

I'll take your word for it on the tests :-D

Copy link
Member

@choldgraf choldgraf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops I spoke too soon, it looks like the cells on that page aren't being executed...could this be because {code-cell} is in a quote block?

https://deploy-preview-1128--mystmd.netlify.app/notebooks-with-markdown#add-tags-to-code-cell-directives

@rowanc1
Copy link
Member Author

rowanc1 commented Apr 18, 2024

They can be comma separated or parsed as yaml:

:tags: tag-1, tag-2
:tags: [tag-1]

Or

---
tags:
  - tag-1
  - tag-2
---

Right now I think that "tag-with-quotes" is not parsed correctly actually. Should add that case.

@rowanc1
Copy link
Member Author

rowanc1 commented Apr 18, 2024

This is a bit of a subtle change that was made is that single line :key: values are parsed as strings. Because we kept getting people erroring out on unexpected yaml stuff, especially in captions and labels with #: characters. I think we have docs on that!

I opted to support the current yaml parsing here to support jupyter-book out of the gate without changes. Maybe that should be under a flag?

@choldgraf
Copy link
Member

choldgraf commented Apr 18, 2024

Let me know if the change in f396585 + 2977664 looks correct and make edits as you wish!

@choldgraf
Copy link
Member

For some reason the execution is still not happening

@rowanc1
Copy link
Member Author

rowanc1 commented Apr 18, 2024

I am looking into that now, something to do with the blockquote.

@rowanc1
Copy link
Member Author

rowanc1 commented Apr 18, 2024

The bug is here, going to leave that one for a new day:

I am going to un-nest this out of the block quote, which works and get this improvement in. :)

@rowanc1 rowanc1 merged commit f13d451 into main Apr 18, 2024
5 checks passed
@rowanc1 rowanc1 deleted the bug/code-block branch April 18, 2024 20:58
@choldgraf
Copy link
Member

yessss thanks

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

Successfully merging this pull request may close these issues.

None yet

2 participants