From 78fe5d0521cb20930c91ec7d3c8c263cbb820ff4 Mon Sep 17 00:00:00 2001 From: llama Date: Wed, 6 Aug 2025 17:07:32 +0800 Subject: [PATCH] Fix show_exception's messagebox always formatting as plaintext (#4246) * fix show_exception's messagebox always formatting as plaintext * Revert "fix show_exception's messagebox always formatting as plaintext" This reverts commit aec6dd9be889c3f9635dc87efdb4d973535fca34. * convert SearchError msg to markdown when in browser --- pylib/anki/_backend.py | 2 +- qt/aqt/browser/browser.py | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/pylib/anki/_backend.py b/pylib/anki/_backend.py index 03fbb30d6..9a68cf644 100644 --- a/pylib/anki/_backend.py +++ b/pylib/anki/_backend.py @@ -246,7 +246,7 @@ def backend_exception_to_pylib(err: backend_pb2.BackendError) -> Exception: return BackendError(err.message, help_page, context, backtrace) elif val == kind.SEARCH_ERROR: - return SearchError(markdown(err.message), help_page, context, backtrace) + return SearchError(err.message, help_page, context, backtrace) elif val == kind.UNDO_EMPTY: return UndoEmpty(err.message, help_page, context, backtrace) diff --git a/qt/aqt/browser/browser.py b/qt/aqt/browser/browser.py index 5d41f4ac9..e222f62c2 100644 --- a/qt/aqt/browser/browser.py +++ b/qt/aqt/browser/browser.py @@ -10,6 +10,8 @@ import re from collections.abc import Callable, Sequence from typing import Any, cast +from markdown import markdown + import aqt import aqt.browser import aqt.editor @@ -20,7 +22,7 @@ from anki.cards import Card, CardId from anki.collection import Collection, Config, OpChanges, SearchNode from anki.consts import * from anki.decks import DeckId -from anki.errors import NotFoundError +from anki.errors import NotFoundError, SearchError from anki.lang import without_unicode_isolation from anki.models import NotetypeId from anki.notes import NoteId @@ -498,6 +500,8 @@ class Browser(QMainWindow): text = self.current_search() try: normed = self.col.build_search_string(text) + except SearchError as err: + showWarning(markdown(str(err))) except Exception as err: showWarning(str(err)) else: