diff --git a/qt/aqt/browser/previewer.py b/qt/aqt/browser/previewer.py index 693cd2279..e7e2b7532 100644 --- a/qt/aqt/browser/previewer.py +++ b/qt/aqt/browser/previewer.py @@ -170,6 +170,7 @@ class Previewer(QDialog): if not self._open: return c = self.card() + func = "_showQuestion" ans_txt = "" if not c: txt = tr.qt_misc_please_select_1_card() @@ -189,7 +190,9 @@ class Previewer(QDialog): # need to force reload even if answer txt = c.question(reload=True) ans_txt = c.answer() + if self._state == "answer": + func = "_showAnswer" txt = ans_txt txt = re.sub(r"\[\[type:[^]]+\]\]", "", txt) @@ -218,10 +221,12 @@ class Previewer(QDialog): txt = gui_hooks.card_will_show(txt, c, f"preview{self._state.capitalize()}") self._last_state = self._state_and_mod() + js: str if self._state == "question": - js = f"_showQuestion({json.dumps(txt)}, {json.dumps(ans_txt)}, '{bodyclass}');" + ans_txt = self.mw.col.media.escape_media_filenames(ans_txt) + js = f"{func}({json.dumps(txt)}, {json.dumps(ans_txt)}, '{bodyclass}');" else: - js = f"_showAnswer({json.dumps(txt)}, '{bodyclass}');" + js = f"{func}({json.dumps(txt)}, '{bodyclass}');" self._web.eval(js) self._card_changed = False diff --git a/qt/aqt/reviewer.py b/qt/aqt/reviewer.py index fa540c55b..9e7715535 100644 --- a/qt/aqt/reviewer.py +++ b/qt/aqt/reviewer.py @@ -337,9 +337,10 @@ class Reviewer: self._run_state_mutation_hook() bodyclass = theme_manager.body_classes_for_card_ord(c.ord) + a = self.mw.col.media.escape_media_filenames(c.answer()) self.web.eval( - f"_showQuestion({json.dumps(q)}, {json.dumps(c.answer())}, '{bodyclass}');" + f"_showQuestion({json.dumps(q)}, {json.dumps(a)}, '{bodyclass}');" ) self._update_flag_icon() self._update_mark_icon()