Monday, January 05, 2009

JavaScript: Escape text with HTML entries

When I post some code snippets into this website, often there is a problem with html tags or symbols present in the code. The most common examples are greater and lower symbols: <,>. For that reason I wrote simple html form and some JavaScript that escapes html tags or symbols.

Input text:


Remove double End of Line characters

Escaped text:

Download

The script can be downloaded from here.

Alternative script

I also found alternative site that can escape HTML. However, on that site it is not possible to choose whether double end of line characters are removed or not.