I have half-way-decent syntax highlighting working now, using a kind of hybrid of regular expression matches, start-end matches, and testing the existing format of text which has already been highlighted. I think this will do for the moment. The only problems arise when attribute+value structures are split across multiple lines. I think we can live with that for the moment.
In the process, I discovered how to convert text documents from UTF-8 using QTextCodec. This is simple enough, but I'll ultimately need to figure out how to detect encodings. I'll do a bit of research on this.