Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

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 http://www.perl-community.de/ (was http://www.perl.de 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.8.8.32.11.32"

Comment on HTML: Syntax highlightning for perl-Code
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 castaway (Parson) on Jul 24, 2003 at 11:54 UTC
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:

    hello.pl


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

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

    This looks promising:

    perltidy

    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  somefile.pl 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, http://bob-n.com

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.

    ~~
    naChoZ

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

    http://ali.as/cgi-bin/CPAN/samples/PPI/syntax/cgi.pl

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

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://277504]
Approved by gjb
Front-paged by broquaint
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (14)
As of 2014-08-29 15:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (281 votes), past polls