.\" Automatically generated by Pod::Man 4.09 (Pod::Simple 3.35) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .if !\nF .nr F 0 .if \nF>0 \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} .\} .\" ======================================================================== .\" .IX Title "PPI::HTML 3pm" .TH PPI::HTML 3pm "2018-07-08" "perl v5.26.2" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" PPI::HTML \- Generate syntax\-hightlighted HTML for Perl using PPI .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 2 \& use PPI; \& use PPI::HTML; \& \& # Load your Perl file \& my $Document = PPI::Document\->load( \*(Aqscript.pl\*(Aq ); \& \& # Create a reusable syntax highlighter \& my $Highlight = PPI::HTML\->new( line_numbers => 1 ); \& \& # Spit out the HTML \& print $Highlight\->html( $Document ); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\s-1PPI::HTML\s0 converts Perl documents into syntax highlighted \s-1HTML\s0 pages. .SH "HISTORY" .IX Header "HISTORY" \&\s-1PPI::HTML\s0 is the successor to the now-redundant PPI::Format::HTML. .PP 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 (\s-1ANSI\s0 and \s-1HTML\s0 for example) later developments with the here-doc code and the need for independently written serializers meant that this idea had to be discarded. .PP In addition, the old module only made use of the Tokenizer, and had a pretty shit \s-1API\s0 to boot. .SS "\s-1API\s0 Overview" .IX Subsection "API Overview" The new module is much cleaner. Simply create an object with the options you want, pass PPI::Document objects to the \f(CW\*(C`html\*(C'\fR method, and you get strings of \s-1HTML\s0 that you can do whatever you want with. .SH "METHODS" .IX Header "METHODS" .ie n .SS "new %args" .el .SS "new \f(CW%args\fP" .IX Subsection "new %args" The \f(CW\*(C`new\*(C'\fR constructor takes a simple set of key/value pairs to define the formatting options for the \s-1HTML.\s0 .IP "page" 4 .IX Item "page" Is the \f(CW\*(C`page\*(C'\fR option is enabled, the generator will wrap the generated \&\s-1HTML\s0 fragment in a basic but complete page. .IP "line_numbers" 4 .IX Item "line_numbers" At the present time, the only option available. If set to true, line numbers are added to the output. .IP "colors | colours" 4 .IX Item "colors | colours" For cases where you don't want to use an external stylesheet, you can provide \f(CW\*(C`colors\*(C'\fR as a hash reference where the keys are \s-1CSS\s0 classes (generally matching the token name) and the values are colours. .Sp This allows basic colouring without the need for a whole stylesheet. .IP "css" 4 .IX Item "css" The \f(CW\*(C`css\*(C'\fR option lets you provide a custom CSS::Tiny object containing any \s-1CSS\s0 you want to apply to the page (if you are using page mode). .Sp If both the \f(CW\*(C`colors\*(C'\fR and \f(CW\*(C`css\*(C'\fR options are used, the colour \s-1CSS\s0 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 \s-1CSS\s0 objects passed in. .PP Returns a new \s-1PPI::HTML\s0 object .SS "css" .IX Subsection "css" The \f(CW\*(C`css\*(C'\fR accessor returns the CSS::Tiny object originally provided to the constructor. .ie n .SS "html $Document | $file | \e$source" .el .SS "html \f(CW$Document\fP | \f(CW$file\fP | \e$source" .IX Subsection "html $Document | $file | $source" The main method for the class, the \f(CW\*(C`html\*(C'\fR method takes a single PPI::Document object, or anything that can be turned into a PPI::Document via its \f(CW\*(C`new\*(C'\fR method, and returns a string of \s-1HTML\s0 formatted based on the arguments given to the \f(CW\*(C`PPI::HTML\*(C'\fR constructor. .PP Returns a string, or \f(CW\*(C`undef\*(C'\fR on error. .SH "SUPPORT" .IX Header "SUPPORT" Bugs should always be submitted via the \s-1CPAN\s0 bug tracker .PP .PP For other issues, contact the maintainer .SH "AUTHOR" .IX Header "AUTHOR" Adam Kennedy .PP Funding provided by The Perl Foundation .SH "SEE ALSO" .IX Header "SEE ALSO" , \s-1PPI\s0 .SH "COPYRIGHT" .IX Header "COPYRIGHT" Copyright 2005 \- 2009 Adam Kennedy. .PP This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. .PP The full text of the license can be found in the \&\s-1LICENSE\s0 file included with this module.