Hey!
Nested colour tags (or any tags of the same type, for that matter) are not part of STM... When I first started out programming it was because I didn't know how to do it, but now it's because I believe it's an easier pattern to use.
For example... lets say you want to type the string <c=red>R<c=orange>A<c=yellow>I<c=green>N<c=blue>B<c=violet>O<c=pink>W
To get back to normal text, in STM you'd just have to do </c>. But with nested tags, it's </c></c></c></c></c></c></c>. Another way to think about it is... every <c=x> tag essentially also works as an invisible </c> tag! This also makes it easier to pragmatically type text, since you don't have to remember how many layers of text formatting you're currently on. In addition to this reason, there's a lot of STM users by this point, so changing something like this would cause a lot of problems for a lot of people... I have considered it though.
For your situation, I'd recommend... When finishing the subitem highlighting, use <c=prevcolour> instead of </c>! Or if you are pragmatically generating the text, you can do a replacement script (or STM's pre-parsing loop!) to adjust your string before it's sent to STM. I have some sample code included for parsing custom tags, and I think I could adapt this so it formats numbers instead of tags in the same way.
So... the short answer is... Nested tags don't work because lots of people are using the current tag system, but there's other workarounds you can do to have a smooth typing experience!
If you need any additional programming help, please let me know.