mwouts / jupytext

Jupyter Notebooks as Markdown Documents, Julia, Python or R scripts
https://jupytext.readthedocs.io
MIT License
6.65k stars 386 forks source link

Multi-line metadata #1012

Closed patchmeifyoucan closed 1 year ago

patchmeifyoucan commented 2 years ago

Hello,

I am using Jupytext in combination with another Jupyter plugin which changes the Jupyter UI according to metadata written by the extension. The resulting JSON is a bit long and in all cases exceeds the max. line length recommended by Python, hence PyCharm inserts line breaks into the meta data.

So far, I have not found a useful solution except keeping a long cell definition along with the metadata JSON. Is it possible to define the code cell over multiple lines, i.e., is there any way to signal line continuation on a line break? Or is there any other way to accomplish this using the percent or light formats?

Thank you very much.

mwouts commented 2 years ago

Hello @patchmeifyoucan , are you trying to save your notebook as a script, or a markdown file?

If you are using the .md extension then you could give a try to the MyST Markdown format which write the metadata as YAML blocks.

Otherwise, you could also consider setting a cell_metadata_filter as documented here - if you used paired notebooks (text+ipynb) then the filtered metadata will still be preserved (but only in the ipynb document)

mwouts commented 1 year ago

Closed in favor of #1029