22// Handles communication with local Anki instance via AnkiConnect
33
44import { CONFIG , QUIZ_FIELDS , FLASHCARD_FIELDS } from './constants.js' ;
5+ import { cleanMath } from './utils.js' ;
56import {
67 QUIZ_MODEL_NAME , QUIZ_MODEL_ID , QUIZ_FIELDS as QUIZ_MODEL_FIELDS ,
78 QUIZ_FRONT_TEMPLATE , QUIZ_BACK_TEMPLATE , QUIZ_STYLING
@@ -138,21 +139,21 @@ export async function sendQuizzesToAnki(quizzes, deckName) {
138139 deckName : targetDeck ,
139140 modelName : QUIZ_MODEL_NAME ,
140141 fields : {
141- Question : quiz . question || "" ,
142- Hint : quiz . hint || "" ,
142+ Question : cleanMath ( quiz . question || "" ) ,
143+ Hint : cleanMath ( quiz . hint || "" ) ,
143144 ArchDiagram : "" ,
144- Option1 : options [ 0 ] ?. text || "" ,
145+ Option1 : cleanMath ( options [ 0 ] ?. text || "" ) ,
145146 Flag1 : options [ 0 ] ?. isCorrect ? "True" : "False" ,
146- Rationale1 : options [ 0 ] ?. rationale || "" ,
147- Option2 : options [ 1 ] ?. text || "" ,
147+ Rationale1 : cleanMath ( options [ 0 ] ?. rationale || "" ) ,
148+ Option2 : cleanMath ( options [ 1 ] ?. text || "" ) ,
148149 Flag2 : options [ 1 ] ?. isCorrect ? "True" : "False" ,
149- Rationale2 : options [ 1 ] ?. rationale || "" ,
150- Option3 : options [ 2 ] ?. text || "" ,
150+ Rationale2 : cleanMath ( options [ 1 ] ?. rationale || "" ) ,
151+ Option3 : cleanMath ( options [ 2 ] ?. text || "" ) ,
151152 Flag3 : options [ 2 ] ?. isCorrect ? "True" : "False" ,
152- Rationale3 : options [ 2 ] ?. rationale || "" ,
153- Option4 : options [ 3 ] ?. text || "" ,
153+ Rationale3 : cleanMath ( options [ 2 ] ?. rationale || "" ) ,
154+ Option4 : cleanMath ( options [ 3 ] ?. text || "" ) ,
154155 Flag4 : options [ 3 ] ?. isCorrect ? "True" : "False" ,
155- Rationale4 : options [ 3 ] ?. rationale || ""
156+ Rationale4 : cleanMath ( options [ 3 ] ?. rationale || "" )
156157 } ,
157158 tags : CONFIG . DEFAULT_TAGS
158159 } ;
@@ -179,8 +180,8 @@ export async function sendFlashcardsToAnki(flashcards, deckName) {
179180 deckName : targetDeck ,
180181 modelName : FLASHCARD_MODEL_NAME ,
181182 fields : {
182- Front : card . front || "" ,
183- Back : card . back || ""
183+ Front : cleanMath ( card . front || "" ) ,
184+ Back : cleanMath ( card . back || "" )
184185 } ,
185186 tags : CONFIG . DEFAULT_TAGS
186187 } ) ) ;
0 commit comments