For convenience, here’s a finished notetype that supports MathJax clozes as well:
If you’d like to learn JS, this is a fun challenge. You’ll learn about regular expressions, CSS selectors, EventListeners and other important stuff. I can write a guide for a simple solution if you’re interested.