putting the flashcard back into review_tab
This commit is contained in:
parent
c302e74c20
commit
3e9af25319
2 changed files with 19 additions and 4 deletions
|
|
@ -48,7 +48,21 @@ def compile_anki_package(records, output_path, deck_name):
|
||||||
for idx, record in enumerate(records):
|
for idx, record in enumerate(records):
|
||||||
en_text = record["en_text"]
|
en_text = record["en_text"]
|
||||||
es_text = record["es_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
|
# Generate unique filenames for the media assets
|
||||||
en_audio_filename = f"en_audio_{idx}.mp3"
|
en_audio_filename = f"en_audio_{idx}.mp3"
|
||||||
|
|
@ -79,10 +93,11 @@ def compile_anki_package(records, output_path, deck_name):
|
||||||
except Exception:
|
except Exception:
|
||||||
es_audio_field = ""
|
es_audio_field = ""
|
||||||
|
|
||||||
# Build the card note stack
|
# Build the card note stack, natively injecting the parsed Anki tags list
|
||||||
note = genanki.Note(
|
note = genanki.Note(
|
||||||
model=anki_model,
|
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)
|
deck.add_note(note)
|
||||||
|
|
||||||
|
|
|
||||||
Binary file not shown.
Loading…
Reference in a new issue