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

How to handle notebook-level metadata

Open choldgraf opened this issue 5 years ago • 3 comments

In a markdown file, this is pretty straightforward - it's just the --- blocks at the top.

But for an ipynb file, we have a couple options:

  • Use all keys in the notebook metadata
  • Use a special key meant for myst-nb
  • Use a front-matter cell of some kind (raw cell, or check the first markdown cell for YAML?)

Currently we do the first, just wanna make sure it's an intentional decision!

choldgraf avatar Mar 15 '20 18:03 choldgraf

Note the first option makes markdown-notebook conversions simpler. Also note, when converting to the docutils docinfo, currently all values that are lists or dicts are stripped (e.g. {"key": {"nested": "dict"}})

https://github.com/ExecutableBookProject/MyST-Parser/blob/8b0d16e50c0a376810c751400831d59c20193d1a/myst_parser/docutils_renderer.py#L1227

chrisjsewell avatar Mar 15 '20 19:03 chrisjsewell

yeah - I think it makes parsing things simpler, but at the cost that asking users to manipulate notebook metadata is trickier, since IMO there isn't a very user-friendly UI process around this.

Do you think it would add much complexity if we parsed the first markdown cell, checking for front-matter YAML, and added that to whatever the notebook-level metadata had in it?

choldgraf avatar Mar 15 '20 20:03 choldgraf

That’s certainly a possibility

chrisjsewell avatar Mar 15 '20 20:03 chrisjsewell