Skip to content

Instantly share code, notes, and snippets.

@z1lc
Created April 27, 2020 02:31
Show Gist options
  • Save z1lc/544a971164bf6179655a869e1f3c3980 to your computer and use it in GitHub Desktop.
Save z1lc/544a971164bf6179655a869e1f3c3980 to your computer and use it in GitHub Desktop.
Genanki compatibility testing
import genanki
# models/notes based on genanki README
templates = [
{
'name': 'Card 1',
'qfmt': '{{Question}}',
'afmt': '{{FrontSide}}<hr id="answer">{{Answer}}',
},
{
'name': 'Card 2',
'qfmt': '{{Answer}}',
'afmt': '{{FrontSide}}<hr id="answer">{{Question}}',
},
{
'name': 'Card 3',
'qfmt': '{{Answer}}{{Answer}}',
'afmt': '{{FrontSide}}<hr id="answer">{{Question}}{{Question}}{{Question}}{{Question}}{{Question}}{{Question}}',
},
{
'name': 'Reserved 12',
'qfmt': '{{Answer}}',
'afmt': 'updated!',
},
{
'name': 'Reserved 2',
'qfmt': '{{#z-unused}}{{/z-unused}}',
'afmt': '',
},
{
'name': 'Reserved 3',
'qfmt': '{{#z-unused}}{{/z-unused}}',
'afmt': '',
},
]
my_model = genanki.Model(
1607392319,
'Simple Model',
fields=[
{'name': 'Question'},
{'name': 'Answer'},
{'name': 'z-unused'},
{'name': 'z-unused2 (hidden)'}
],
templates=templates)
my_note = genanki.Note(
model=my_model,
fields=['ZZZZZZZZZZZZZZZZz', 'BBBBBBBBBBBBBBB', ''])
my_deck = genanki.Deck(
2059400110,
'Country Capitals')
my_deck.add_note(my_note)
genanki.Package(my_deck).write_to_file('output-5.apkg')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment