Created
August 7, 2010 17:43
-
-
Save leegao/513014 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// A Simple Javascript syntax highlighted Editor within 1023 bytes (< 1Kb) | |
// Demo: http://failboat.me/jpad.html | |
(d=document).write('<style>#p,#d{text-shadow:0 0 20px #39E;top:0;left:0;white-space:pre;color:#756;width:100%;height:100%;padding:10px;border:none;line-height:20px;position:absolute;background:transparent;font:14px "Courier New"}#p{opacity:0.4}</style><div id="d">JS</div><textarea id="p"></textarea>');p=d[g="getElementById"]("p");n="length";function j(b,a){l=[];for(_ in a){i=0;$=a[_];for(m=b.match(a[_]);$.test(b);)l.push([$.lastIndex-m[i][n],m[i++][n],_])}l.sort(function(c,f){return c[0]+1/c[1]-f[0]-1/f[1]});h=0;z=[];for(_ in l){$=l[_];e=$[0]+$[1];if(!(e<=h)){z.push([h,$[0]-h,g],$);h=e}}z.push([h,b[n],g]);return z}p.onkeyup=function(){var b=d[g]("d"),a=p.value;t=j(a,{"#288;border-bottom:dashed 1px #ccc":/\/\/.*|\/\*(.|\n)+\*\//g,"#D24":/"[^"\n]*"|'[^'\n]*'/g,"#08c":/\b(else|switch|break|throw|case|catch|new|finally|null|try|const|for|continue|function|var|if|return|delete|while|do|with|in)(?!\w)/g});s="";for(i in t){y=t[i];s+="<span style='color:"+y[2]+"'>"+a[ss="substr"](y[0],y[1])+"</span>"}b.innerHTML=s} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Final submission, which was just shy of full compliance with regex due to 13 bytes.
http://js1k.com/2010-first/source/817