PHP MimeViewer for Trac
- 4
- Add a Comment
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:
.code-keyword { color: #007700; }
.code-lang { color: #0000BB; }
.code-comment { color: #FF8000; }
.code-string { color: #DD0000; }
… 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
PHPDeveloper.org
September 25th, 2006
at 4:37am
Clay Loveless’ Blog: PHP MimeViewer for Trac…
…
Ed Finkler
September 26th, 2006
at 6:30am
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.
rodrigo moraes
October 14th, 2006
at 4:13pm
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.
Clay
October 14th, 2006
at 6:54pm
Download link is fixed now, sorry about that — caused by a server move.