/usr/bin/ppi2html is in libppi-html-perl 1.08-1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 | #!/usr/bin/perl
eval 'exec /usr/bin/perl -S $0 ${1+"$@"}'
if 0; # not running under some shell
# Converts Perl to HTML using PPI::HTML
use strict;
use File::Slurp ();
use PPI;
use PPI::HTML;
use CSS::Tiny;
# Get the file
my $file = shift @ARGV;
$file or barf("File '$file' not provided");
-f $file or barf("File '$file' does not exist");
# Determine the output file
my $output = @ARGV ? shift(@ARGV) : $file . '.html';
print "Reading $file...\n";
my $Document = PPI::Document->new( $file )
or barf("File '$file' could not be loaded as a document");
# Set up some custom CSS properties
my $CSS = CSS::Tiny->new;
$CSS->{body}->{'font-family'} = 'Courier New, Courier, mono';
$CSS->{body}->{'font-size'} = '10pt';
# Create the PPI::HTML object
my $HTML = PPI::HTML->new(
line_numbers => 1,
page => 1,
css => $CSS,
colors => {
# Standard token classes
pod => '#008080',
comment => '#008080',
operator => '#DD7700',
single => '#999999',
double => '#999999',
literal => '#999999',
interpolate => '#999999',
words => '#999999',
regex => '#9900FF',
match => '#9900FF',
substitute => '#9900FF',
transliterate => '#9900FF',
number => '#990000',
magic => '#0099FF',
cast => '#339999',
# Special classes
pragma => '#990000',
keyword => '#0000FF',
core => '#FF0000',
line_number => '#666666',
},
)
or barf("Failed to create HTML syntax highlighter");
# Process the file
my $content = $HTML->html( $Document )
or barf("Failed to generate HTML");
$content =~ s/\t/ /gs;
$content =~ s/<br>//gs;
File::Slurp::write_file( $output, $content );
print "Saved HTML to $output\n";
exit(0);
# Support Functions
sub barf {
my $msg = shift;
print $msg . "\n";
exit(1);
}
|