I've been approaching a similar problem, recently, in trying to represent my javascript node-graph elements as plain text. Very different output and use case, but I settled on the same kind of "psuedo-selector" idea that you seem to have. Hash to tag id's, wrappers to allow for complex content, and I even went as far as to use query string format to allow for dynamic event raising (when a node is hit, I can trigger an event with a key and value pair).
I can show a video of it, if it's of interest, but I don't think there's much I can help recommend. This comment is just to say that I like what you're doing and have found myself in a similar situation so I'll be very eager to hear what the community has to say about your project!