Standardizing how to add cell metadata between code and markdown cells
See original GitHub issueSomething I’ve noticed adds some (I think unnecessary) cognitive burden re: cell tags.
Currently there are two different syntaxes for cell metadata.
-
If the cell is a code cell, you provide metadata like so (ignore the backslashes):
\```python tags=["tag1", "tag2"] code \```
-
If the cell is a “region” (aka markdown cell), you provide it like this:
<!-- #region {"tags": ["tag1", "tag2"]} --> sometext <!-- #endregion -->
I find myself often using the first style in markdown cells, e.g. doing:
<!-- #region tags=["tag1", "tag2"]} -->
sometext
<!-- #endregion -->
This then gets read in as a “title” metadata instead of cell tags.
I feel like this is an unnecessary difference in syntax, at least from a user’s perspective. Is there a strong technical reason that it needs to be different between the two?
(a related point, it’d be nice to relax some of the strong JSON requirements for that metadata. for those who are writing it directly into markdown files, it’s annoying to have to remember to, e.g., use double-quotes only instead of single quotes etc.)
Issue Analytics
- State:
- Created 4 years ago
- Comments:12 (12 by maintainers)
Sure!
Well, not exactly: the
cell_metadata_json
option is just the format in which the metadata will be written by Jupytext. Whatever the value of the option it will be able to read metadata in either form, key/value or JSON. Only when it writes the notebook back to text, Jupytext will apply that option. Again, the aim here is to minimize the impact of format changes on the existing text notebooks.I quite like it! It works fine for me, I tried a few combinations of varying objects etc and wasn’t able to “break” things 😃
That said - one strange behavior I noticed was that if you write python code directly into the values, it’ll get executed. e.g., if I write
Then the output will be “4”. That seems vaguely insecure to me, no?