This is a more "Qt" way of highlighting syntax, and works around the problems of #4199 without resorting to complicated html escaping. The tests are more straightforward with less mocking, but do involve testing a private class.