How can I prevent the conversion of `\(a\)` into `<anki-mathjax>a</anki-mathjax>` in the _add cards dialog_ (HTML field)?

Background

I am using a .csv to create and import my Anki cards. If I want to use certain formatting (e.g. lists), then I have to include their html equivalents in the .csv file (e.g. <ol><li>Hello</li><ol>).

I now face the challenge of learning a lot of higher level maths and need to render math formulars in my Anki cards because of that. Importing <anki-mathjax>a</anki-mathjax> from a .csv would cause the formular to be not properly displayed when I try to review that card in Anki though. Instead, \(a\) needs to be included into my .csv file. Anki will convert it automatically into <anki-mathjax>a</anki-mathjax> on import.

The issue

I need to be able to check my math formular, before I can paste it’s html representation into my .csv file. For that, I do the following:

  1. Open add cards dialog.
  2. Open html preview.
  3. Paste my .csv code (e.g. \(a\)) into it.
  4. Edit the formular as I need it.
  5. Copy the resulting, modified html into my .csv file.

However, since Anki auto converts \(a\) into <anki-mathjax>a</anki-mathjax> even in the add card dialog without me actually adding that card, I always have to delete <anki-mathjax></anki-mathjax> and turn it back into \(\).

What would help?

  1. It would be helpful if I could turn off the auto conversion from \(a\) to <anki-mathjax>a</anki-mathjax> in the add cards dialog only (i.e. the conversion should not be turned off during import or other parts of anki).
  2. Or: if I could copy the html in the add cards dialog into my clipboard, so that it always would auto convert <anki-mathjax>a</anki-mathjax> back into \(a\) behind the scenes, that would help too. That way, my clipboard always contains the right html, that can be pasted as-is into my .csv cell.

I am open for other ideas.

  • I need to be able to see the entire card though, e.g. my questions html is like this:
Wie spricht man die folgende Menge aus?<br><br>\(A=\set{x \mid -5 < x < 3}\)

I need to be able to see how this is beeing rendered on my Anki card.

  • I want to continue using .csv – switching from it isn’t an option at the time being.

How could an addon help me achieve that? Is there maybe a similar addon available already?

Thanks for your time and help!

When you copy it back, just don’t copy the anki-mathjax tags. Copy the edited formula between them and paste that between the open/close \( markers in your file.

Or, copy the entire text back just like you have been doing, and when you’re done editing everything, run find-replace in your CSV to fix the markers.

This doesn’t seem like something an add-on could do, because the issue is with copy-pasting in and out of Anki.

1 Like

Yes, I’ve been doing that but it’s more time intensive than I’d like.

That’s actually a great idea. Not sure why I wasn’t thinking about that earlier, as it’s somewhat obvious. Thanks!

I’m pretty sure anki uses custom copy paste logic – but I don’t know what limitations addons have.

I’ll use your workaround for now but it’d be great if an addon solution would be possible (just to remove the last step of having to find and replace).

If it does – obviously neither do I! :sweat_smile:
Hopefully someone better versed in that can comment.