diff --git a/anki_exporter.py b/anki_exporter.py index 91efb07..78980be 100644 --- a/anki_exporter.py +++ b/anki_exporter.py @@ -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) \ No newline at end of file + package.write_to_file(output_path) diff --git a/spanish_trainer.db b/spanish_trainer.db index 66228e7..56c75e9 100644 Binary files a/spanish_trainer.db and b/spanish_trainer.db differ