From 9bb4a02e0a1582f096b0f842ff2c7b2bfe2acca6 Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Mon, 4 May 2020 21:53:22 +1000 Subject: [PATCH] fix unnecessary spaces being added to notes with empty tags --- pylib/anki/collection.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pylib/anki/collection.py b/pylib/anki/collection.py index 2df64a6f9..296a1e74a 100644 --- a/pylib/anki/collection.py +++ b/pylib/anki/collection.py @@ -1010,7 +1010,9 @@ and type=0""", to_fix = [] for id, tags in self.db.execute("select id, tags from notes"): norm = unicodedata.normalize("NFC", tags) - if not norm.startswith(" ") or not norm.endswith(" "): + if not norm.strip(): + norm = "" + elif not norm.startswith(" ") or not norm.endswith(" "): norm = " " + norm + " " if norm != tags: to_fix.append((norm, self.usn(), intTime(), id))