I've made a language called CSTML to do some of this: https://docs.bablr.org/guides/cstml
Basically it's a text-based language for embedding semantic metadata into some kind of underlying text stream. Is this interesting to you?