PPI::HTML3pm
Generate syntax-hightlighted html for perl using ppi
Usage
use PPI;use PPI::HTML;# Load your Perl filemy $Document = PPI::Document->load( 'script.pl' );# Create a reusable syntax highlightermy $Highlight = PPI::HTML->new( line_numbers => 1 );# Spit out the HTMLprint $Highlight->html( $Document );
Overview
PPI::HTML converts Perl documents into syntax highlighted HTML pages.
Methods
new %args
The "new" constructor takes a simple set of key/value pairs to define the formatting options for the HTML.
- page
-
Is the
"page"option is enabled, the generator will wrap the generated HTML fragment in a basic but complete page.
- line_numbers
-
At the present time, the only option available. If set to true, line numbers are added to the output.
- colors | colours
-
For cases where you don't want to use an external stylesheet, you can provide
"colors"as a hash reference where the keys are CSS classes (generally matching the token name) and the values are colours.This allows basic colouring without the need for a whole stylesheet.
- css
-
The
"css"option lets you provide a custom CSS::Tiny object containing any CSS you want to apply to the page (if you are using page mode).If both the
"colors"and"css"options are used, the colour CSS entries will overwrite anything contained in the CSS::Tiny object. The object will also be cloned if it to be modified, to prevent destroying any CSS objects passed in.
Returns a new PPI::HTML object
css
The "css" accessor returns the CSS::Tiny object originally provided to the constructor.
html $Document | $file | \$source
The main method for the class, the "html" method takes a single PPI::Document object, or anything that can be turned into a PPI::Document via its "new" method, and returns a string of HTML formatted based on the arguments given to the "PPI::HTML" constructor.
Returns a string, or "undef" on error.
Support
Bugs should always be submitted via the CPAN bug tracker
<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=PPI-HTML>
For other issues, contact the maintainer
Releases
11 releases since Debian 3.1 (Sarge); the text changed 6 times.