Syntax Highlighting libraries
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 <christoph.burschka [at] rwth-aachen.de>
Math.-Techn. Assistent i.A.
Re: Syntax Highlighting libraries
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
Re: Syntax Highlighting libraries
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!
Re: Syntax Highlighting libraries
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
Re: Syntax Highlighting libraries
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. ;)
>
>
Re: Syntax Highlighting libraries
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
Re: Syntax Highlighting libraries
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!
Re: Syntax Highlighting libraries
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
Re: Syntax Highlighting libraries
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. ;)
>
>
Re: Syntax Highlighting libraries
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.
Re: Syntax Highlighting libraries
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.
Re: Syntax Highlighting libraries
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/
Re: Syntax Highlighting libraries
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/
Re: Syntax Highlighting libraries
jef [at] 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
Re: Syntax Highlighting libraries
jef [at] 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
Re: Syntax Highlighting libraries
On Apr 3, 2:21 am, Christoph Burschka <christoph.bursc... [at] rwth-
aachen.de> wrote:
> 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.
Re: Syntax Highlighting libraries
On Apr 3, 2:21 am, Christoph Burschka <christoph.bursc... [at] rwth-
aachen.de> wrote:
> 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.
Re: Syntax Highlighting libraries
Grigory Temchenko schrieb:
> On Apr 3, 2:21 am, Christoph Burschka <christoph.bursc... [at] rwth-
> aachen.de> wrote:
>
>>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
Re: Syntax Highlighting libraries
Grigory Temchenko schrieb:
> On Apr 3, 2:21 am, Christoph Burschka <christoph.bursc... [at] rwth-
> aachen.de> wrote:
>
>>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
Re: Syntax Highlighting libraries
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
Re: Syntax Highlighting libraries
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.
Re: Syntax Highlighting libraries
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
Re: Syntax Highlighting libraries
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.
PHP » alt.php » Syntax Highlighting libraries