I did use 'replace' function, I lost font color of my cards

① I did use ‘replace’ function to change ‘O’ to ‘:green_circle:’ , ‘X’ to ‘:x:’ in my deck.
② It worked fine though, It resets color of almost all the cards. (some cards are not affected. don’t know why)

③ for example,


This card(up) becomes this card(down)

④ color is critical with my arangement. I have no idea what to do…

I’ve done update, shut Ankimobile though, it won’t help. I guess it affects data somehow.

I’ve done backup with the backup file, did several trial, I’ve found the specific logic.

If I replace ‘O’ (big O only)to sth else, colorized texts in whole deck gets reset.

If I replace ‘x’,‘X’,‘o’(small o) to sth else, it gets no error.

The fields contain HTML, not just text, which is why if you use minimal regexes like o, it will also hit the markup.
For example colored text looks like this:

<font color="#123456">Some text</font>

So if you replace o with the emoji, it will look like this:

<f🟢nt c🟢l🟢r="#123456">S🟢me text</f🟢nt>

However you cannot use Unicode in the markup, which gives you this seemingly randomly mangled text.

There’s also no good way to only match outside of HTML tags with regular expressions. Could you show us what you are actually trying to replace? In which cases do you use O, and X?

3 Likes

I do use’O,o,ㅇ’ as a symbol of positive,
use ‘x,X’ as symbol of negative.

what I really wanted to do was to color ‘O,o,ㅇ’ green, ‘X,x’ orange. But it seems that I need to learn html to use that function, so I’ve decided to replace it to Emoji, instead of coloring them.

It’s interesting to hear from u.
Because, replacing small o to :green_circle: worked fine. It works fine, not like as u predicted it would malfunctions.

The Only big O to :green_circle: malfunctions.

If your theory is correct,small o to :green_circle: should also malfunction. Do you agree?
It seems quite odd to me.

This is an example of a card.
You might Notice bunch of O and X.
I do use them as a symbol of positive and negative

holy moly…! you were right.
all the x becomes :x:
But it still works fine!?

Yes that’s true. Judging from you last screenshot, you must have already replaced small “o” to capital “O” already at some point, because it says (for example) <fOnt cOlOr="#123456">. HTML markup is case-insensitive, which is why this did not break it.

You don’t seem to have any pattern with the “O” and “X” which we can exploit, which is unfortunate. At least I cannot think of a good regex that can help you out here. If those were my cards, at this point I would just leave them as is, and continue with emojis for all future cards I make (maybe make a new notetype), and leave the old ones as is.

2 Likes