I wrote a couple of packages that compute some text to insert into a buffer, and to make it look nice I wanted to add some syntax highlighting. Right now, what I've done is to come up with a "syntax" for my buffer that would allow me to create regexes for syntax highlighting. But actually, this is cumbersome. It would be great if the code that inserted the text into the buffer could specify the syntax highlighting to go alone with it.
Why is it cumbersome to come up with regexes? Well, I'm inserting tabular data that should be lined up nicely in columns. So I could use a column separator (the vertical bar, say) and use that to match the various columns. But what if I want to add or remove columns? Then I have to tweak all the regexes.
There must be other people with the same issue. Find in Files comes to mind -- it also computes text to insert into a buffer, then highlights it. What about SublimeLinter? That might just run an external command and interpret the output...
Hm. Is there a way to add markup to the buffer so that the regexes can interpret the markup, but the markup is then hidden so it's not visible to the user?