taylormitchell / ankify_roam

A command-line tool which brings flashcards created in Roam to Anki.
MIT License
36 stars 6 forks source link

I can't seem to import cards with cloze deletions? #8

Closed Etyre closed 3 years ago

Etyre commented 3 years ago

Hey. I'm trying out ankify_roam.

Thanks for making this! Looking through the README, it looks like you already thought of and implemented all the features I was looking for.

However, when trying to import new anki cards from roam for the first time, it looks like on the "basic" style cards were imported. The "cloze" style cards didn't work.

I get the following error message:

MacBook-Pro-2:ankify_roam elityre$ ankify_roam add eli.json 2020-10-04 01:45:28,910 - INFO - Setting up Ankifier 2020-10-04 01:45:29,091 - INFO - Loading Roam Graph 2020-10-04 01:45:35,164 - INFO - Fetching blocks to ankify 2020-10-04 01:45:35,258 - INFO - Ankifying 4 blocks 2020-10-04 01:45:35,392 - ERROR - Failed ankifying <Block(uid='EZfmNWARo', string='This is al...')> during upload to anki Traceback (most recent call last): File "/usr/local/lib/python3.7/site-packages/ankify_roam/ankifiers.py", line 83, in ankify anki.add_note(anki_note) File "/usr/local/lib/python3.7/site-packages/ankify_roam/anki.py", line 52, in add_note return _invoke("addNote", note=anki_dict) File "/usr/local/lib/python3.7/site-packages/ankify_roam/anki.py", line 37, in _invoke raise GenericResponseError(response['error']) ankify_roam.anki.GenericResponseError: The field values you have provided would make an empty question on all cards. 2020-10-04 01:45:35,440 - ERROR - Failed ankifying <Block(uid='8ScQi1ftQ', string='This is a ...')> during upload to anki Traceback (most recent call last): File "/usr/local/lib/python3.7/site-packages/ankify_roam/ankifiers.py", line 83, in ankify anki.add_note(anki_note) File "/usr/local/lib/python3.7/site-packages/ankify_roam/anki.py", line 52, in add_note return _invoke("addNote", note=anki_dict) File "/usr/local/lib/python3.7/site-packages/ankify_roam/anki.py", line 37, in _invoke raise GenericResponseError(response['error']) ankify_roam.anki.GenericResponseError: The field values you have provided would make an empty question on all cards. 2020-10-04 01:45:35,490 - ERROR - Failed ankifying <Block(uid='cBUVxdLUr', string='This {{c1:...')> during upload to anki Traceback (most recent call last): File "/usr/local/lib/python3.7/site-packages/ankify_roam/ankifiers.py", line 83, in ankify anki.add_note(anki_note) File "/usr/local/lib/python3.7/site-packages/ankify_roam/anki.py", line 52, in add_note return _invoke("addNote", note=anki_dict) File "/usr/local/lib/python3.7/site-packages/ankify_roam/anki.py", line 37, in _invoke raise GenericResponseError(response['error']) ankify_roam.anki.GenericResponseError: The field values you have provided would make an empty question on all cards. 2020-10-04 01:45:35,491 - INFO - Added 1 new notes and updated 0 existing notes

It seems like it doesn't like that 4 of the blocks tagged "#ankify" don't have children (nor does it like it if they have empty children). From which I infer that the program is treating those blocks as basic cards instead of cloze deletion cards?

What should I do about this?

Etyre commented 3 years ago

Apparently, I can import cards that don't have children as long as they don't have curly brackets.

taylormitchell commented 3 years ago

Hey Etyre,

Hmm that is strange. Looks like ankify_roam is trying to create some cloze cards but it didn't convert the cloze deletions to the right anki syntax (so anki doesn't see any cloze deletions, which it doesn't like).

I'm guessing it's some issue with the cloze syntax or how ankify_roam is handling it. Could you share the blocks (including children) which are having this issue? Just copy pasting them here is fine.

Etyre commented 3 years ago

Yep.

The following is the text of the blocks that I tried to import.

It seems like as long as the block doesn't have a curly bracket, it gets added as a card to anki.

taylormitchell commented 3 years ago

Yeah, it's got something to do with how ankify_roam is handling cloze cards. I can't replicate the error on my end though. Can you send me some info about your setup?

I would also just try installing the latest version of ankify_roam via git. I've made some bug fixes recently, none were for the issue you're experiencing... but who knows, maybe they're related.

Etyre commented 3 years ago

Let's see.

Etyre commented 3 years ago

Alright. I deleted all the "ankify_roam" files and downloaded with the git link. (However, this did not produce a new directory in the location where I ran the command, as I was expecting. Is that normal?)

I tried it again, I ran into the same problem again.

Etyre commented 3 years ago

I updated to the latest version of anki, and that seemed to fix the problem.

taylormitchell commented 3 years ago

Nice! Glad to hear it.

I'll try downgrading my version of anki to track down the problem so I can either fix it or put a particular anki version in the ankify_roam prerequisites.