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

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>

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.

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.

In order to install and use this package you will need Perl version 5.005 or better.
Prerequisites:
Installation as usual:
% perl Makefile.PL
% make
% make test
% su
Password: *******
% make install

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

You can control the behaviour of this module by configuring the following variables with PerlSetVar directive in the httpd.conf (or .htaccess files)
HighlightCSS stringThis 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:
Default is {color:#006699;font-style:italic;}
Default is {color:#001144;font-family:garamond,serif;font-size:11pt;font-style:italic;}
Default is {color:#339999;font-style:italic;}
Default is {color:#993399;font-style:italic;}
Default is {color:#0000aa;}
Default is {color:#0000aa;}
Default is {color:#998800;}
Default is {color:#008800;}
Default is {color:#ff7700;}
Default is {color:#8800ff;}
Default is {color:#ff0033;}
Not yet used
Default is {color:#880000;}
Default is {color:#000000; font-weight:bold;}
Default is {color:#000000; font-weight:bold;}
Default is {color:#000000; font-weight:bold;}
Default is {color:#000000;}
Default is {color:#33AA33;}
Default is {color:#990000;}
Default is {color:#ff00ff;}
Default is {color:#000000;}
Default is {color:#AA0000;}
Default is {color:#CCCCCC;}
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|OffThis 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|OffThis directive enables a very simple cache layer of already and unchanged highlighted files:
PerlSetVar HighlightCache On
Default is Off.
HighlightCacheDir stringThis directive sets cache directory
PerlSetVar HighlightCacheDir /tmp/highlight
Default is /tmp.

In addition, you can control the module behaviour at run time by adding some values via the query string. In particular:
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
Forces showing of code line numbers. For example:
http://myhost.com/myproject/sample.pl?showlinenumbers

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 1.01

back

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

Enrico Sorcinelli, <enrico@sorcinelli.it>

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.