jupyter-book / mystmd

Command line tools for working with MyST Markdown.
https://mystmd.org/guide
MIT License
192 stars 62 forks source link

Allow `include` as valid figure contents #812

Open fwkoch opened 9 months ago

fwkoch commented 9 months ago

It would be nice to include an external (maybe auto-generated?) file as figure contents, something like:

::::{figure}
:label: table-1
:kind: table

My Caption

:::{include} table.txt
:::
::::

However, the figure directive is not happy with this because it does not consider an include node valid figure contents (specified here https://github.com/executablebooks/mystmd/blob/main/packages/myst-transforms/src/containers.ts#L9-L16)

Probably the best approach here is to lift children out of include nodes onto the figure (and transfer any source info up to the figure as well). Then, the valid included content will be picked up.

roaldarbol commented 3 months ago

In case it's relevant, this works for table, but still gets a warning:

⛔️ 01-Chapters/02-Chapter.md container of kind table contains no valid content besides caption, legend
   Valid content types include image, referenced notebook cell, table, code, iframe, subfigure
⚠️  01-Chapters/02-Chapter.md unexpected figure content of type table found in legend node