Luminous is an accurate and style-able syntax highlighter for PHP which supports a bunch of common languages and output to HTML and LaTeX.
If you simply want to use Luminous as a library, please don't clone this repository. Or if you do, make sure you delete luminous/tests afterwards. Do not expose luminous/tests on a public machine. It is recommended to get a packaged version from the links below.
Extract your tarball, zip, whatever, into some directory where it's going to be used (i.e. probably your web-server). We'll assume it's called `luminous/'
First, if you're going to use caching, which you probably are, create a directory called luminous/cache and give it writable permissions (chmod 777 on most servers -- yours may accept a less permissive value). Then include luminous/luminous.php and away you go!
1234 | <?php require_once 'luminous/luminous.php'; echo luminous::head_html(); // outputs CSS includes, intended to go in <head> echo luminous::highlight('c', 'printf("hello world\n");'); |
Useful examples can be found in luminous/examples/. If you have problems, check that luminous/examples/example.php works.
If you're crazy and want to use Luminous/PHP on the command line, guess what, you can!
12 | $ cd luminous/ $ php luminous.php --help |
Luminous is fairly slow. But it caches! So it's not slow. Or is it?
It depends on your use-case, is the simple answer. Most people should make sure the cache works (create luminous/cache with appropriate permissions), and after that, Luminous will almost certainly have negligable impact on their performance.
Optimizations are welcome, but not at the expense of maintainability.
The cache can be stored either directly on the file system or in a MySQL table (support for other DBMSs will come later, patches welcome). In either case, check out the cache documentation.
Luminous is distributed under the LGPL but includes a bunch of stuff which is separate.