I do the text parsing and formatting in my plugin.
So you mean are actually writing a custom lexer? If so then you might want to look at some other lexers people have created and see how they are doing it. In general a lexer assigns a style number to each character and then that style number has color/font/underline/bold/etc associated with it.
I tried the UDL but couldn’t come up with a solution.
I’ve never use UDL so I can’t be of any help here. :)