mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 22:12:21 -04:00
Use alternate pattern match during field changes
When a user renames or deletes a field, Anki tries to go through the user's templates to substitute occurrences of that field name with its new name or remove the field. However, if the user has multiple Mustache placeholders on a single line, this does not work as intended because the leading (.*) capture group grabs the text in-between the two (or more) Mustache placeholders. Examples: {{#Flag}} ... {{/Flag}}{{^Flag}} ... {{/Flag}} or {{Front}} {{#Flag}}...{{/Flag}} or {{Front}} Hello. {{Victim}}
This commit is contained in:
parent
11ea5d5686
commit
643ec35449
1 changed files with 1 additions and 1 deletions
|
@ -304,7 +304,7 @@ and notes.mid = ? and cards.ord = ?""", m['id'], ord)
|
|||
|
||||
def renameField(self, m, field, newName):
|
||||
self.col.modSchema(check=True)
|
||||
pat = r'{{(.*)([:#^/]|[^:#/^}][^:}]*?:|)%s}}'
|
||||
pat = r'{{([^{}]*)([:#^/]|[^:#/^}][^:}]*?:|)%s}}'
|
||||
def wrap(txt):
|
||||
def repl(match):
|
||||
return '{{' + match.group(1) + match.group(2) + txt + '}}'
|
||||
|
|
Loading…
Reference in a new issue