This should be fixed in the next release. It looks like XenForo 2's built-in templater highlight function doesn't handle HTML content well. In the next release, we implement a wrapper function when the input is known to be HTML.
I should verify that the fix works for your example above when we test the new release on the live demo.