I’m with helhum. Symfony console component has something similar for colored command line output.
There you can use xml tags to add further “semantics” to parts of your output, e.g.
<info>. As mentioned before markdown and bb codes are the same.
Combined with Helmuts answer this means we should add special domain “language” to be handled?
We already have this in TYPO3 using parseFunc already in Fluid and TypoScript to define which tags are ok, combined with classes and further stuff. Still I don’t think we should use this feature in modern parts, instead we should use something new.
And as Helmut also pointed out, it should be independent from HTML, as possible output might be a json or xml response in a webservice or we might be in CLI context, which does not sound like a typical place for flash messages to me, but if we want to reuse code, they might get into further places and used in different contexts?