Tweet sized syntax highlighter

An idea I’ve been throwing around since the first JS1k programming competition was to see if it would be possible to build a javascript syntax highlighter of some form that could fit in a single tweet. (In the first event, there was additional credit given to tweetable code.)

I’ve been able to make something that works in Chrome, although it will take some further work to get it cross browser.

b[t='innerHTML']='<hr id=y><p id=z contenteditable>';f='y[t]=z[t]';for(p in b)f+='.replace(/'+p+'/ig,"<b>$&</b>")';z.onkeyup=eval.bind(b,f)

See it in action!

Published
Categorized as Post