[Feature Request] Automatically add a CSS class to cloze deletions in Mathjax, like in normal text

Instead of substituting {{c1::math::hint}} with just [hint] on the front and math on the back, it can be replaced with something like \class{cloze}{[hint]} and \class{cloze}{math} (or preferably a separate class like math-cloze whose default style doesn’t make text bold).

Doing it manually works if there is only one cloze but if there are multiple clozes, they would all change color even when it’s not their card.

Is \class valid in all contexts that plain text would be? The reason I avoided colors in the past was a worry that it might lead to broken rendering in some situations.

It’s part of a standard Mathjax extension so it should always work in Mathjax (unless for some reason the extension is not loaded of-course).

I don’t know of other contexts in which plain text is used so I can’t say but I would assume it wouldn’t work outside of Mathjax.

I just meant inside things like \sqrt{}. Happy to give it a try, but will need to roll it back if issues are reported. I’ve logged this on Add styling to cloze deletions inside MathJax · Issue #2650 · ankitects/anki · GitHub

1 Like

Oh I see what you mean. Yeah afaik, it should work in all contexts. At least from personally playing around with it, I couldn’t find a place where it didn’t work properly. But of-course more people testing it is more likely to find any potential bugs it causes.

Thank you for adding it!