Fork me on GitHub

Luminous - A PHP Syntax Highlighter

Latest release: 19th May 2012 - v0.6.7-1

Luminous is a PHP syntax highlighter.

Its main focus is on accuracy and quality of code highlighting, and modern features like CSS colour themes. Luminous is a generic highlighter which can highlight around 30 source code languages, and includes a built-in cache so you don't have to worry about your server load. If you want professional, high quality PHP syntax highlighting for your website or blog, give it a try.

You can try it out here as an online syntax highlighter, and download if it you want to deploy it on your own site.

News

RSS RSS

Current

24th April 2012 - Luminous 0.6.7 Stable Release
0.6.7 brings a selection of bug fixes to the CSS scanner, a few improvements to JavaDoc style comment detection, and the ability to start line numbering at arbitrary numbers (thanks to Martin Sikora). Unconstrained HTML output's horizontal overflow has also been addressed and should now scroll.

Download

Bug reports to GitHub

This is likely to be the last relase of the 0.6.x tree and further releases will be numbered 0.7.x.

A few of the legacy leftovers will be shaken up, and the markup made a lot cleaner. This blog is currently using an early 0.7 version (see the previous entry to see a code block). If you want to use 0.7 early, feel free to checkout the branch from GitHub but beware instability.

The way I tend to do this is that the master branch should be stable (unit tests passed before committing) and that I make absolutely no guarantees about any other branch. At some point the stable existing 0.7 functionality will be merged back into master, but until then feel free to check it out but beware things may bre[...]

Read more

Archives

24th April 2012 - Luminous 0.6.7 Stable Release
0.6.7 brings a selection of bug fixes to the CSS scanner, a few improvements to JavaDoc style comment detection, and the ability to start line numbering at arbitrary numbers (thanks to Martin Sikora). Unconstrained HTML output's horizontal overflow has also been addressed and should now scroll.

Download

Bug reports to GitHub

This is likely to be the last relase of the 0.6.x tree and further releases will be numbered 0.7.x.

A few of the legacy leftovers will be shaken up, and the markup made a lot cleaner. This blog is currently using an early 0.7 version (see the previous entry to see a code block). If you want to use 0.7 early, feel free to checkout the branch from GitHub but beware instability.

The way I tend to do this is that the master branch should be stable (unit tests passed before committing) and that I make absolutely no guarantees about any other branch. At some point the stable existing 0.7 functionality will be merged back into master, but until then feel free to check it out but beware things may bre[...]

Read more

15th April 2012 - Luminous 0.7 development
Development has started on the 0.7 branch. One of the reasons for advancing the version number is because there are some changes that are going to be backwards incompatible, so this is a heads up.

