Add edge-case to type-in-answer filter in reviewer (#3010)

This commit is contained in:
Lucas Scharenbroch 2024-02-14 04:38:10 -06:00 committed by GitHub
parent b80057440e
commit df70564079
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -721,6 +721,7 @@ class Reviewer:
def typeAnsAnswerFilter(self, buf: str) -> str:
if not self.typeCorrect:
return re.sub(self.typeAnsPat, "", buf)
orig = buf
origSize = len(buf)
buf = buf.replace("<hr id=answer>", "")
hadHR = len(buf) != origSize
@ -744,6 +745,9 @@ class Reviewer:
s = f"<hr id=answer>{s}"
return s
if hadHR and not re.search(self.typeAnsPat, buf):
return orig
return re.sub(self.typeAnsPat, repl, buf)
def _contentForCloze(self, txt: str, idx: int) -> str | None: