putting the flashcard back into review_tab

This commit is contained in:
stephen 2026-06-26 16:20:45 +10:00
parent c302e74c20
commit dbb9449efa
2 changed files with 19 additions and 4 deletions

View file

@ -48,7 +48,21 @@ def compile_anki_package(records, output_path, deck_name):
for idx, record in enumerate(records):
en_text = record["en_text"]
es_text = record["es_text"]
notes = f"Context: {record['source_context'] or ''} | {record['notes'] or ''}".strip(" | ")
# Extract and parse tags for native Anki tag support (split comma-separated text)
raw_tags = record.get("tags") or ""
note_tags = [t.strip().replace(" ", "_") for t in raw_tags.split(",") if t.strip()]
# Build text for visual notes area, appending tags if they exist
notes_parts = []
if record.get('source_context'):
notes_parts.append(f"Context: {record['source_context']}")
if record.get('notes'):
notes_parts.append(f"Notes: {record['notes']}")
if raw_tags:
notes_parts.append(f"Tags: {raw_tags}")
notes_display_text = " | ".join(notes_parts)
# Generate unique filenames for the media assets
en_audio_filename = f"en_audio_{idx}.mp3"
@ -79,14 +93,15 @@ def compile_anki_package(records, output_path, deck_name):
except Exception:
es_audio_field = ""
# Build the card note stack
# Build the card note stack, natively injecting the parsed Anki tags list
note = genanki.Note(
model=anki_model,
fields=[en_text, es_text, notes, en_audio_field, es_audio_field]
fields=[en_text, es_text, notes_display_text, en_audio_field, es_audio_field],
tags=note_tags
)
deck.add_note(note)
# Build package collection mapping archive pipelines
package = genanki.Package(deck)
package.media_files = media_files
package.write_to_file(output_path)
package.write_to_file(output_path)

Binary file not shown.