Spurious "<span>" tag in Cloze deletions with hints

For several cards I’ve created recently, I’ve had a problem with an HTML span tags being automatically inserted into a cloze block. The opening tag is put immediately before the second “::” (used to mark the start of a cloze hint) whereas the closing tag is placed within the cloze hint, right before the closing braces “}}”.

An example of the HTML code is shown here:

For {{c1::a quaternion<span style="background-color: rgb(255, 255, 255);">::a(n) <anki-mathjax>\cdots</anki-mathjax></span>}}<anki-mathjax block="true">a+b\mathbf i+c \mathbf j+d\mathbf k,</anki-mathjax> ... (rest of card ommited)

This causes the blue cloze-highlighting to extend to the end of the card, when showing the back:

I’ve not been able to narrow down exactly when it happens, but it appears to be related to pasting “::a(n) (\cdots)” to create a cloze hint.

Has anybody else run into similar problems? I was using Anki version 2.1.53, but I just upgraded to 2.1.54, so I’ll post an update if it happens again.

It just happened again on 2.1.54. Here’s the resulting HTML:

Theorem. Consider {{c4::a closed<span style="background-color: rgb(255, 255, 255);">::a(n) <anki-mathjax>\cdots</anki-mathjax></span>}} subset <anki-mathjax>

This might be caused by using the Ditto clipboard manager. I have a saved clip for “a(n) (\cdots)”. It worked fine on older versions of Anki but something about the new version caused the pasted text to have the tags.