Open tommyphillips opened 2 years ago
Workaround found: I have put this in my .emacs and it enables me to push the notes to anki while keeping the ,*
sytax:
(defun tap/push-escaped-source-block-to-anki ()
(interactive)
(defun tap/select-source-block ()
(search-backward "#\+begin_src")
(next-line)
(set-mark-command nil)
(search-forward "#\+end_src")
(previous-line)
(end-of-line)
)
(anki-editor-mode 1)
(tap/select-source-block)
(let ((p1 (region-beginning))
(p2 (region-end)))
(save-restriction (narrow-to-region p1 p2)
(goto-char (point-min))
(while (re-search-forward "^," nil t) (replace-match "" nil t))
(anki-editor-push-notes)
(goto-char (point-min))
(while (re-search-forward "^\*" nil t) (replace-match ",\*" nil t))
)))
In an org file, I would like to 'hide' anki-editor code as much as possible. My strategy for doing so is to write the anki-editor within a source block as follows:
The problem is that it is necessary to escape the heading
*
s using,*
Otherwise, the main org document will interpret headings within the block as part of the main document. But anki-editor does not recognise this,*
syntax. I have had a look at the source code, but I am no expert. It seems that probably only a small tweak is required to enable anki-editor to recognise the,*
.If anyone could help, I would appreciate it. In case anyone suggests tangling the block to another file, and then pushing that file to anki, this is not the ideal solution, because the source block will not receive the ANKI_NOTE_ID.