function escape(html) {
        return html.replace(/[<|>|&]/g, function (match) {
            switch (match) {
                case '<': return '&lt;';
                case '>': return '&gt;';
                case '&': return '&amp;';
                default: return match;
            }
        });
    }
Converts HTML characters inside the string to use entities instead. Makes the string safe from
being used e.g. in HTMLElement.innerHTML.