By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,600 Members | 1,683 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,600 IT Pros & Developers. It's quick & easy.

Syntax Highlighting libraries

P: n/a
Are there any free PHP libraries/utility functions that can color the syntax of
various programming languages (eg. Java and C++)?

I am posting code snippets on my site and would like to know if there is a way
to easily give them syntax highlighting automatically.

Thanks!

--
Christoph Burschka <ch****************@rwth-aachen.de>
Math.-Techn. Assistent i.A.
Apr 2 '07 #1
Share this Question
Share on Google+
11 Replies


P: n/a
Christoph Burschka wrote:
Are there any free PHP libraries/utility functions that can color the syntax of
various programming languages (eg. Java and C++)?

I am posting code snippets on my site and would like to know if there is a way
to easily give them syntax highlighting automatically.

Thanks!
There is a PEAR class Text_Highlighter which provides a framework in
which XML based files per language are parsed to highlight code. Not
sure if someone has already build the XML files for the languages you
are looking for. May Google be your best friend!

HTH

Sh
Apr 3 '07 #2

P: n/a
Christoph Burschka wrote:
Are there any free PHP libraries/utility functions that can color the
syntax of various programming languages (eg. Java and C++)?
GeSHi and PEAR Text_Highlighter each cover plenty of languages. There's
significant overlap between them; when a language is covered by both, the
Text_Highlighter output is usually a bit nicer.
I am posting code snippets on my site and would like to know if there is
a way to easily give them syntax highlighting automatically.
Take a look at my demitextile class <http://demiblog.org/etc/demitextile/>.
It combines syntax highlighting (via GeSHi, Text_Highlighter and some
built-in) with smart quotes and the Textile markup language
<http://textism.com/tools/textile/>.

Example:
http://examples.tobyinkster.co.uk/demitextile-usage1
http://examples.tobyinkster.co.uk/demitextile-output1

Note that it's smart enough to detect when you've embedded CSS, Javascript
and PHP within some HTML, and switches syntax highlighting mode
accordingly.

--
Toby A Inkster BSc (Hons) ARCS
Contact Me ~ http://tobyinkster.co.uk/contact
Geek of ~ HTML/SQL/Perl/PHP/Python*/Apache/Linux

* = I'm getting there!
Apr 3 '07 #3

P: n/a
Schraalhans Keukenmeester wrote:
Christoph Burschka wrote:
There is a PEAR class Text_Highlighter which provides a framework in
which XML based files per language are parsed to highlight code. Not
sure if someone has already build the XML files for the languages you
are looking for. May Google be your best friend!

HTH

Sh
Thanks very much, I'll see if that helps me.

I tried using Google, but it's really tricky to search for some terms.
Apparently, coloring the syntax of *PHP* scripts in *Java* applications is a far
more common task than the other way around, so "syntax+color+php+java" isn't
exactly helpful. ;)
--
Christoph Burschka
Apr 3 '07 #4

P: n/a
jef
I've tryed Text_Hilighter before, seemed to be the 1 and only PEAR
extension that I've had trouble with, I'm not however, ruling out the
fact it could have been the dodgey gentoo vserver i'm running that
particular website under... I was just getting a silly error that the
actual highlight function wasn't recognized, however the factory
function was. tt.

Good luck
-jef

Christoph Burschka wrote:
Schraalhans Keukenmeester wrote:
>Christoph Burschka wrote:
There is a PEAR class Text_Highlighter which provides a framework in
which XML based files per language are parsed to highlight code. Not
sure if someone has already build the XML files for the languages you
are looking for. May Google be your best friend!

HTH

Sh

Thanks very much, I'll see if that helps me.

I tried using Google, but it's really tricky to search for some terms.
Apparently, coloring the syntax of *PHP* scripts in *Java* applications is a far
more common task than the other way around, so "syntax+color+php+java" isn't
exactly helpful. ;)

Apr 3 '07 #5

P: n/a
Christoph Burschka wrote:
Are there any free PHP libraries/utility functions that can color the syntax of
various programming languages (eg. Java and C++)?

I am posting code snippets on my site and would like to know if there is a way
to easily give them syntax highlighting automatically.

Thanks!
Bumped into another one for you. (Old!)
http://www.0php.com/PHP-source-code-utility.php

Designed for PHP4, written in 2002, perhaps still a good starting point...

Rgds
Sh.
Apr 8 '07 #6

