开发者

How can I serve up color-coded Java code using PHP?

开发者 https://www.devze.com 2023-01-01 19:32 出处:网络
I\'d like to embed code from my SVN repository into my website, using PHP. The SVN has public anonymous access, so t开发者_JAVA技巧he PHP code should be fine reading it.

I'd like to embed code from my SVN repository into my website, using PHP. The SVN has public anonymous access, so t开发者_JAVA技巧he PHP code should be fine reading it.

The code on said SVN is java, and so far I've had no luck finding a syntax-highlighter to make the code more readable. Ideally I'd like one that uses CSS classes so that I can change the colors to match the look of the website.

Could someone point me to a PHP library that highlights Java code?


Have you considered GeSHi? It supports a lot of languages including Java. You have to enable classes to use CSS classes.


Redmine or Trac can be connected to your SVN repo and will allow you to browse the contents with syntax highlighting. Both packages can be themed, and there are plenty of web sites that base the entire site on them.

GeSHi as recommended by Yacoby is also another option. I use that on my Drupal-based web site and it works quite well. It doesn't connect directly to a SVN repo though - for that you'd need a separate library. See http://www.petercarrero.com/content/2009/10/23/getting-php-bindings-subversion for an excellent blog entry that explains how to do this.

0

精彩评论

暂无评论...
验证码 换一张
取 消