louietan / anki-editor

Emacs minor mode for making Anki cards with Org
699 stars 87 forks source link

SRC block exported even if :exports results is set #99

Open doolio opened 2 years ago

doolio commented 2 years ago

I have the following note with three fields (code, output and remarks) where I attempt to leverage org-babel to produce the output from specific code snippets and have that output below the next sub-heading and therefore appear on the back of the card. To achieve this I do not evaluate (via C-c C-c) the src block on the front (field = code) of the card but instead evaluate the one on the back (field = output) of the card. The second src block calls the first (tuple-unpacking) src block and simply prints the result. This is what I want. However, the issue is the second src block is exported when I push to Anki despite the header parameter :exports specifying results and not the default code. This is not what I would expect. Is this a bug in anki-editor or ox.el i.e. org-export.

* Tuple Unpacking
:PROPERTIES:
:ANKI_DECK: PKB
:ANKI_NOTE_TYPE: Code Output
:ANKI_TAGS: python
:ANKI_NOTE_ID: 1651139569279
:END:
** Code

#+name:tuple-unpacking
#+begin_src python :results output raw
*a, b, c = (1, 2, 3, 4, 5)
print(a, b, c)
#+end_src

** Output

#+begin_src shell :var REPL=tuple-unpacking :results output raw :exports results
echo $REPL
#+end_src

#+RESULTS:
[1, 2, 3] 4 5

** Remarks
Tuple unpacking
doolio commented 2 years ago

I've resolved my issue where the shell src block was being exported by finding a simpler solution meaning it is redundant. I can just use the name given to the first src block to force the results to appear in the next subheading. I'll not close this issue in case what I highlighted initially is indeed a bug in anki-editor.

* Tuple Unpacking
:PROPERTIES:
:ANKI_DECK: PKB
:ANKI_NOTE_TYPE: Code Output
:ANKI_TAGS: python
:ANKI_NOTE_ID: 1651139569279
:END:
** Code

#+name:tuple-unpacking
#+begin_src python :results output raw
*a, b, c = (1, 2, 3, 4, 5)
print(a, b, c)
#+end_src

** Output

#+RESULTS:tuple-unpacking
[1, 2, 3] 4 5

** Remarks
Tuple unpacking