ox-ipynb icon indicating copy to clipboard operation
ox-ipynb copied to clipboard

Ignore `:exports none`

Open AndreasMatthias opened this issue 2 years ago • 3 comments

I frequently use the header argument :exports none for code blocks that I don't want to be exported to LaTeX:

#+begin_src jupyter-python :exports none
import numpy as np
#+end_src

But now I face the issue that these bocks are not even exported to ipynb, though they are crucial for running the notebook.

Is it possible to ignore :exports none during export to ipynb?

AndreasMatthias avatar Oct 26 '23 19:10 AndreasMatthias

~~Seems like ox-ipynb.el#L842-L858 should handle this, but it doesn't work for me.~~

By accident I mistyped the header and then the following worked. Note the doubling of :exports:

#+begin_src jupyter-python :exports :exports none
import numpy as np
#+end_src

AndreasMatthias avatar Oct 26 '23 22:10 AndreasMatthias

I am not sure how you can have it both ways. Your work around seems to work like you want, presumably because you get something like ":export none" as the string, so the code you linked above doesn't get rid of it, but for some reason still works to exclude it in LaTeX. I guess if I did it correctly in ipynb, it would exclude it there too.

One solution you could use is a function in ox-ipynb-preprocess-hook that removes ":export none" from source blocks.

jkitchin avatar Oct 29 '23 18:10 jkitchin

Thanks for the hint to ox-ipynb-preprocess-hook. I don't know much about the code base of org-babel but I'll give it a try.

AndreasMatthias avatar Oct 30 '23 20:10 AndreasMatthias