Open brosasaki opened 1 year ago
Could you provide an org-mode snippet and then how you'd like the result to be? Currently the default is to make note front from title and node back from content -- would you like to turn all links in an org-mode buffer to Anki notes?
I mean, I imagine converting an org-roam card (or any org heading) from this:
:PROPERTIES:
:ID: 72612BA5-09A0-4DF3-8396-AA8349F277F6
:END:
#+title: cells
Cells are the 'basic building block' of life; all terrestrial life consists of cells in one form or another, and they are often adapted to serve the needs and environment of the lifeform they comprise.
Cells can be either [[id:7122B6F3-635B-4284-9F4B-31AAA103A988][prokaryotic]](lacking a nucleus) or [[id:FCD71E9C-0565-4667-B069-057458DDFA88][eukaryotes]].
According to cell theory:
- All life is composed of at least one cell
- All metabolic processes take place in cells
- Cells are descended from other cells
- Cells contain all [[id:EB554030-A86B-4C20-A032-72D9529DFAB0][hereditary information]]
Cells are composed of [[id:1A732D70-280B-4D2E-8FD9-64DE58C81632][organelles]], which improve efficiency by localizing reactions.
* cell-differentiation
:PROPERTIES:
:ID: A4346C26-289A-4253-9DFD-D3A1109B4331
:END:
Every [[id:72612BA5-09A0-4DF3-8396-AA8349F277F6][cell]] is derived from other [[id:72612BA5-09A0-4DF3-8396-AA8349F277F6][cells]].
In an organism, all [[id:72612BA5-09A0-4DF3-8396-AA8349F277F6][cells]] are genetically identical.
Differentiation is determined by changes in gene expresson, from lineage and/or hormone/environmental signals.
Growth processes determine number of [[id:72612BA5-09A0-4DF3-8396-AA8349F277F6][cells]], differentiation, body plan, etc.
e.g: [[id:4EF7CA72-FAD2-4302-9295-A530D2173220][stomatal guard cells]] produce hormones to prevent surrounding cells from becoming stomata.
To this:
Cells are the 'basic building block' of life; all terrestrial life consists of cells in one form or another, and they are often adapted to serve the needs and environment of the lifeform they comprise.
Cells can be either {{c1::prokaryotic}}(lacking a nucleus) or {{c2::eukaryotes}}.
According to cell theory:
- All life is composed of at least one cell
- All metabolic processes take place in cells
- Cells are descended from other cells
- Cells contain all {{c3::hereditary information}}
Cells are composed of {{c4::organelles}}, which improve efficiency by localizing reactions.
Every {{c1::cell}} is derived from other {{c1::cells}}.
In an organism, all {{c1::cells}} are genetically identical.
Differentiation is determined by changes in gene expresson, from lineage and/or hormone/environmental signals.
Growth processes determine number of {{c1:cells}}, differentiation, body plan, etc.
e.g: {{c2::stomatal guard cells}} produce hormones to prevent surrounding cells from becoming stomata.
Essentially, every (set of) link(s) (that point to the same destination) gets converted into cloze field(s). I ca imagine an option to also "clozify" ID-property-containing subheading lines (instead of excluding them) would be useful, too, since those also count as links in org-roam. I'm sure there are edge cases etc. but I feel like this would align with how many people write org-roam cards and would like to memorize them.
Here's my first stab at it:
(defun my/org-link-cloze-format (string)
"Turn org-links in STRING into cloze fields, where links to the same address have the same cloze field number."
;; based off of org-link-display-format
(save-match-data
(let ((seen-addresses '()))
(replace-regexp-in-string
org-link-bracket-re
(lambda (match)
"add address to SEEN-ADDRESSES if not already. Then, return the new cloze expression where the cloze field number is unique to the address."
(let ((address (match-string 1 match))
(label (match-string 2 match)))
(progn (add-to-list 'seen-addresses address t)
(concat "{{c"
(number-to-string (1+ (cl-position address seen-addresses :test #'string=)))
"::"
(or label address)
"}}"))))
string nil))))
(defun my/org-anki-sync-entry-cloze ()
"Synchronize entry at point, and convert links to cloze in the process, where links to the same address have the same cloze field number."
;; this does not work.
(interactive)
(let ((org-link-display-format #'my/org-link-cloze-format))
(call-interactively 'org-anki-sync-entry)))
Unfortunately, though my/org-link-cloze-format works correctly (as tested with the examples I made in the last post) my/org-anki-sync-entry-cloze is still a mystery to me. Maybe you you know the proper way to integrate this--this is my first time trying to contribute to a package.
Is there a known way to have the text of links be converted into cloze fields? I would like to use this package to memorize part of my org-roam files, particularly by memorizing the links between each card. It seems like it would be a simple implementation (theoretically I could just awk+elisp-fu it out, I guess) but I wanted to see if anyone had already done this personally or if this functionality is already there.