Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing MyMedia as field #78

Open
yannickfunk opened this issue May 3, 2021 · 0 comments
Open

Missing MyMedia as field #78

yannickfunk opened this issue May 3, 2021 · 0 comments

Comments

@yannickfunk
Copy link

yannickfunk commented May 3, 2021

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant