Fork me on GitHub

Luminous - A PHP Syntax Highlighter

Latest release: 12th January 2013 - v0.7.0

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

12th January 2013 - Luminous 0.7.0 release

I finally got around to getting 0.7.0 out.

Highlights (pun):

  • SCSS (nested CSS) scanner
  • CSS and markup cleanup
  • Composer package
  • Licensing change, GPL => LGPL. In my eyes, using Luminous is akin to dynamic linking, and dynamic linking is okay by the GPL. But there is a certain amount of controversy around that. The LGPL is probably more appropriate in definite terms.

Download from the normal place.

Please note: the online demo will still use 0.6.7 for a while as I need to migrate the existing highlights to 0.7 (as the stylesheets are different).[...]

Read more

Archives

12th January 2013 - Luminous 0.7.0 release

I finally got around to getting 0.7.0 out.

Highlights (pun):

  • SCSS (nested CSS) scanner
  • CSS and markup cleanup
  • Composer package
  • Licensing change, GPL => LGPL. In my eyes, using Luminous is akin to dynamic linking, and dynamic linking is okay by the GPL. But there is a certain amount of controversy around that. The LGPL is probably more appropriate in definite terms.

Download from the normal place.

Please note: the online demo will still use 0.6.7 for a while as I need to migrate the existing highlights to 0.7 (as the stylesheets are different).[...]

Read more

Luminous 0.7 uses the brilliant (I thought) idea of using CSS counters and ::before pseudo-elements to add line-numbering to HTML output for Luminous, which cleaned and cut back the markup considerably. Unfortunately, as is often the way when you do something clever, there are some unforeseen problems, which are now holding up the process, and a satisfactory solution to all requirements is not obvious.

1) Clean code

Luminous 0.6 uses a table with one row and two cells - line numbers in the left cell, code in the right. HTML fascists (no offence, I'm one too) will scream at the thought of using a table for layout, but simply put, it works, and this is more than can be said for most alternatives. Let's be clear here: tables were used for layout originally because HTML didn't provide good means of doing common things, and we're using tables again because HTML doesn't provide good means of doing less common things. GitHub's brand of Pygments works in the same way, as does BitBuck[...]

Read more

6th September 2012 - More Luminous 0.7 ramblings

As I'm currently killing time from my slightly half-hearted job search while I am learning to drive (which in the UK is a major undertaking), I've been thinking about Luminous 0.7 and what I want it to do.

Firstly, 0.6 was a near-total rewrite about 18 months ago and 0.7 will be nowhere near the same level of change. That's because 0.6.x works pretty well. The core highlighting is awesome, and where it's not awesome, it's because I don't fully understand the language's grammar (see Bash and Ruby, forks/patches are welcome), not because Luminous is inherently crippled. 0.6 moved away from the idea that all languages should be abstracted into one single monolithic lexing algorithm and instead allows lexers to be individually written by hand. It works very well; it doesn't inflate the codebase much and it segregates complexity. It handles those awkward little special cases nicely, on which monolithic highlighters like GeSHi or many of the myriad JavaScript based highlig[...]

Read more

10th June 2012 - Luminous 0.6.7-1 and 0.6.7-2

These are very minor bugfix releases. Hopefully they clear up the strange scrollbar behaviour. These will hopefully be the final releases of the 0.6.x tree.

0.7 should condense a lot of the markup and therefore make problems like this less likely in future. The holy grail for the markup will be to (1) keep explicit line numbering out of the markup and (2) to allow the code-box to be horizontally scrollable without the line numbers disappearing out of the viewport. Both of these I consider important, but the way (1) is currently implemented appears incompatible with any nice solution for (2). Reddit has an interesting solution whereby it injects the entire set of line numbers as a single pseudo-element, (as opposed to each line injecting its own number as a ::before pseudo-element, which is how 0.7 does it now) but this probably isn't appropriate for Luminous because it's (probably) impossible to control the start-number, and it also means having '1 2 .. 999' hard coded in the CSS (which[...]

Read more

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 bewa[...]

Read more

Example/Demo

12345678910
<?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>