Skip to content

Commit b6d5a78

Browse files
authored
Merge pull request #1 from lbesnard/SentenceCards
Feat: improve sentence card type to have play button next to each sen…
2 parents 42faaaf + 9cb633c commit b6d5a78

File tree

1 file changed

+33
-6
lines changed

1 file changed

+33
-6
lines changed

lingoanki/__main__.py

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -493,12 +493,24 @@ def create_word_model():
493493
{
494494
"name": "Word to Translation",
495495
"qfmt": "{{Word}}<br>{{Audio}}",
496-
"afmt": '{{FrontSide}}<hr id="answer">{{Translation}}',
496+
"afmt": """
497+
{{FrontSide}}<hr id="answer">
498+
499+
<div style="background-color:#f0f0f0; padding:10px; border-radius:8px;">
500+
<div style="color:#009933; font-size:1em;">{{Translation}}</div>
501+
</div>
502+
""",
497503
},
498504
{
499505
"name": "Translation to Word",
500506
"qfmt": "{{Translation}}",
501-
"afmt": '{{FrontSide}}<hr id="answer">{{Word}}<br>{{Audio}}',
507+
"afmt": """
508+
{{FrontSide}}<hr id="answer">
509+
<div style="background-color:#f0f0f0; padding:10px; border-radius:8px;">
510+
<div style="color:#009933; font-size:1em;">{{Word}}<br>{{Audio}}
511+
</div>
512+
</div>
513+
""",
502514
},
503515
],
504516
css="""
@@ -529,12 +541,26 @@ def create_sentence_model():
529541
{
530542
"name": "Sentence to Translation",
531543
"qfmt": "{{Audio}}",
532-
"afmt": '{{FrontSide}}<hr id="answer">{{Sentence}}<br>{{Translation}}',
544+
"afmt": """
545+
<div style="font-weight:bold; font-size:1.2em; color:#0073e6;">
546+
{{FrontSide}}<hr id="answer">
547+
</div>
548+
<div style="background-color:#f0f0f0; padding:10px; border-radius:8px;">
549+
<div style="color:#333; font-size:1em;">{{Sentence}}</div>
550+
<hr style="border: 1px solid #0073e6;">
551+
<div style="color:#009933; font-size:1em;">{{Translation}}</div>
552+
</div>
553+
""",
533554
},
534555
{
535556
"name": "Translation to Sentence",
536557
"qfmt": "{{Translation}}",
537-
"afmt": '{{FrontSide}}<hr id="answer">{{Sentence}}<br>{{Audio}}',
558+
"afmt": """
559+
{{FrontSide}}<hr id="answer">{{Audio}}
560+
<div style="background-color:#f0f0f0; padding:10px; border-radius:8px;">
561+
<div style="color:#009933; font-size:1em;">{{Sentence}}</div>
562+
</div>
563+
""",
538564
},
539565
],
540566
css="""
@@ -569,7 +595,6 @@ def create_combined_sentences_model():
569595
{{CombinedSentences}}<br>
570596
{{/CombinedSentences}}
571597
<br>
572-
[sound:{{Audio}}]
573598
""",
574599
"afmt": '{{FrontSide}}<hr id="answer">{{Translation}}',
575600
}
@@ -649,7 +674,9 @@ def create_flashcards(word_dict, sentence_dict, deck_name="Language Flashcards")
649674
for sentence, data in sorted_sentences:
650675
sentence_number = data["sentence_number"]
651676
audio_fp = data["audio_fp"]
652-
combined_sentences += f"<b>{sentence_number:03d}. {sentence}</b><br>"
677+
combined_sentences += (
678+
f"<b>{sentence_number:03d}. {add_audio(audio_fp)} {sentence}</b><br>"
679+
)
653680
combined_audio += f"{sentence_number:03d}. {add_audio(audio_fp)} <br>"
654681

655682
combined_translation = " ".join(

0 commit comments

Comments
 (0)