PHP MimeViewer for Trac

As John Herren pointed out in the comments to yesterday's post, my suggestion for PHP syntax coloring wasn't working for several versions of Trac.

After a little digging, it turned out that my CSS rules were based on the non-standard SilverCity highlighting output, rather than the newer and more common native PHP highlighting.

While reviewing the output from the native PHP highlighter, I noticed that Trac's manipulation of the output from highlight_string() isn't quite right. The way things are now, as of Trac 0.10rc1, an intended multi-line docblock only has the first "/**" highlighted as a comment ... the rest of the docblock is highlighted as default PHP (the code-lang class).

I've been clamoring for good PHP syntax coloring output in Trac for a long time. Rather than pass the buck and put this on the Trac team, I've released a little PHP-based shell script called php_mimeview.

With php_mimeview installed, simply update the [mimeviewer] config section of trac.ini in your Trac project to point php_path to the full path location of php_mimeview. With that script, plus these rules in your site_css.cs template file:

[source language=":css"]
.code-keyword { color: #007700; }
.code-lang { color: #0000BB; }
.code-comment { color: #FF8000; }
.code-string { color: #DD0000; }
[/source]

... you'll get what you're probably used to seeing in syntax-highlighted PHP code.

Thanks to John Herren for the nudge to investigate this further.

4 Comments

Clay Loveless’ Blog: PHP MimeViewer for Trac…

One thing on pearified: I was able to add the channel fine, but I get an error when trying to list the packages:

> pear list-all -c pearified.com
File http://pearified.com:80/Chiara_PEAR_Server_REST/c/categories.xml not valid (received: HTTP/1.1 404 Not Found
)

oh, and drop me a line sometime — I’m trying to keep in better touch with my PHP bretheren.

Clay,
I was looking for a solution for the PHP syntax highlighting on Trac, and look what I’ve found! :)

The link to download the file from Pearified is broken, though.

Download link is fixed now, sorry about that — caused by a server move.

Additional comments powered by BackType