From 625d7d5a82cd088124bd3e21f4b9e50bcff8ba85 Mon Sep 17 00:00:00 2001 From: "Soren I. Bjornstad" Date: Mon, 11 Aug 2014 11:33:39 -0500 Subject: [PATCH] rename fields in template properly when more than one modifier used Previously something like {{type:cloze:Text}} in the template would not be renamed when the field was renamed. --- anki/models.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/anki/models.py b/anki/models.py index 5249ee128..7f46b524b 100644 --- a/anki/models.py +++ b/anki/models.py @@ -304,10 +304,10 @@ and notes.mid = ? and cards.ord = ?""", m['id'], ord) def renameField(self, m, field, newName): self.col.modSchema() - pat = r'{{([:#^/]|[^:#/^}][^:}]*?:|)%s}}' + pat = r'{{(.*)([:#^/]|[^:#/^}][^:}]*?:|)%s}}' def wrap(txt): def repl(match): - return '{{' + match.group(1) + txt + '}}' + return '{{' + match.group(1) + match.group(2) + txt + '}}' return repl for t in m['tmpls']: for fmt in ('qfmt', 'afmt'):