Open bhugueney opened 3 years ago
I am not sure how simple it would be to do this. There is a function ox-ipynb-export-code-cell
where that might be possible.
I guess though the easiest thing is to use named results, and put those code blocks in a section that is not exported. That would get the graphics where you want them, and just avoid the export of those cells.
Another idea would be use a preprocessing hook function that deletes those cells before exporting.
Thank you very much for your reply. However, I'm probably too dense to use the suggested workaround. I thought that instead of having a source block like : `
+--------+ +-------+ /-------\
| | --+ ditaa +--> | |
| Text | +-------+ |diagram|
|Document| |!magic!| | cRED |
| {d}| | {io} | | |
+---+----+ +-------+ \-------/
: ^
| Lots of work |
+-------------------------+
I would have in a :noexport:
the following named src block :
`
+--------+ +-------+ /-------\
| | --+ ditaa +--> | |
| Text | +-------+ |diagram|
|Document| |!magic!| | cRED |
| {d}| | {io} | | |
+---+----+ +-------+ \-------/
: ^
| Lots of work |
+-------------------------+
and then in an exported (normal) section, the following call :
#+call: ditaa-example() :results file
Hoping that the export would trigger the src codeevaluation an generated the image file and include the image in a markdown cell, without creating a (invalid) source cell.
However, it appears that either I made a mistake or ox-ipynb does not support the #+call:
: I get a
Wrong type argument: consp, nil
in org-babel-exp-do-export
and debugger shows
- org-babel-exp-do-export(nil lob) org-babel-exp-process-buffer() org-export-as(md nil nil t (:with-toc nil :with-tags nil)) org-export-string-as("\n#+call: ditaa-example() :results file\n\n\n\n" md t (:with-toc nil :with-tags nil)) (progn (fset (quote org-html-table) vnew) (fset (quote org-html-table-row) vnew) (fset (quote org-html-table-cell) vnew) (fset (quote org-export-get-relative-level) vnew) (fset (quote org-md-headline) vnew) (org-export-string-as s (quote md) t (quote (:with-toc nil :with-tags nil))))
Could you confirm if the #+CALL:
is supported and if there is a way to achieve what I want ? I want a call because I want the export to be fully automated for CI/CD, so generating images by hand with C-c is unfortunately not an option ☹.
Thank you again. Best Regards
#+CALL
does not seem to be supported directly, but this worked for me:
(with-current-buffer (org-org-export-as-org)
(ox-ipynb-export-to-ipynb-file-and-open))
I think you can work this into a fully automated CI/CD workflow. It might break some other feature though depending on how you make your notebooks.
I am not sure the canonical way to support #+call
to make it better than this.
Again, thank you so much for scimax and ox-ipynb ! As I want to have a source for my Notebooks, I want to also have the illustrations as source code that can be edited, so I would like to use the org mode source blocks for ditaa , graphviz and plantuml. However, when I use code blocks with
:exports results
, ox-ipynb still wants to export a cell with the source as a code cell. Of course, it does not work when loading the notebook. Would it be possible for the exporter to respect the:exports results
and only export the resulting image ?Best Regards.