Sync flashcards from Roam Research to Anki
Roam -> Anki Sync
]] (deprecated)-- deprecated --
Version 2 of this project is in active development here: Fabricus. It supports bidirectional sync and is implemented as an Anki plugin.
This contains code meant to be used with roam-backup and Anki. roam-backup
saves your Roam Research into Google Cloud Storage. Roam -> Anki Sync
reads from Google Cloud Storage and extracts any flashcards you defined into Anki.
ripgrep
.roam-backup
saving to a Google Cloud Storage bucket GCS_BUCKET_NAME
.ripgrep
must be available on $PATH
(usually this isn't a problem)..env
file to define nodejs env variables. See Usage
section for what is expected there.ClozeUID
with 3 fields: { Text: text, Extra: extra, UID: uid }
. Easiest way is to clone the existing Cloze
model and add a UID
field. This field is used for idempotency.http://127.0.0.1:8765
.This program expects some Node environment variables to be present. To provide them, create a .env
file following the example below:
GCS_BUCKET_NAME="some-roam-backup"
GCS_SERVICEACCOUNT_KEYFILE="./key.json"
DEFAULT_DECK="Some Deckname"
ANKI_CONNECT_URL="http://127.0.0.1:8765"
GCS_SERVICEACCOUNT_KEYFILE
can be omitted if using application default credentials.
In Roam, a modified Anki cloze syntax is provided. Example:
- this is {c1:another} {c2:flashcard} {c3:haha}. #flashcard {uid:20200405151338}.
The necessary components are:
#flashcard
or [[flashcard]]
tag{uid:something}
format, for idempotency. I usually use a timestamp generated via text expansion.Everything must be on a single line.
npm start
will run a one-time sync from Roam to Anki. To make this run automatically, use your OS automation system of choice e.g. cron.
Once cards are synced, changes are pulled one way from roam to anki. The note fields will be overwritten in Anki if they have been changed there. Any tags on the note in Anki will be preserved.
An easy way to organize automatically synced cards is to filter by the ClozeUID
model and tag to your heart's content.
gcloud auth application-default login
..env
file.