1PPI::HTML(3)          User Contributed Perl Documentation         PPI::HTML(3)
2
3
4

NAME

6       PPI::HTML - Generate syntax-hightlighted HTML for Perl using PPI
7

SYNOPSIS

9         use PPI;
10         use PPI::HTML;
11
12         # Load your Perl file
13         my $Document = PPI::Document->load( 'script.pl' );
14
15         # Create a reusable syntax highlighter
16         my $Highlight = PPI::HTML->new( line_numbers => 1 );
17
18         # Spit out the HTML
19         print $Highlight->html( $Document );
20

DESCRIPTION

22       PPI::HTML converts Perl documents into syntax highlighted HTML pages.
23

HISTORY

25       PPI::HTML is the successor to the now-redundant PPI::Format::HTML.
26
27       While early on it was thought that the same formatting code might be
28       able to be used for a variety of different types of things (ANSI and
29       HTML for example) later developments with the here-doc code and the
30       need for independantly written serializers meant that this idea had to
31       be discarded.
32
33       In addition, the old module only made use of the Tokenizer, and had a
34       pretty shit API to boot.
35
36   API Overview
37       The new module is much cleaner. Simply create an object with the
38       options you want, pass PPI::Document objects to the "html" method, and
39       you get strings of HTML that you can do whatever you want with.
40

METHODS

42   new %args
43       The "new" constructor takes a simple set of key/value pairs to define
44       the formatting options for the HTML.
45
46       page
47           Is the "page" option is enabled, the generator will wrap the
48           generated HTML fragment in a basic but complete page.
49
50       line_numbers
51           At the present time, the only option available. If set to true,
52           line numbers are added to the output.
53
54       colors | colours
55           For cases where you don't want to use an external stylesheet, you
56           can provide "colors" as a hash reference where the keys are CSS
57           classes (generally matching the token name) and the values are
58           colours.
59
60           This allows basic colouring without the need for a whole
61           stylesheet.
62
63       css The "css" option lets you provide a custom CSS::Tiny object
64           containing any CSS you want to apply to the page (if you are using
65           page mode).
66
67           If both the "colors" and "css" options are used, the colour CSS
68           entries will overwrite anything contained in the CSS::Tiny object.
69           The object will also be cloned if it to be modified, to prevent
70           destroying any CSS objects passed in.
71
72       Returns a new PPI::HTML object
73
74   css
75       The "css" accessor returns the CSS::Tiny object originally provided to
76       the constructor.
77
78   html $Document | $file | \$source
79       The main method for the class, the "html" method takes a single
80       PPI::Document object, or anything that can be turned into a
81       PPI::Document via its "new" method, and returns a string of HTML
82       formatted based on the arguments given to the "PPI::HTML" constructor.
83
84       Returns a string, or "undef" on error.
85

SUPPORT

87       Bugs should always be submitted via the CPAN bug tracker
88
89       <http://rt.cpan.org/NoAuth/ReportBug.html?Queue=PPI-HTML>
90
91       For other issues, contact the maintainer
92

AUTHOR

94       Adam Kennedy <adamk@cpan.org>
95
96       Funding provided by The Perl Foundation
97

SEE ALSO

99       <http://ali.as/>, PPI
100
102       Copyright 2005 - 2009 Adam Kennedy.
103
104       This program is free software; you can redistribute it and/or modify it
105       under the same terms as Perl itself.
106
107       The full text of the license can be found in the LICENSE file included
108       with this module.
109
110
111
112perl v5.28.1                      2009-11-16                      PPI::HTML(3)
Impressum