0.7 will see a radical overhaul of the line numbering system and move it from generating the numbers in PHP to a pure CSS solution. Line numbers have always been a pain; the current solution is to place the numbers and code in two adjacent table cells (I've seen other highlighters do this too) because this solves a number of problems which otherwise occur. This markup is obviously not ideal. Line numbers are more meta or presentational than content and having them in the markup at all seems wrong, and no less so when that markup starts using tables for behaviour and presentation. From a practical point of view, search engines and presumably screen readers and so on have a hard time picking out what's important (the code) from what's not (the numbers), and appearing in Google with a summary consisting of a long list [...]

Read more

26th February 2012 - 0.6.6 Stable Release
0.6.6 is a relatively minor release that doesn't add any new exciting functionality, but clears up a few things which have been long overdue.

Firstly, Luminous should now work on PHP5.2.0 and above, with the caveat that early versions in the 5.2 tree will generate warnings under strict mode. This does not affect later 5.2 releases. This should be a plus to anyone forced to still support the whole 5.2 tree.

Secondly, the cache has slightly better error logging facilities. By default, Luminous is set to 'verbose' mode and will generate a PHP warning on a fatal cache problem. This is now configurable (via luminous::set('verbose', false). Furthermore, you can now more easily log cache problems for 'private' viewing (i.e. not broadcasting debugging information to your users) with the new luminous::cache_errors() function. See the cache docs for this one.

In the interests of full disclosure, a warning: Since 0.6.5 I've been working full time and have less time to spend on Luminous. Therefore with less testing time, I [...]

Read more

25th February 2012 - Luminous and PHP 5.2 compatibility
Some PHP 5.2.0 incompatibilities have recently been squashed and the changes will shortly be making it into a stable release (in the next week or so). For now, you can clone from GitHub, but the changes are so far largely untested.

Luminous should already be compatible with later releases from the PHP 5.2 tree, and you really shouldn't be running such an old PHP version anyway as it is now unsupported, but sometimes you don't have control over your hosting environment.[...]

Read more

The Luminous syntax highlighting plugin for CodeIgniter has been updated. It now uses Luminous 0.6.5 (refer to the 0.6.5 changelog to find out what that means), but more importantly, a small bug that could cause ugly PHP errors has been fixed.

Note that the plugin is not versioned (beyond Git) so the URL and filename are the same.

Instructions

Download [...]

Read more

15th October 2011 - 0.6.5 Stable Release
0.6.5 adds a number of things. In no particular order, the highlights are:

  • a new theme, Kimono, which is based on the more famous Monokai theme;
  • A version checking script;
  • Some small performance optimisations;
  • A 'plain' diff scanner;
  • And a number of language specific fixes in Django, Ruby, Bash, Perl and PHP.

Overall, the languages fixes in 0.6.5 makes Luminous an even better syntax highlighter than it was before and it is recommended that you upgrade. If you rely on diff highlighting, the diff scanner has been split into two. The previous mode (where embedded code was highlighted too) has been moved into 'diff-pretty'; 'diff' is now simply a plain highlighting mode, but it is less likely to be wrong and it's much faster. If you prefer the old behaviour, use 'diff-pretty'.

Full changelog

Download Luminous[...]

Read more

18th September 2011 - 0.6.4 Stable Release
0.6.4 has been released.

Highlights are:

  • A Django Scanner,
  • a new theme based on GitHub's syntax highlighting,
  • you can now use border-radius on the Luminous div element, and it should look okay,
  • a whole bunch of bug fixes in web language scanners, and some missing keywords added for Python

Everyone should definitely upgrade as the fixed bugs in the web languages were potentially fatal, although I'm not sure they were reachable.

Full changelog: http://luminous.asgaard.co.uk/assets/luminous/CHANGES.markdown

Download: http://luminous.asgaard.co.uk/index.php/download[...]

Read more

28th August 2011 - 0.6.3-1 Stable Release
0.6.3-1 was quietly released a few weeks ago.

To document it: it's a minor release which fixes a single bug in the caching system's timeout. The bug caused cache elements to be removed by default after 9 days of inactivity, rather than the more sensible (and intended) 90.

A cache element's activity is measured by the most recent cache hit for the element.

It is possible to override the timeout by calling

luminous::set('cache-age', $your_new_timeout_in_seconds);

As usual, setting it to -1 or 0 will disable the timeout.[...]

Read more

22nd June 2011 - 0.6.3 Stable Release
Version 0.6.3 of your favourite syntax highlighter is released. Get your copy from the download page.

0.6.3 brings two new features: Highlighting support for Ada code, and the ability to store your highlight cache in a MySQL table. Support for other databases will hopefully come in future. For information on how to do this, check out the cache page of the user documentation.

As well as this, there are a few small general fixes and small fixes for Perl, PHP, Python, and Ruby highlighting.

Full Changelog

As ever, please report problems to the issue tracker on GitHub.

Further, coinciding with this release, the Doxygen API docs are now available online

[...]

Read more

15th May 2011 - 0.6.2 Stable Release
0.6.2. is released. Get it from the download site.

0.6.2 sports three exciting new features: a command line interface, a full-page HTML formatter and language guessing. The full page HTML formatter can be accessed by setting the format option to 'html-full'. The language guessing you will find to be either scarily accurate or totally useless depending on what languages you use, but generally, if you're providing full or at least large source snippets of common languages it will be useful.

Be warned that internally the options API has been reworked and it now has some strict validation so you can't set any configuration settings to nonsensical values. If you try to set something nonsensical, it will throw an exception. Obviously, you should be doing a little integration testing before you upgrade any production machines anyway.

There are also a few language fixes for C, Diff, PHP, Ruby and SQL.

Full changelog

 

--

PS: the site is slow right now because the host is having YET MORE problems with its disk array. Un[...]

Read more

Example/Demo

 1 
 2 
 3 
 4 
 5 
 6 
 7 
 8 
 9 
 10 
<?php require_once('luminous/luminous.php'); ?>
<!DOCTYPE html>
<html>
  <head>
    <?= luminous::head_html(); // outputs stylesheet includes ?>
  </head>
  <body>
    <?= luminous::highlight('php', 'echo "hello world";'); ?>
  </body>
</html>