I use WordPress to power my blog. Because of the nature of its content, you may need to post LZX, HTML, XML or some other type of code into a comment. WordPress will not display this correctly if you simply paste XML into the comment.
To have the code in your comments appear correctly, follow these steps:
- XML-escape your code. That means that if you want to write <canvas>, you must escape it to <canvas>. Characters that should be escaped are < (which becomes <), > (which becomes >) and & (which becomes &).
- Wrap your code in <pre> tags. Do not escape the brackets (< and >) in the pre tags.
- Submit your comment.
This will display your code correctly, along with white space.
As always when typing into browsers, save what you write before submitting it – e.g. by copying to the clipboard – so that if something goes wrong, you don’t have to retype it.