Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

anki-editor-push-notes ignores source block headers on execution #28

Open
omidmnz opened this issue Sep 11, 2018 · 3 comments · May be fixed by #81
Open

anki-editor-push-notes ignores source block headers on execution #28

omidmnz opened this issue Sep 11, 2018 · 3 comments · May be fixed by #81

Comments

@omidmnz
Copy link

omidmnz commented Sep 11, 2018

I use Noweb reference syntax to embed some code in all my source blocks, which needs :noweb yes in the source blocks' headers.
The code works perfectly fine when I execute the block myself, but anki-editor-push-notes executes the blocks without the header, which leads to wrong outputs. I tried :cache yes to avoid the problem, but anki-editor-push-notes seems to ignore that too.
Here is a minimal example:

* Noweb Test                                                       :noexport:
  #+name: enable_noweb
  #+begin_src python
    noweb = True
  #+end_src

* Noweb Test
  :PROPERTIES:
  :ANKI_NOTE_TYPE: Basic
  :ANKI_DECK: OrgTestDeck
  :ANKI_NOTE_ID: 1536670156877
  :END:

** Front
   Noweb Enabled?

** Back
  #+begin_src python :exports results :results output :noweb yes
    noweb = False
    <<enable_noweb>>
    print("Noweb {0}.".format("enabled" if noweb else "not enabled"))
  #+end_src

  #+RESULTS:
  : Noweb enabled.

The result of manual execution is Noweb enabled. as expected, but the pushed card reads Noweb not enabled..
I am using Emacs 26.1, with Org Mode 9.1.14, and the latest anki-editor on Melpa.

@louietan
Copy link
Owner

This "unexpected behavior" involves the way anki-editor works, that when it is building the content of a field, it does the exporting on the region of subtree of that field entry, this way Org has no idea where that noweb block is defined, but when you evaluate the source block, Org will search backward the buffer for the definition of the noweb block.

@omidmnz
Copy link
Author

omidmnz commented Sep 28, 2018

Thanks for clarification. Should I consider this as a "Won't Fix" tag?

@marzipankaiser
Copy link

This also prevents globally set headers (#+PROPERTY: header-args ..., see https://orgmode.org/manual/Property-Syntax.html ) from working properly.
Interestingly, interactively calling anki-editor-export-subtree-to-html (which is defined but never used in anki-editor.el) with the point inside the respective body returns the correct result for me (i.e. respects the global header args) - is there a reason to prefer using org-export-string-as in anki-editor--build-fields over using this (or the method used there)?

tarsius pushed a commit to emacsmirror/anki-editor that referenced this issue May 18, 2024
added defcustom anki-editor-allow-duplicate
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants