Live data from Hacker News

Rainbow.js - code syntax highlighting in 1.2kb

craig.is

1–10 of 34 posts

Re: Rainbow.js - code syntax highlighting in 1.2kb

#4
post #2

Rainbow["onHighlight"] = Rainbow.onHighlight; Isn't that line useless since `obj['property'] == obj.property` is always true? https://github.com/ccampbell/rainbow/blob/master/js/rainbow....

No, it's not useless when it comes to advanced minimization when Rainbow.onHighlight might be minimized to Rainbox.a. By doing Rainbow['onHighlight'] ensures a method called onHighlight exists on the Rainbow object.

Re: Rainbow.js - code syntax highlighting in 1.2kb

#5
post #2

Rainbow["onHighlight"] = Rainbow.onHighlight; Isn't that line useless since `obj['property'] == obj.property` is always true? https://github.com/ccampbell/rainbow/blob/master/js/rainbow....

This is because I'm using Google Closure Compiler in advanced mode so all methods that do not get used get renamed.

In order to preserve the methods and keep them public you have to reference them like this.

Re: Rainbow.js - code syntax highlighting in 1.2kb

#7
post #6

This looks like a very worthy replacement for http://code.google.com/p/google-code-prettify/ I can't see the license specified anywhere, any chance you could add a LICENSE file or similar?

It's under Apache 2.0. Just not specified in a LICENSE file yet.

https://github.com/ccampbell/rainbow/blob/master/js/rainbow....

Re: Rainbow.js - code syntax highlighting in 1.2kb

#8
post #7
post #6

This looks like a very worthy replacement for http://code.google.com/p/google-code-prettify/ I can't see the license specified anywhere, any chance you could add a LICENSE file or similar?

It's under Apache 2.0. Just not specified in a LICENSE file yet. https://github.com/ccampbell/rainbow/blob/master/js/rainbow....

Ah, thanks, didn't spot that.

Re: Rainbow.js - code syntax highlighting in 1.2kb

#10
post #9

Is there a way to style dynamically inserted blocks (say inserted via an ajax call) after the page loads? I did not see an equivalent of the prettify() function of google-code-prettify that lets you do this. Looks great otherwise.

Looks to me like Rainbow.init() would do it.
Post reply on HN