diff --git a/anki/tags.py b/anki/tags.py index 5d9b7a6f1..0ab99cbf4 100644 --- a/anki/tags.py +++ b/anki/tags.py @@ -4,6 +4,7 @@ from anki.utils import intTime, ids2str, json from anki.hooks import runHook +import re """ Anki maintains a cache of used tags so it can quickly present a list of tags @@ -145,7 +146,8 @@ class TagManager(object): def canonify(self, tagList): "Strip duplicates and sort." - return sorted(set(tagList)) + strippedTags = [re.sub("[\"']", "", x) for x in tagList] + return sorted(set(strippedTags)) def inList(self, tag, tags): "True if TAG is in TAGS. Ignore case." diff --git a/aqt/editor.py b/aqt/editor.py index df6b9f60e..c85091908 100644 --- a/aqt/editor.py +++ b/aqt/editor.py @@ -708,7 +708,9 @@ class Editor(object): def saveTags(self): if not self.note: return - self.note.tags = self.mw.col.tags.split(self.tags.text()) + self.note.tags = self.mw.col.tags.canonify( + self.mw.col.tags.split(self.tags.text())) + self.tags.setText(self.mw.col.tags.join(self.note.tags).strip()) if not self.addMode: self.note.flush() runHook("tagsUpdated", self.note)