Source for demo by Dominic Szablewski. See also description.
D=document,A='textarea',r='replace',p=[];D.body.innerHTML='<'+A+' id=t rows=10 cols=80>var syn="tax"; // hl</'+A+'><br><button onclick="h()">hl</button><pre id=p></pre>';function s(c,r){return '<span style="color:#'+c+'">'+(r||'$1')+'</span>'}function h(){D.getElementById('p').innerHTML=D.getElementById('t').value[r](/</g,'<')[r](/>/g,'>')[r](/\\\\/g,'<b')[r](/\\\//g,'<l')[r](/\\'/g,'<q')[r](/\\"/g,'<d')[r](/([\[({=:]\s*?)\/(?![\/\*])/g,'$1<r/')[r](/\/\*[\s|\S]*?\*\/|\/\/.*|<r\/.+?\/\w*|".*?"|'.*?'/g,function(m){return "r"+p.push(m)+">"})[r](/((&[lg]t;|[&\/+\-*=?:.,;()\[\]{}|%^!])+)/g,s('17b'))[r](/\b(break|case|catch|continue|default|delete|do|else|false|finally|for|function|if|in|instanceof|new|return|switch|this|throw|true|try|typeof|var|void|while|with)\b/gi,s('f0b'))[r](/\b(0x[\da-f]+|\d+)\b/g,s('d83'))[r](/r(\d+)>/g,function(m,n){b=p[n-1];return b.match(/^\/[\/*]/)?s('666',b):b.match(/^["']/)?s('719',b):s('6a0',b)})[r](/<r/g,"")[r](/<q/g,"\\'")[r](/<d/g,'\\"')[r](/<l/g,'\\/')[r](/<b/g,'\\\\')}h()