Declaration of VAR

and some other stuff

Escape HTML for highlighting

2016-07-12 10:56:33 +0200

2016-07-12 10:56:33 +0200 | Comments

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.