Last night, i checked a very cool piece of code into dojox. It goes by the name dojox.lang.highlight and provides syntax highlighting for a number of programming languages. The orig code was released BSD, and generously contributed under CLA by Ivan Sagalaev.
the test page can be seen here:
http://archive.dojotoolkit.org/nightly/dojotoolkit/dojox/highlight/tests...
it's tagged experimental mostly because there are stray globals being defined. The code works, but will be 'scoped down' some as to not pollute the global namespace. the API surface is public, but really only needs one function:
dojox.lang.highlight.init(node) to highlight a block of text in the dom. if parseOnLoad: true, if will do that automatically.
another change is it uses the dojo package system. you simply require in the languages you want to support via dojo.require() and the highlight "engine" takes care of the rest.
each language is it's own definition file, or there are groups for common uses, eg:
dojo.require("dojox.highlight.languages.php");// only php definitions
or dojo.require("dojox.highlight.langugages._dynamic"); // which is php, perl, html, etc
dojox.hightlight.languages._all mixes all the definitions supported in.
more optimizations will be coming to this great piece of code, getting rid of some of the code needed to normalize stuff between browsers (which dojo does for us to a degree) ... but this is the first "IPO" ... enjoy.
the author's site, and location of the orig code: http://softwaremaniacs.org/soft/highlight/en/
regards.
[edited]
been moved to dojox.highlight - standalone project ... code + all languages = 30k, 6k after gzip.

Amazing stuff!
Wonder if we could combine it with RichText/Editor to make the code editable? Hmmm...
there's an open ticket on a submission for something...
...just like that: http://trac.dojotoolkit.org/ticket/4832
though it doesn't use this highlighting code, iirc.
question about dependencies in dojox
Can I use dojox.highlight in a dojox project?
From the dojo book:
"The subprojects can rely on Dojo and Dijit code,
but they cannot reference (e.g. dojo.require) other subprojects in
Dojox"
Thanks!
nic
well, it's just a level of
well, it's just a level of separation/building blocks.
the Dojo Toolkit is:
Dojo Base + Dojo Core (dojo.js and everything else dojo) which is used to build
Dijit (all the dojo widgets), which can only include things from dojo + dijit. Then there is
Dojox - which is the rest of everything. you are free to use it anywhere, dojox can extend dijit or dojo or other dojox things) ... Its just a way to tell you that if you are not going to use dojox, you can safely remove most of it, and if you only want dojo methods, you don't even need the dijit stuff, and nothing depends on a "higher" project" in the build chain. Eg: dojo.string has methods, and is standalong. dojox.string extends that, and requires dojo.string, but dojo.string would work without dojox.string.
So, yes. you can use dojox.highlight in a project. It actually only needs dojo Core to function. just drop the highlight.js in your dojox/ folder, and the highlight/ tree next to it (dojox/highlight/...) and you should be good to go.
I was an idiot...
I told dante to put this in lang but on review, it really should be it's own thing--so it will be moved at some point in the near future.
duh.
yeh don't anyone get too
yeh don't anyone get too comfortable with the namespace, it's going into dojox.highlight, a single engine in it's own project.
just dojo.require("dojox.highlight.languages._all"); (or whatever) and then dojox.highlight.init(node) (or turn parseOnLoad:true);
Excellent! It makes much
Excellent! It makes much more sense to be in its own namespace rather than in dojox.lang, which was meant to be a collection of generic language-specific libraries for JavaScript.
As soon as I have some time on my hands I'll go over the code to remove stray globals if they are still there at that time. ;-)