README
1NAME
2 PPI::HTML - Generate syntax-hightlighted HTML for Perl using PPI
3
4SYNOPSIS
5 use PPI;
6 use PPI::HTML;
7
8 # Load your Perl file
9 my $Document = PPI::Document->load( 'script.pl' );
10
11 # Create a reusable syntax highlighter
12 my $Highlight = PPI::HTML->new( line_numbers => 1 );
13
14 # Spit out the HTML
15 print $Highlight->html( $Document );
16
17DESCRIPTION
18 PPI::HTML converts Perl documents into syntax highlighted HTML pages.
19
20HISTORY
21 PPI::HTML is the successor to the now-redundant PPI::Format::HTML.
22
23 While early on it was thought that the same formatting code might be
24 able to be used for a variety of different types of things (ANSI and
25 HTML for example) later developments with the here-doc code and the need
26 for independantly written serializers meant that this idea had to be
27 discarded.
28
29 In addition, the old module only made use of the Tokenizer, and had a
30 pretty shit API to boot.
31
32 API Overview
33 The new module is much cleaner. Simply create an object with the options
34 you want, pass PPI::Document objects to the "html" method, and you get
35 strings of HTML that you can do whatever you want with.
36
37METHODS
38 new %args
39 The "new" constructor takes a simple set of key/value pairs to define
40 the formatting options for the HTML.
41
42 page
43 Is the "page" option is enabled, the generator will wrap the
44 generated HTML fragment in a basic but complete page.
45
46 line_numbers
47 At the present time, the only option available. If set to true, line
48 numbers are added to the output.
49
50 colors | colours
51 For cases where you don't want to use an external stylesheet, you
52 can provide "colors" as a hash reference where the keys are CSS
53 classes (generally matching the token name) and the values are
54 colours.
55
56 This allows basic colouring without the need for a whole stylesheet.
57
58 css The "css" option lets you provide a custom CSS::Tiny object
59 containing any CSS you want to apply to the page (if you are using
60 page mode).
61
62 If both the "colors" and "css" options are used, the colour CSS
63 entries will overwrite anything contained in the CSS::Tiny object.
64 The object will also be cloned if it to be modified, to prevent
65 destroying any CSS objects passed in.
66
67 Returns a new PPI::HTML object
68
69 css
70 The "css" accessor returns the CSS::Tiny object originally provided to
71 the constructor.
72
73 html $Document | $file | \$source
74 The main method for the class, the "html" method takes a single
75 PPI::Document object, or anything that can be turned into a
76 PPI::Document via its "new" method, and returns a string of HTML
77 formatted based on the arguments given to the "PPI::HTML" constructor.
78
79 Returns a string, or "undef" on error.
80
81SUPPORT
82 Bugs should always be submitted via the CPAN bug tracker
83
84 <http://rt.cpan.org/NoAuth/ReportBug.html?Queue=PPI-HTML>
85
86 For other issues, contact the maintainer
87
88AUTHOR
89 Adam Kennedy <adamk@cpan.org>
90
91 Funding provided by The Perl Foundation
92
93SEE ALSO
94 <http://ali.as/>, PPI
95
96COPYRIGHT
97 Copyright 2005 - 2009 Adam Kennedy.
98
99 This program is free software; you can redistribute it and/or modify it
100 under the same terms as Perl itself.
101
102 The full text of the license can be found in the LICENSE file included
103 with this module.
104
105