org-anki
org-anki copied to clipboard
Cannot convert file-level headings
While working on #80, I found that trying to call org-anki-sync-entry
on "file level" entries (i.e. entries at the top of the file where their names are given by #+TITLE
) does not work, with the message wrong type argument: number-or-marker-p, nil
. org-anki-sync-all
also excludes file-level headings. Support for this style of heading would allow for better support for org-roam, making it an even greater addition to workflows which use that package, as well as more comprehensive use-case coverage in general.
To replicate, call org-anki-sync-entry
/org-anki-sync-all
on the following buffer, with org-anki-default-deck
set or an #+ANKI_DECK
line:
#+Title: What color is a leaf?
Green
While hacking at this for a bit, it seems that the treatment of the file-level as a "node"/entry in itself is something unique to org-roam and not org as a whole. Most critically, org-map-entries
does not consider the file-level as a node, and neither does org-entry-get
; org-current-level
returns nil at the file level instead of 0.
What this means is that getting org-anki to follow the org-roam convention would require either a lot of reinventing the wheel or the integration of functions from org-roam into the package. Maybe the latter could be done in such a way as to make org-roam an optional dependency?
The main hurdle for this seems to be the need for an alternative to org-map-entries
that includes the file-level, i.e. an org-roam-map-nodes
.
The other functions have org-roam analogues that can typically be fit in via the ((or (ignore-errors (org-function)) (ignore-errors (roam-function)))
pattern; please tell me if this is bad practice.
I don't know how org-roam works, is it so that one file should become one Anki note, where the #+TITLE
attribute would give the Anki note front (question) and the entire body of the file would be the note back?
@brosasaki Is the idea with issue to consider the file-level title similar to regular org entries are now? So for example in this org document:
#+title: File level title
Top level content
* First entry heading
First entry content
Would become these Anki notes:
Front | Back |
---|---|
File level title | Top level content |
First entry heading | First entry content |
Yes, that's the idea. I've been working on a branch https://github.com/brosasaki/org-anki/tree/org-roam-compatibility which implements these ideas, though it's still a bit hacky and certain features (skip and match functionality) aren't fully there for file-level headings.