Skip to content

Commit

Permalink
fix: attempt to fix change model for clozes
Browse files Browse the repository at this point in the history
refer: #89
  • Loading branch information
lervag committed Jun 1, 2024
1 parent bbff152 commit bff40f9
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/apyanki/note.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,9 +271,13 @@ def change_model(self) -> Optional[Note]:
for field in model["flds"]:
fields[field["name"]] = ""

fields[first_field] = f"Created from Note {self.n.id}\n\n"
for old_field_name, old_field in self.n.items():
fields[first_field] += f"### {old_field_name}\n{old_field}\n"

if model["name"] == "Cloze":
fields[first_field] += "\nCloze card needs clozes: {{c1::content}}"

note_data = NoteData(
model["name"],
" ".join(self.n.tags),
Expand Down Expand Up @@ -580,7 +584,7 @@ def add_to_collection(self, anki: Anki) -> Note:
for tag in self.tags.strip().split():
new_note.add_tag(tag)

if not new_note.dupeOrEmpty():
if not new_note.duplicate_or_empty():
anki.col.addNote(new_note)
anki.modified = True
else:
Expand Down

0 comments on commit bff40f9

Please sign in to comment.