Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW

HTML: Syntax highlightning for perl-Code

by strat (Canon)
on Jul 24, 2003 at 11:39 UTC ( #277504=perlquestion: print w/replies, xml ) Need Help??
strat has asked for the wisdom of the Perl Monks concerning the following question:

Dear monks,

the people from (was in the past) want to make editing for german Perl-HowTo's much easier, and are looking for a script to automatically highlight the syntax of perl-code displayed in HTML (like some good editors do it).

Please, could you help me and give me some links if you know that somebody has already written something in that direction?

I want to avoid writing something like that if possible, because I have to code a lot in the moment, and can't use several days on this code in the moment.

Best regards,
perl -e "s>>*F>e=>y)\*martinF)stronat)=>print,print v8."

  • Comment on HTML: Syntax highlightning for perl-Code

Replies are listed 'Best First'.
Re: HTML: Syntax highlightning for perl-Code
by castaway (Parson) on Jul 24, 2003 at 11:54 UTC
Re: HTML: Syntax highlightning for perl-Code
by gjb (Vicar) on Jul 24, 2003 at 11:53 UTC

      Coincidentally, I just installed source-highlight today. Yes it does work for Perl, except it doesn't seem to recognise =cut so everything after the start of the first POD section gets flagged as a comment :-(

Re: HTML: Syntax highlightning for perl-Code
by RMGir (Prior) on Jul 24, 2003 at 11:59 UTC
    perltidy -html.

    Using the -nss option to suppress style sheets, and trimming out a few things:

    #!/usr/bin/perl -w
    use strict;
    for(1..2) {
        print "Hello, world #$_!\n";

Re: HTML: Syntax highlightning for perl-Code
by bobn (Chaplain) on Jul 24, 2003 at 12:07 UTC

    This looks promising:


    I've only played with this a little, just now. You'll want to read the doc.

    I've just used this command line:  perltidy -html -nss -html-color-keyword=ff000000 The doc says -nss should only be neeeded for older (per-NS4) browsers, but I didn't get color without it, even in Mozilla 1.2.1. However, the doc also advised not using the -html-color options and editting the style-sheet - it looks like if you don't want to edit the style-sheet, then using the -html-color and the -nss options are the way to go.

    Also, it produced some pecuoiar error messages. On the positive side, it sed pod2html, so also produced html for the pod sections. --Bob Niederman,

Re: HTML: Syntax highlightning for perl-Code
by naChoZ (Curate) on Jul 24, 2003 at 12:12 UTC
    This node from a previous thread is also relevent.


Re: HTML: Syntax highlightning for perl-Code
by Tommy (Chaplain) on Jul 25, 2003 at 05:09 UTC

    You can check out the Scintilla Project and it's free cross-platform editor with syntax higlighting support for many, many languages. It's written in C, so depending on your project you may be able to simply borrow it's Perl lexer.

    The free editor is called SciTE (Scintilla Text Editor) and it has the ability to export source code (in syntax-highlighted style) to HTML, RTF, PDF, and LaTeX formats. I use it to export syntax-highlighted Perl code in HTML when I post code at the ooOPps! Code Library.

    Tommy Butler, a.k.a. TOMMY
Re: HTML: Syntax highlightning for perl-Code
by adamk (Chaplain) on Jul 25, 2003 at 08:25 UTC

    It's a little slower, but you may also want to take a look at the PPI module.

    It currently works great for syntax highlighting, although it's eventually meant as a more general perl parser.

    Demos at

    (Yes, this is blatant self interest, but hey, it still handles perl syntax highlighting better than anything else I've ever seen)

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://277504]
Approved by gjb
Front-paged by broquaint
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (6)
As of 2017-08-21 22:50 GMT
Find Nodes?
    Voting Booth?
    Who is your favorite scientist and why?

    Results (325 votes). Check out past polls.