Skip to content

Commit 51b997a

Browse files
committed
fix: apply cleanMath to field values before AnkiConnect export
- fix: import and apply cleanMath() to all text fields in anki-connect.js - fix: convert LaTeX delimiters at export time instead of runtime - feat: bump version to 1.0.5
1 parent 2172f17 commit 51b997a

2 files changed

Lines changed: 14 additions & 13 deletions

File tree

manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"manifest_version": 3,
33
"name": "NotebookLM2Anki",
4-
"version": "1.0.4",
4+
"version": "1.0.5",
55
"description": "Export NotebookLM Quizzes & Flashcards to Anki - via AnkiConnect, .apkg, or CSV",
66
"permissions": [
77
"activeTab",

src/lib/anki-connect.js

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// Handles communication with local Anki instance via AnkiConnect
33

44
import { CONFIG, QUIZ_FIELDS, FLASHCARD_FIELDS } from './constants.js';
5+
import { cleanMath } from './utils.js';
56
import {
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

Comments
 (0)