Quickie Trac Notes
- 3
- Add a Comment
Two quick notes for Trac users out there:
- I banged out all 33 lines of my first Trac plugin last night. The FlexJsPlugin allows Trac users to add JavaScript to the <head> block of their Trac-powered sites without needing to hack ClearSilver templates.
- For PHP source files to display in the Trac Browser with default PHP syntax highlighting colors, use this:
/* trac php syntax highlighting */ .code-block { line-height: 1em; font-family: Courier, monotype; font-size: 12px; } .h_question { color: #0000BB; } /* highlight.default */ .hphp_commentline { color: #FF8000; } /* highlight.comment */ .hphp_operator { color: #007700; } /* highlight.keyword */ .hphp_word { color: #007700; } /* highlight.keyword */ .hphp_default {} .hphp_variable { color: #0000BB; } /* highlight.default */ .hphp_hstring { color: #DD0000; } /* highlight.string */ .hphp_simplestring { color: #DD0000; } /* highlight.string */ .h_tagunknown {} .h_default {}
Drop the CSS in your project's site_css.cs file and you'll feel a little less like a stranger in a strange land. And while I haven't started playing too much with what some easily customizable JavaScript can bring to a Trac project, I'm looking forward to experimenting. Trac is great, but for all its coolness, it's lacking a bit in the area of today's JavaScript coolness.
3 Comments
John Herren
September 23rd, 2006
at 8:52pm
Which version of Trac are you running? I tried this on 0.9.6 and no dice. The css is coming through in the source, but my code isn’t marked up with those classes. Is there another config step, or are you using 0.10rc1?
Clay
September 24th, 2006
at 12:48am
Hey John,
You’re right — no dice with a default Trac, even 0.10rc1.
My notes are from a SilverCity-based PHP highlighting system, which I now realize is pretty uncommon.
A current Trac using php itself for syntax highlighting needs these rules:
.code-keyword { color: #007700; }
.code-lang { color: #0000BB; }
.code-comment { color: #FF8000; }
.code-string { color: #DD0000; }
… even those, however, are imperfect, as Trac’s “Deuglifier” that splits HTML into the row-numbered tables doesn’t catch the fact that PHP’s syntax highlighting output doesn’t mark each line … a multi-line comment only has opening and closing span tags surrounding the entire block, rather than a tag per line.
I’ll open up a ticket with Trac on that issue. In the meantime, the above rules are better than the defaults if you’re used to seeing PHP syntax coloring.
Clay
September 24th, 2006
at 8:14pm
Check out the follow-up post for the solution to this issue.
http://claylo.com/2006/09/24/php-mimeviewer-for-trac/