When you are trying to highlight some code that contains special characters, this can mess up your markup. So you need to escape some characters first, for example replace all < and > with &lt; and &gt;. I used this page to find the codes.

I’ve had enough of copy-paste-replace-this-replace-that-copy-paste, so I created a page of my own that does at least replacing part:

Escape your HTML for highlighting

The core of the replacing mechanism is this RegEx:


It can also re-escape the result, sometimes it can eventually escape unescaped. You can do it by pressing the button with the in the middle.

You can see, that it escapes only pretty basic stuff, so don’t rely on it in any somewhat difficult cases.