kerrickstaley / genanki

A Python 3 library for generating Anki decks
MIT License
1.99k stars 150 forks source link

Support Cloze note type #3

Closed kerrickstaley closed 4 years ago

kerrickstaley commented 7 years ago

Cloze notes are great, let's do that.

qwiglydee commented 6 years ago

Isn't it just a matter of type: 1 in models?

kerrickstaley commented 6 years ago

Yes, it should be. But ideally I want to add a nice-to-use interface for creating Cloze notes.

kerrickstaley commented 6 years ago

(Pull requests welcome!)

mtherieau commented 6 years ago

I worked on this a bit and it's more than just type: 1 in models. Each cloze note can generate multiple cards. When generating Cards from a cloze Note, first the Model's template/qfmt field needs to be scanned to find fields that are marked with "cloze:" prefix. Then each of these fields in the Note needs to be scanned to find "cN::" cloze references. A Card needs to be created for each unique "N" ordinal cloze reference. Here's a working example that extends genanki.Note and genanki.Card to support cloze notes. https://gist.github.com/mtherieau/356445199db23daa776010710c68852a (fyi: I lifted the cloze regexes from anki)

kerrickstaley commented 4 years ago

Fixed in https://github.com/kerrickstaley/genanki/pull/37, won't get around to releasing it until later though.