jkitchin / ox-ipynb

org-mode exporter to Jupyter notebooks
170 stars 39 forks source link

Ignore `:exports none` #50

Open AndreasMatthias opened 8 months ago

AndreasMatthias commented 8 months ago

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 commented 8 months ago

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
jkitchin commented 8 months ago

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.

AndreasMatthias commented 8 months ago

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.