Syntax Highlighting libraries

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Christoph Burschka

    #1

    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.burs chka@rwth-aachen.de>
    Math.-Techn. Assistent i.A.
  • Schraalhans Keukenmeester

    #2
    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_Highlighte r 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

    Comment

    • Toby A Inkster

      #3
      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_Highlighte r each cover plenty of languages. There's
      significant overlap between them; when a language is covered by both, the
      Text_Highlighte r 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_Highlighte r and some
      built-in) with smart quotes and the Textile markup language
      <http://textism.com/tools/textile/>.

      Example:



      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!

      Comment

      • Christoph Burschka

        #4
        Re: Syntax Highlighting libraries

        Schraalhans Keukenmeester wrote:
        Christoph Burschka wrote:
        There is a PEAR class Text_Highlighte r 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+p hp+java" isn't
        exactly helpful. ;)


        --
        Christoph Burschka

        Comment

        • jef@w3z.co.uk

          #5
          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_Highlighte r 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+p hp+java" isn't
          exactly helpful. ;)
          >
          >

          Comment

          • Schraalhans Keukenmeester

            #6
            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!)


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

            Rgds
            Sh.

            Comment

            • Craig Storey

              #7
              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!)

              >
              Designed for PHP4, written in 2002, perhaps still a good starting point...
              >
              Rgds
              Sh.
              GeSHI - http://qbnz.com/highlighter/

              Comment

              • Christoph Burschka

                #8
                Re: Syntax Highlighting libraries

                jef@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_Highlighte r 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+p hp+java" isn't
                >exactly helpful. ;)
                >>
                >>
                I've managed to get Text_Highlighte r 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

                Comment

                • Grigory Temchenko

                  #9
                  Re: Syntax Highlighting libraries

                  On Apr 3, 2:21 am, Christoph Burschka <christoph.burs c...@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.

                  Comment

                  • Christoph Burschka

                    #10
                    Re: Syntax Highlighting libraries

                    Grigory Temchenko schrieb:
                    On Apr 3, 2:21 am, Christoph Burschka <christoph.burs c...@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

                    Comment

                    • Lorenzo Bettini

                      #11
                      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



                      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/gengen http://doublecpp.sourceforge.net

                      Comment

                      • Bob Stearns

                        #12
                        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
                        >

                        >
                        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.

                        Comment

                        Working...