Skip to main content

A command-line tool for importing flashcards from Roam into Anki

Project description

Ankify Roam

A command-line tool for importing flashcards from Roam into Anki.

Installation

pip install ankify_roam

Requirements

  • Python >=3.6
  • Anki
  • AnkiConnect
    • Open the Install Add-on dialog by selecting Tools | Add-ons | Browse & Install in Anki.
    • Input 2055492159 into the text box labeled Code and press the OK button to proceed.
    • Restart Anki when prompted to do so in order to complete the installation of AnkiConnect.

Getting Started

1. Ankify Roam

Define a card by adding the #ankify tag. By default the block will be converted into a Basic card with the block content on the front and it's children on the back:

  • What is the capital of France? #ankify
    • Paris

You can also create cloze deletions with curly brackets. If the block tagged with #ankify has any cloze deletions, then it'll be converted to a Cloze card. You can explicitely define the cloze ids or have ankify_roam infer them. Here's an example of cloze markup in Roam and what it becomes in Anki:

{1:Paris} is the capital and most populous city of {2:France}, with a estimated population of {2,148,271} residents #ankify
{{c1::Paris}} is the capital and most populous city of {{c2::France}}, with a estimated population of {{c3::2,148,271}} residents #ankify

2. Export Roam

Once you've tagged all the blocks to ankify, export your Roam:

  1. Click on the ... in the top right corner
  2. Select Export All > JSON > Export All
  3. Unzip the downloaded file.

3. Open Anki

Open Anki. Make sure you're on the profile you'd like to add the cards to and that you've installed the AnkiConnect add-on.

4. Create Roam specific card types

Running the following will create 2 new card types in anki for your Roam flashcards: 'Roam Basic' and 'Roam Cloze'

ankify_roam init

5. Add the Roam export to Anki

ankify_roam add my_roam.json

The blocks you tagged in Roam should now be in Anki!

6. Repeat

When you tag new blocks to ankify or edit ones you've already imported to Anki, you'll need to export your database again, and then rerun ankify_roam add on the export. This will add any newly tagged blocks and update the existing ones with any changes you've made.

Options

Instead of specifying the Roam export json, you can specify the exported zip file or give the directory it's in and ankify_roam will add the latest export in there.

ankify_roam add Roam-Export-1592525007321.zip
ankify_roam add ~/Downloads

Use a different tag than #ankify:

ankify_roam add --tag-ankify=flashcard my_roam.json

Use different note types than 'Roam Cloze' and 'Roam Basic'. See [TODO] for more details on creating compatible note types.

ankify_roam add --default-basic="My Basic" --default-cloze="My Cloze" my_roam.json

Same thing for the deck to add to:

ankify_roam add --deck="Biology" my_roam.json

Specify the deck and note type on a per-card basis:

  • 2+2={4} #[[[[ankify]]:deck=Math]] #[[[[ankify]]:model=My Cloze]]

TODO: cover all features in this section so that I don't need a separate documentation section

Fancy stuff

Styling the cloze markup

You can also use curly bracket page links to define cloze deletions:

The nice thing about doing it this way is that you can now style the cloze markup:

  1. Press Ctrl-C Ctrl-B in Roam to hide the square brackets surrounding page links.
  2. Add this css to your [[roam/css]] page (how to video here) to change the color of the curly brackets:
span[data-link-title="{"] > span,
span[data-link-title="}"] > span
{
  color: #DDDCDC !important;
}

Now you can #ankify Roam to your hearts content without #uglifying it too:

Uncloze Namespaces

When you add a cloze deletion around a namespaced page reference, you have the option to leave the namespace out of it:

ankify_roam add --pageref-cloze=base_only my_roam.json

With that option, a cloze deletion like this in Roam...

...will look like this in Anki:

Creating and editing Anki note types

Include a "uid" field

When creating your own note type, the most important thing you need to do is create a field called "uid".

This field is used by ankify_roam to remember which block in Roam corresponds with which note in Anki. Without this field, when you make a change to a block in Roam, ankify_roam will add that block as a new note in Anki rather than updating the existing one.

Suggested CSS modifications

Hide all Roam tags

.rm-page-ref-tag {
    display: none;
}

Hide page reference brackets

.rm-page-ref-brackets {
    display: none;
}

Hide bullet points to simulate "View as Document" in Roam:

li {
    list-style-type: none;
}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ankify_roam-0.0.1.tar.gz (16.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ankify_roam-0.0.1-py3-none-any.whl (16.0 kB view details)

Uploaded Python 3

File details

Details for the file ankify_roam-0.0.1.tar.gz.

File metadata

  • Download URL: ankify_roam-0.0.1.tar.gz
  • Upload date:
  • Size: 16.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/47.1.1 requests-toolbelt/0.9.1 tqdm/4.42.0 CPython/3.7.1

File hashes

Hashes for ankify_roam-0.0.1.tar.gz
Algorithm Hash digest
SHA256 354a6a91dc7b4670be1c23e9f206c3fa0c77e1fa9b9aa9180a6e7bf05e047dc1
MD5 12398994cc39d9128309f6bc0d516184
BLAKE2b-256 a7e59f87f6f1e1aa4f3cdf69fb447ab1be89521230d596fa7bf75f82f9eaea1b

See more details on using hashes here.

File details

Details for the file ankify_roam-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: ankify_roam-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 16.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/47.1.1 requests-toolbelt/0.9.1 tqdm/4.42.0 CPython/3.7.1

File hashes

Hashes for ankify_roam-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 430918d4ee94f1725750422c7c1b693bb2db2e7a8dc4804f80faf03fe81b378a
MD5 b2300285d65bbcde8320035a54cd58f1
BLAKE2b-256 2958d5080195ff3afa3362c3d7de233ac3ab7fa9304effd7a227628415bd3fb0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page