Closed mwouts closed 5 years ago
I don't know what kind of cell metadata is possible. You could imagine that as some kind of #+attr_jupyter: lines above a cell block. These would be associated with the src-block and could be used to go from org to jupyter.
It might look something like:
#+attr_jupyter: some cell metadata stuff
#+attr_jupyter: some other metadata stuff
#+BEGIN_SRC ipython
print(7)
#+END_SRC
It would be a little trickier to put metadata on markdown cells, but I guess you would do it like:
#+ipynb_cell_metadata: some metadata
and the exporter would have to check paragraphs for these kinds of things.
It would be helpful to see an example of what kind of cell metadata people use.
I wrote the ox-ipynb code to solve a problem where I write lecture notes in org-mode, but send notebooks to my students. I have never tackled a two way conversion.
Hello @jkitchin , thanks for the quick answer! I take notes of this. As you mention the two way conversion is certainly a bit tricky. For the other formats (markdown, Python scripts) my experience is that it is very convenient to be able to fix the notebook directly, and get the source updated. But we need to do it very well so that users can be confident that we are not going to break their source file...
As far as I see, cell metadata are not very much used. The cell metadata I have seen were either
hide_input
or hide_output
(boolean). And unfortunately there are at least three variations on these names...tags
, for instance tags=['parameters']
for papermill
's parameter cell (tags
is one of the very few official cell metadata )slideshow={"slide_type": "fragment"}
In the R markdown format, we only provide support for cell metadata on code cells, and we don't support nested dictionaries. Probably a similar target for org mode would be useful already.
On last question: if we start working on this, may I copy the example org file, and output notebook, as tests for Jupytext? Or, would you want to submit them as a pull request?
Thanks!
You are welcome to copy them.
I don't know what kind of cell metadata is possible. You could imagine that as some kind of #+attr_jupyter: lines above a cell block. These would be associated with the src-block and could be used to go from org to jupyter.
It might look something like:
#+attr_jupyter: some cell metadata stuff #+attr_jupyter: some other metadata stuff #+BEGIN_SRC ipython print(7) #+END_SRC
It would be a little trickier to put metadata on markdown cells, but I guess you would do it like:
#+ipynb_cell_metadata: some metadata
Would it be possible to actually include this functionality in the
ox-ipynb
???and the exporter would have to check paragraphs for these kinds of things.
It would be helpful to see an example of what kind of cell metadata people use.
one very useful application of the metadata at the cell level would be to write
"metadata": {"slideshow": {"slide_type": "SLIDETYPE"}},
where SLIDETYPE
would be read from something like #+ipynb_cell_metadata: slideshow:SLIDETYPE
or something like #+ipynb_slide_type: SLIDETYPE
and the SLIDETYPE = slide
OR SLIDETYPE = subslide
OR SLIDETYPE = fragment
OR SLIDETYPE = skip
OR SLIDETYPE = notes
And if the SLIDETYPE
is not given within body of the cell either add nothing to metadata
or to use last seen SLIDETYPE
This would facilitate direct production of a slideshow///OR///presentation from the org-mode
source files...
I wrote the ox-ipynb code to solve a problem where I write lecture notes in org-mode, but send notebooks to my students. I have never tackled a two way conversion.
With c077597 you can export a slide show from:
#+attr_ipynb: (slideshow . ((slide_type . slide)))
Nullam eu ante vel est convallis dignissim. Fusce suscipit, wisi nec facilisis facilisis, est dui fermentum leo, quis tempor ligula erat quis odio. Nunc porta vulputate tellus. Nunc rutrum turpis sed pede. Sed bibendum. Aliquam posuere. Nunc aliquet, augue nec adipiscing interdum, lacus tellus malesuada massa, quis varius mi purus non odio. Pellentesque condimentum, magna ut suscipit hendrerit, ipsum augue ornare nulla, non luctus diam neque sit amet urna. Curabitur vulputate vestibulum lorem. Fusce sagittis, libero non molestie mollis, magna orci ultrices dolor, at vulputate neque nulla lacinia eros. Sed id ligula quis est convallis tempor. Curabitur lacinia pulvinar nibh. Nam a sapien.
#+BEGIN_SRC ipython
print('hello')
#+END_SRC
#+attr_ipynb: (slideshow . ((slide_type . slide)))
Nullam eu ante vel est convallis dignissim. Fusce suscipit, wisi nec facilisis facilisis, est dui fermentum leo, quis tempor ligula erat quis odio. Nunc porta vulputate tellus. Nunc rutrum turpis sed pede. Sed bibendum. Aliquam posuere. Nunc aliquet, augue nec adipiscing interdum, lacus tellus malesuada massa, quis varius mi purus non odio. Pellentesque condimentum, magna ut suscipit hendrerit, ipsum augue ornare nulla, non luctus diam neque sit amet urna. Curabitur vulputate vestibulum lorem. Fusce sagittis, libero non molestie mollis, magna orci ultrices dolor, at vulputate neque nulla lacinia eros. Sed id ligula quis est convallis tempor. Curabitur lacinia pulvinar nibh. Nam a sapien.
#+attr_ipynb: (slideshow . ((slide_type . subslide)))
Nullam eu ante vel est convallis dignissim. Fusce suscipit, wisi nec facilisis facilisis, est dui fermentum leo, quis tempor ligula erat quis odio. Nunc porta vulputate tellus. Nunc rutrum turpis sed pede. Sed bibendum. Aliquam posuere. Nunc aliquet, augue nec adipiscing interdum, lacus tellus malesuada massa, quis varius mi purus non odio. Pellentesque condimentum, magna ut suscipit hendrerit, ipsum augue ornare nulla, non luctus diam neque sit amet urna. Curabitur vulputate vestibulum lorem. Fusce sagittis, libero non molestie mollis, magna orci ultrices dolor, at vulputate neque nulla lacinia eros. Sed id ligula quis est convallis tempor. Curabitur lacinia pulvinar nibh. Nam a sapien.
#+attr_ipynb: (slideshow . ((slide_type . slide)))
#+BEGIN_SRC ipython
%matplotlib inline
import matplotlib.pyplot as plt
#+END_SRC
#+attr_ipynb: (slideshow . ((slide_type . fragment)))
$\int f(x) dx$
with C-c C-e s o
Try it out, it is pretty lightly tested.
Hello @jkitchin , thanks for the org mode converter!
I recently released Jupytext, a two-way converter between text and Jupyter notebooks. One of the first suggestion I got on the day of the announcement was... to support org mode, cf. https://github.com/mwouts/jupytext/issues/62!
I see that you've gone pretty far in supporting not only code cells, but also text formatting. Do you think it would be feasible to implement the opposite conversion? Would you be interested in contributing a sample (and simple) org mode file to our project? Also, if you had suggestions on how to best represent the notebook metadata, and cell metadata in the org file, please let us know.