jkitchin / ox-ipynb

org-mode exporter to Jupyter notebooks
173 stars 40 forks source link

Support custom cell-level metadata #6

Closed Cadair closed 5 years ago

Cadair commented 6 years ago

I am not sure if this already supports this, my attempts at reading the source did not enlighten me.

I would very much like to be able to add metadata to individual cells, mainly code blocks, so that I can do extra post-processing on the notebook once I have exported it. Is this something you think is possible?

Thanks

jkitchin commented 6 years ago

It is not currently possible, but it probably could be made possible. I am not real sure how you would do though. What syntax to annotate a code cell do you imagine using? I feel like it would look something like this:

#+ATTR_IPYNB: :key1 val1 :key2 val2

right above a cell. That would then be used to construct cell metadata. Would that do what you have in mind?

Cadair commented 6 years ago

Yeah that was pretty much what I had in mind, do you see putting it above a SRC block working?

jkitchin commented 6 years ago

I thought so, but it turns out that won't work, those attributes don't export to a new org buffer which is the first step of exporting as of now. It might have to go in the src header. Can you give me some examples of what you would like to do?

jkitchin commented 6 years ago

I implemented a version of this in the cell-metadata branch.

Try it out like this:

#+ATTR_IPYNB: :key1 val1 :key2 val2
#+BEGIN_SRC ipython
print(6)
#+END_SRC
sschob commented 5 years ago

Hi John, could this branch be merged into the master. I would like to use this feature to export notebooks that can be used with RISE (https://github.com/damianavila/RISE)

jkitchin commented 5 years ago

Give 8d62d42 a try. It should allow metadata on src blocks and paragraphs.