P: n/a
Schraalhans Keukenmeester wrote:
Christoph Burschka wrote:
>Are there any free PHP libraries/utility functions that can color the syntax of
various programming languages (eg. Java and C++)?

I am posting code snippets on my site and would like to know if there is a way
to easily give them syntax highlighting automatically.

Thanks!
Bumped into another one for you. (Old!)
http://www.0php.com/PHP-source-code-utility.php

Designed for PHP4, written in 2002, perhaps still a good starting point...

Rgds
Sh.
GeSHI - http://qbnz.com/highlighter/
Apr 12 '07 #7

P: n/a
je*@w3z.co.uk wrote:
I've tryed Text_Hilighter before, seemed to be the 1 and only PEAR
extension that I've had trouble with, I'm not however, ruling out the
fact it could have been the dodgey gentoo vserver i'm running that
particular website under... I was just getting a silly error that the
actual highlight function wasn't recognized, however the factory
function was. tt.

Good luck
-jef

Christoph Burschka wrote:
>Schraalhans Keukenmeester wrote:
>>Christoph Burschka wrote:
There is a PEAR class Text_Highlighter which provides a framework in
which XML based files per language are parsed to highlight code. Not
sure if someone has already build the XML files for the languages you
are looking for. May Google be your best friend!

HTH

Sh
Thanks very much, I'll see if that helps me.

I tried using Google, but it's really tricky to search for some terms.
Apparently, coloring the syntax of *PHP* scripts in *Java* applications is a far
more common task than the other way around, so "syntax+color+php+java" isn't
exactly helpful. ;)

I've managed to get Text_Highlighter to work (and even made a new XML
description for a scripting language, which it generated a highlighting class
from). It works very well, thanks!

--cb
Apr 21 '07 #8

P: n/a
On Apr 3, 2:21 am, Christoph Burschka <christoph.bursc...@rwth-
aachen.dewrote:
Are there any free PHP libraries/utility functions that can color the syntax of
various programming languages (eg. Java and C++)?
You can use http://softwaremaniacs.org/soft/highlight/en/
That's very easy to use library and it don't need PHP. You just drop
few lines of JavaScript on your page and it's work.

Apr 25 '07 #9

P: n/a
Grigory Temchenko schrieb:
On Apr 3, 2:21 am, Christoph Burschka <christoph.bursc...@rwth-
aachen.dewrote:
>>Are there any free PHP libraries/utility functions that can color the syntax of
various programming languages (eg. Java and C++)?


You can use http://softwaremaniacs.org/soft/highlight/en/
That's very easy to use library and it don't need PHP. You just drop
few lines of JavaScript on your page and it's work.
But between a Javascript and a PHP solution, I'd say server-side is the
more desirable. After all, my CMS (Drupal) can cache the filter output
of the PHP function, and therefore has minimal resource use, compared to
forcing every user to run the parser in their browser.

Not to speak of browser compatibility and accessibility, of course...

--
cb
Apr 26 '07 #10

P: n/a
Christoph Burschka wrote:
Are there any free PHP libraries/utility functions that can color the syntax of
various programming languages (eg. Java and C++)?

I am posting code snippets on my site and would like to know if there is a way
to easily give them syntax highlighting automatically.

Thanks!
This is not exactly what you asked for

http://www.gnu.org/software/src-highlite/

but in the near future I want to extend it in order to generate php
highlighter so you might want to keep an eye on it :-)

--
Lorenzo Bettini, PhD in Computer Science, DSI, Univ. di Firenze
ICQ# lbetto, 16080134 (GNU/Linux User # 158233)
HOME: http://www.lorenzobettini.it MUSIC: http://www.purplesucker.com
BLOGS: http://tronprog.blogspot.com http://longlivemusic.blogspot.com
http://www.gnu.org/software/src-highlite
http://www.gnu.org/software/gengetopt
http://www.gnu.org/software/gengen http://doublecpp.sourceforge.net
May 31 '07 #11

P: n/a
Lorenzo Bettini wrote:
Christoph Burschka wrote:
>Are there any free PHP libraries/utility functions that can color the
syntax of
various programming languages (eg. Java and C++)?

I am posting code snippets on my site and would like to know if there
is a way
to easily give them syntax highlighting automatically.

Thanks!

This is not exactly what you asked for

http://www.gnu.org/software/src-highlite/

but in the near future I want to extend it in order to generate php
highlighter so you might want to keep an eye on it :-)
VIM comes with highlighting for almost all programming languages.
May 31 '07 #12

This discussion thread is closed

Replies have been disabled for this discussion.