I’m currently trying to change the text of the card in the reviewer if some conditions are true. My code searches for a term or expression in the card and, if it’s there, it proceeds to implement the changes. The problem is that sometimes the searched term coincides with some term in the HTML. I then thought, “what if I could get just the text of the card, without the HTML?”, but I have no idea if it’s possible.
I’d appreciate to get some advices on how to do that.
P.s. I’m also thinking about making this changes only if the answer side of the card is shown. I’ve tried to use if kind == "answer":
to achieve this but it didn’t work at all. Does anyone know how to properly do that?
Heres an exemple of what I’m trying to do:
import re
from anki.hooks import addHook
def change(text, card, kind):
names = ["Hello", "world", "tEST", "SUCCEED", "Fail"]
for name in names:
pattern = re.compile(rf"\b{name}\b", re.IGNORECASE)
matches = pattern.finditer(text)
for match in matches:
underline = f'<u>{match.group()}</u>'
text = text[:match.start()] + underline + text[match.end():]
return text
addHook("prepareQA", change)
Thank you in advance!