How do I automatically detect text and format accordingly?

In Obsidian, you can bold something with four asterisks, italicise with two, use dollar signs for math, and equal signs to highlight.

However, I want Obsidian to detect when I put an ampersand symbol and a character after it, the character denoting the text color. For example:
&1 This text is blue.
&a This text is aqua.
&2 This text is green.
&b This text is lime.
&3 This text is yellow.
&c This text is gold.
&4 This text is orange.
&d This text is brown.
&5 This text is red.
&e This text is purple.

I also want the “formatting codes” to not be visible when colored text is not selected.

I made tooltips that appear on hover, and things like that, but I don’t know where to start when the problem involves automatically detecting text.

If anyone needs more clarity (which you will probably need), feel free to tell me!

My guess is that you will need a plugin to do this. A workaround that doesn’t require plugins is to use inline HTML.

<span style="color:red">This is red</span>

Yes, this will make your note messy, but at least it will satisfy the requirement:

I also want the “formatting codes” to not be visible when colored text is not selected.

I know how to do this. I have these macros on my Stream Deck:
span style=“color:rgb(195,0,0)”
span style=“color:rgb(0,195,0)”
span style=“color:rgb(255,100,240)”
span style=“color:rgb(54,195,255)”
span style=“color:rgb(55,55,55)”
/span

I just wanted a faster way.

You can add rules to the Typing Transformer plugin.