NAME

Apache::Syntax::Highlight::Perl - mod_perl 1.0/2.0 extension to highlight Perl code

SYNOPSIS

In httpd.conf (mod_perl 1):

PerlModule Apache::Syntax::Highlight::Perl

<FilesMatch "\.((p|P)(l|L|m|M)|t)$">
   SetHandler perl-script
   PerlHandler Apache::Syntax::Highlight::Perl
   PerlSetVar HighlightShowLineNumbers On
   PerlSetVar HighlightCSS http://path.to/highlight.css
</FilesMatch>

In httpd.conf (mod_perl 2):

PerlModule Apache2
PerlModule Apache::Syntax::Highlight::Perl

<FilesMatch "\.((p|P)(l|L|m|M)|t)$">
   SetHandler perl-script
   PerlResponseHandler Apache::Syntax::Highlight::Perl
   PerlSetVar HighlightShowLineNumbers On
   PerlSetVar HighlightCSS http://path.to/highlight.css
</FilesMatch>

DESCRIPTION

Apache::Syntax::Highlight::Perl is a mod_perl (1.0 and 2.0) module that provides syntax highlighting for Perl code. This module is a wrapper around Syntax::Highlight::Perl.

MOD_PERL 2 COMPATIBILITY

Apache::Syntax::Highlight::Perl is fully compatible with both mod_perl generations 1.0 and 2.0.

If you have mod_perl 1.0 and 2.0 installed on the same system and the two uses the same per libraries directory, to use mod_perl 2.0 version make sure to load first Apache2 module which will perform the necessary adjustements to @INC:

PerlModule Apache2
PerlModule Apache::Syntax::Highlight::Perl

Of course, notice that if you use mod_perl 2.0, there is no need to pre-load the Apache::compat compatibility layer.

INSTALLATION

In order to install and use this package you will need Perl version 5.005 or better.

Prerequisites:

  • mod_perl 1 or 2 (of course)

  • Syntax::Highlight::Perl >= 1.00

Installation as usual:

% perl Makefile.PL
% make
% make test
% su
  Password: *******
% make install

CONFIGURATION

In order to enable Perl file syntax highlighting you could modify httpd.conf or .htaccess files.

DIRECTIVES

You can control the behaviour of this module by configuring the following variables with PerlSetVar directive in the httpd.conf (or .htaccess files)

HighlightCSS string

This single directive sets the URL (or URI) of the custom CCS file.

PerlSetVar HighlightCSS /highlight/perl.css

It can be placed in server config, <VirtualHost>, <Directory>, <Location>, <Files> and .htaccess context.

The CSS file is used to define styles for all the syntactical elements that Syntax::Highlight::Perl currently recognizes.

For each style there is a correspondant syntactical element. The elements are:

Comment_Normal

Default is {color:#006699;font-style:italic;}

Comment_POD

Default is {color:#001144;font-family:garamond,serif;font-size:11pt;font-style:italic;}

Directive

Default is {color:#339999;font-style:italic;}

Label

Default is {color:#993399;font-style:italic;}

Quote

Default is {color:#0000aa;}

String

Default is {color:#0000aa;}

Subroutine

Default is {color:#998800;}

Variable_Scalar

Default is {color:#008800;}

Variable_Array

Default is {color:#ff7700;}

Variable_Hash

Default is {color:#8800ff;}

Variable_Typeglob

Default is {color:#ff0033;}

Whitespace

Not yet used

Character

Default is {color:#880000;}

Keyword

Default is {color:#000000; font-weight:bold;}

Builtin_Function

Default is {color:#000000; font-weight:bold;}

Builtin_Operator

Default is {color:#000000; font-weight:bold;}

Operator

Default is {color:#000000;}

Bareword

Default is {color:#33AA33;}

Package

Default is {color:#990000;}

Number

Default is {color:#ff00ff;}

Symbol

Default is {color:#000000;}

CodeTerm

Default is {color:#AA0000;}

DATA

Default is {color:#CCCCCC;}

LineNumber

This style hasn't a correspondant syntactical element but is used to display line numbers to the right of the code. Default is {color:#CCCCCC;}

See FORMAT TYPES section of Syntax::Highlight::Perl POD for more informations about elements currently recognized.

HighlightShowLineNumbers On|Off

This single directive displays line numbers to the right of the text

PerlSetVar HighlightShowLineNumbers On

It can be placed in server config, <VirtualHost>, <Directory>, <Location>, <Files> and .htaccess context. The default value is Off.

HighlightCache On|Off

This directive enables a very simple cache layer of already and unchanged highlighted files:

PerlSetVar HighlightCache On

Default is Off.

HighlightCacheDir string

This directive sets cache directory

PerlSetVar HighlightCacheDir /tmp/highlight

Default is /tmp.

RUN TIME CONFIGURATION

In addition, you can control the module behaviour at run time by adding some values via the query string. In particular:

download

Forces the module to exit with DECLINED status, for example by allowing users to download the file (according to Apache configuration):

http://myhost.com/myproject/sample.pl?download
showlinenumbers

Forces showing of code line numbers. For example:

http://myhost.com/myproject/sample.pl?showlinenumbers

BUGS

Please submit bugs to CPAN RT system at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Apache%3A%3ASyntax%3A%3AHighlight%3A%3APerl or by email at bug-apache-syntax-highlight-perl@rt.cpan.org

Patches are welcome and I'll update the module if any problems will be found.

VERSION

Version 1.01

TODO

  • Use of Cache::Cache:: family in order to cache highlighted files.

    back

SEE ALSO

Syntax::Highlight::Perl, Apache, IO::FIle, perl

AUTHOR

Enrico Sorcinelli, <enrico@sorcinelli.it>

COPYRIGHT AND LICENSE

Copyright (C) 2004 by Enrico Sorcinelli

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.2 or, at your option, any later version of Perl 5 you may have available.

1 POD Error

The following errors were encountered while parsing the POD:

Around line 452:

You forgot a '=back' before '=head1'