PPI::HTML - Generate syntax-hightlighted HTML for Perl using PPI
use PPI; use PPI::HTML; # Load your Perl file my $Document = PPI::Document->load( 'script.pl' ); # Create a highlighter my $Highlight = PPI::HTML->new( $Document, line_numbers => 1 ); # Spit out the HTML print $Highlight->html;
PPI::HTML is the successor to the non-redundant PPI::Format::HTML.
While early on it was thought that the same formatting code might be able to be used for a variety of different types of things (ANSI and HTML for example) later developments with the here-doc code and the need for independantly written serializers meant that this idea had to be discarded.
In addition, the old module only made use of the Tokenizer, and had a pretty shit API to boot.
The new module is much cleaner. Simple create an object with the options you want and pass PPI::Document objects to the html method, and you get strings of HTML.
html
The new constructor takes a simple set of key/value pairs to define the formatting options for the HTML.
new
At the present time, the only option available. If set to true, line numbers are added to the output.
Returns a new PPI::HTML object
The main method for the class, the html method takes a single PPI::Document object, and returns a string of HTML formatted based on the arguments given to the PPI::HTML constructor.
Returns a string, or undef on error.
undef
Bugs should always be submitted via the CPAN bug tracker
http://rt.cpan.org/NoAuth/ReportBug.html?Queue=PPI%3A%3AHTML
For other issues, contact the maintainer
Adam Kennedy (Maintainer), http://ali.as/, cpan@ali.as
Funding provided by The Perl Foundation
Copyright (c) 2005 Adam Kennedy. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
The full text of the license can be found in the LICENSE file included with this module.
To install PPI::HTML, copy and paste the appropriate command in to your terminal.
cpanm
cpanm PPI::HTML
CPAN shell
perl -MCPAN -e shell install PPI::HTML
For more information on module installation, please visit the detailed CPAN module installation guide.