From 67728e73d78c55f75214b95b5d8f93e487ea4363 Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Sun, 10 Sep 2017 19:49:45 +1000 Subject: [PATCH] fix broken cloze deletion --- anki/media.py | 2 +- anki/template/template.py | 2 +- tests/test_flags.py | 1 - 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/anki/media.py b/anki/media.py index 31e836bf8..27d131f45 100644 --- a/anki/media.py +++ b/anki/media.py @@ -197,7 +197,7 @@ create table meta (dirMod int, lastUsn int); insert into meta values (0, 0); return m.group(1) for ord in ords: s = re.sub(clozeReg%ord, qrepl, string) - s = re.sub(clozeReg%".+?", "\\1", s) + s = re.sub(clozeReg%".+?", "\\2", s) strings.append(s) strings.append(re.sub(clozeReg%".+?", arepl, string)) return strings diff --git a/anki/template/template.py b/anki/template/template.py index d803f3722..d7f748b17 100644 --- a/anki/template/template.py +++ b/anki/template/template.py @@ -203,7 +203,7 @@ class Template: return buf txt = re.sub(reg%ord, repl, txt) # and display other clozes normally - return re.sub(reg%"\d+", "\\1", txt) + return re.sub(reg%"\d+", "\\2", txt) # look for clozes wrapped in mathjax, and change {{cx to {{Cx def _removeFormattingFromMathjax(self, txt, ord): diff --git a/tests/test_flags.py b/tests/test_flags.py index 8bfb38dee..11796b692 100644 --- a/tests/test_flags.py +++ b/tests/test_flags.py @@ -17,7 +17,6 @@ def test_flags(): # set flag 2 col.setUserFlag(2, [c.id]) c.load() - print("db is", col.db.all("select id, flags from cards")) assert c.userFlag() == 2 assert c.flags & origBits == origBits assert len(col.findCards("flag:0")) == 0