Open jchkoch opened 4 years ago
Off the top of my head I am not sure how easy it is to use :exclude: tags.
One way might be to export the org file as an org file, and then export that to an ipynb. The downside of that is you can lose some features of the ipynb markup like keywords.
Another option would be to use a preprocessing hook that deletes the exclude headings.
this exporter is not like regular org exporters, and doesn't work on the the parse tree, so it doesn't always support all the usual export features.
Thanks for the quick reply. I thought I would just open a issue more to document what works and what doesn't work with :exclude: tags in the notebook exporter. Upon reflecting on this error message I occasionally get when exporting my org notebooks to jupyter notebooks, I realized the only condition where I get this error is when exporting to a jupyter notebook using your exporter when I have :exclude: tags (i.e. "beamer" tag set on a header in org mode) and the org-mode line to :exclude: tags is commented out (like this # '+EXCLUDE_TAGS: beamer
). This then tells me that I'm doing something wrong because this line should not be commented out (in my workflow) when exporting to jupyter notebooks using ox-ipynb
. It would then appear to me that perhaps it would be possible for ox-ipynb
to either (since it appears that ox-ipynb
does respect the "normal" exporter rules regarding :exclude: tags):
#+EXCLUDE_TAGS:
line in the org-file.I have also created a MWE of this behaviour as an example org file which is attached here which may better illustrate my workflow of using :exclude: tags with ox-ipynb
.
Anyway, thanks for the awesome package and when I get some time I may dive into seeing if I can add some elisp code to fix this myself.
Do you mean exclude_tags instead of exclude_tag? I still get the error as long as there is a tag that is excluded with exclude_tags. So to export to ipynb I remove the exclude_tags option (which is faster than removing the tags from each heading).
@gmoutso I'm not sure quite what you mean but yes I mean exclude_tags
(the one with a "s"; I have edited my previous comment to include this). The MWE from my last comment shows describes my workflow which works for me to export the same org source file to 1) a Jupyter Notebook and 2) a PDF through LaTeX.
@jchkoch Thanks and apologies for the confusion. Your MWE works. If I use exclude_tags to limit export to ipynb, then the following export to ipynb works
#+exclude_tags: setup
* Summary
Hello
* Setup :setup:
Do not show
but this does not
#+exclude_tags: setup
* Summary
Hello
* Setup :setup:
Do not show
** Bad bad subsection
Hello
On the other hand, exporting to pdf exports both examples correctly (the subsection is not meant to be exported in the second example).
This actually does not affect me. I actually have a different use case to yours. I want to export to ipynb everything (to share implementation and results) and export to pdf only a subset (the results). If you know of a way to ignore exclude_tags
you would make me very happy! And also, many thanks @jkitchin for the package.
@gmoutso I think I understand your use case better now. If I understand correctly, you want to export to ipynb everything (and only publish a subset to PDF). In that case your second example should work if you simply remove the word setup
in the line #+exclude_tags: setup
. As far as my use case is concerned it becomes more difficult because ox-ipynb
is not as @jkitchin has mentioned a "normal" exporter and so does not respect tag inheritance (which seems difficult to enable with a notebook exporter for org). So for now, I specifically tag every heading (including sub-headings of headings which themselves are tagged with "beamer" tag) with a "beamer" tag. I hope that makes some sense.
Thanks for developing such a great jupyter notebook exporter from org-mode. I tend to generate both jupyter notebooks and latex (also beamer) files from a single org-mode source file which sometimes requires me to use tags to selectively choose which parts of the org-mode file gets exported to the jupyter notebook and latex/pdf file, respectively. In the system I have set up I use two different tags: noexport for org-mode blocks which should never be exported regardless of the export format and beamer for org-mode blocks which should not appear in jupyter notebooks. The issue that I have come across is that when including the following preamble in org-mode and exporting to a notebook, I seem to get an error.
The error backtrace that I get when I call the
ox-ipynb
exporter (toggle-debug-on-error
is enabled in emacs) is appended at the end of this post describing the issue. However, by enabling the org-mode line above,#+EXCLUDE_TAG: beamer
, (i.e. uncommenting this line) then the error disappears and ox-ipynb export works perfectly again. Could this possibly be a bug which is fixable in ox-ipynb or is this related to the discussion in issue #15 where ox-ipynb is referred to as not a "regular kind of exporter" not supporting the things the usual ones do? Would be interested in hearing your thoughts regardless and still a great package.