genanki
genanki copied to clipboard
Missing MyMedia as field
import genanki
my_model = genanki.Model(
1091735104,
'Simple Model with Media',
fields=[
{'name': 'Question'},
{'name': 'Answer'},
],
templates=[
{
'name': 'Card 1',
'qfmt': '{{Question}}<br>{{MyMedia}}',
'afmt': '{{FrontSide}}<hr id="answer">{{Answer}}',
},
])
my_note = genanki.Note(
model=my_model,
fields=['Capital of Argentina', 'Buenos Aires'])
my_deck = genanki.Deck(
2059400110,
'Country Capitals')
my_deck.add_note(my_note)
genanki.Package(my_deck).write_to_file('output.apkg')
Produces a file, where the question on the card can not be displayed, because it needs {{MyMedia}}, but I didn't define {{MyMedia}} as a field.
Should there maybe be a check if all fields are present, or should all template items which have no corresponding field be replaced with an empty string? As I'm currently working on a Rust port of genanki I am quite familiar with the codebase. I would like to solve this issue, if you can tell me, whether this is intended or not, and if yes, where to insert a check in the codebase.