Escaping double colon "::" in cloze deletion cards

Hello there :slight_smile:

i was wondering, if there is a recommended way of escaping a double colon (“::”) when used in a cloze deletion card as the actual text to be clozed.

My use case for this is a couple of cards i want to make for the Backus-Naur Form, which uses “::=” as a part of the syntax.

My preliminary solution has been to use the html <span> element between the two colons, which then looks something like this:


This does seem to work, but it feels a bit like a hacky solution.

Is there a better way of doing this?


There’s no escape character, but you could try a zero width space as a more compact workaround.

1 Like

Thanks for the suggestion!

Putting a zero width space between the colons does indeed seem to work for the standard cloze deletion cards.

I should have mentioned that i also want to make a second cloze deletion card type, where i’m prompted to type in the correct answer.

When comparing the given answer with the enclozed text, Anki recognizes the zero width space as a character and marks the given answer as wrong, if you don’t type a space between the colons.

You could obviously just ignore this “false negative”, but its not ideal. So in this respect it seems like the <span> element is the better solution.

Hello @dae, I hope you’re well :slight_smile:

I was wondering, is there a reason Anki can’t or shouldn’t implement an official escape mechanism to enable “::” as content within cloze deletions? I’ve contributed to this “multiple cloze” add-on and recently implemented basic support for using a zero-width space between colons without the false-negative issue Hildeguard mentioned. Using <span> tags creatively doesn’t work when converting HTML to text for expected <-> given comparisons. It’s also impossible to handle consistently if everyone uses a slightly different workaround.

Others have been asking about this capability for years (here and here). Perhaps it’s a rare need, perhaps a sizeable number of users simply work around the issue without asking.

I would be happy to contribute to Anki, maybe something like what I suggested here, if you agree it would be worth the effort. What do you think? Would it require much more effort than one might imagine?

Thanks for your consideration!

Our parsing code currently assumes the extracted text will be an unmodified slice of the original. To support this, you’d presumably need to switch to a Cow, and then use an allocated string if the separator needs to be unescaped, eg \::::.