diff --git a/anki/models.py b/anki/models.py index 035e3ae7d..9674e1131 100644 --- a/anki/models.py +++ b/anki/models.py @@ -338,6 +338,8 @@ and notes.mid = ? and cards.ord = ?""", def renameField(self, m: NoteType, field: Field, newName: Optional[str]) -> None: self.col.modSchema(check=True) + if newName is not None: + newName = newName.replace(":", "") pat = r"{{([^{}]*)([:#^/]|[^:#/^}][^:}]*?:|)%s}}" def wrap(txt): diff --git a/aqt/clayout.py b/aqt/clayout.py index 04e32c820..44e1709c4 100644 --- a/aqt/clayout.py +++ b/aqt/clayout.py @@ -49,6 +49,7 @@ class CardLayout(QDialog): self.emptyFields.append(name) note[name] = "(%s)" % name note.flush() + self.removeColons() self.setupTopArea() self.setupMainArea() self.setupButtons() @@ -242,6 +243,12 @@ Please create a new card type first.""" ) self.redraw() + def removeColons(self): + # colons in field names conflict with the template language + for fld in self.model["flds"]: + if ":" in fld["name"]: + self.mm.renameField(self.model, fld, fld["name"]) + # Buttons ##########################################################################