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

🧱 Transform notebook blocks with captions to figures in place #760

Merged
merged 9 commits into from
Nov 18, 2023

Conversation

fwkoch
Copy link
Collaborator

@fwkoch fwkoch commented Nov 17, 2023

This PR enables creating a figure directly inside a notebook by adding a caption to a cell:

#| caption: My figure caption
...
plt.show()

This modifies the block structure from:

block > code/output

to

block > figure > code/output

This PR also cleans up figures referencing other figures (e.g. if you want to include a "notebook figure" created as described above in a separate markdown page). Referencing a figure from another figure removes the original caption / figure number. If you want to keep the original caption / figure number, you may embed the figure instead.

For full functionality with thebe, this requires jupyter-book/myst-theme#272

TODO:

  • Fix up embedding these figures to make sure they are computable
  • Allow kind to be table
  • Follow through caption parsing

There is still a little bit of wonkiness with resolving embedded content and figure references simultaneously, but those issues are mostly encountered in edge cases - I think for now this is good enough!

@rowanc1 rowanc1 merged commit adb9121 into main Nov 18, 2023
4 checks passed
@rowanc1 rowanc1 deleted the feat/notebook-figure branch November 18, 2023 03:46
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.

2 participants