1HTML::Formatter(3) User Contributed Perl Documentation HTML::Formatter(3)
2
3
4
6 HTML::Formatter - Base class for HTML formatters
7
9 version 2.10
10
12 use HTML::FormatSomething;
13 my $infile = "whatever.html";
14 my $outfile = "whatever.file";
15 open OUT, ">$outfile"
16 or die "Can't write-open $outfile: $!\n";
17
18 print OUT HTML::FormatSomething->format_file(
19 $infile,
20 'option1' => 'value1',
21 'option2' => 'value2',
22 ...
23 );
24 close(OUT);
25
27 HTML::Formatter is a base class for classes that take HTML and format
28 it to some output format. When you take an object of such a base class
29 and call "$formatter->format( $tree )" with an HTML::TreeBuilder (or
30 HTML::Element) object, they return the
31
32 HTML formatters are able to format a HTML syntax tree into various
33 printable formats. Different formatters produce output for different
34 output media. Common for all formatters are that they will return the
35 formatted output when the format() method is called. The format()
36 method takes a HTML::Element object (usually the HTML::TreeBuilder root
37 object) as parameter.
38
40 new
41 my $formatter = FormatterClass->new(
42 option1 => value1, option2 => value2, ...
43 );
44
45 This creates a new formatter object with the given options.
46
47 format_file
48 format_from_file
49 $string = FormatterClass->format_file(
50 $html_source,
51 option1 => value1, option2 => value2, ...
52 );
53
54 Return a string consisting of the result of using the given class to
55 format the given HTML file according to the given (optional) options.
56 Internally it calls "SomeClass->new( ... )->format( ... )" on a new
57 HTML::TreeBuilder object based on the given HTML file.
58
59 format_string
60 format_from_string
61 $string = FormatterClass->format_string(
62 $html_source,
63 option1 => value1, option2 => value2, ...
64 );
65
66 Return a string consisting of the result of using the given class to
67 format the given HTML source according to the given (optional) options.
68 Internally it calls "SomeClass->new( ... )->format( ... )" on a new
69 HTML::TreeBuilder object based on the given source.
70
71 format
72 my $render_string = $formatter->format( $html_tree_object );
73
74 This renders the given HTML object according to the options set for
75 $formatter.
76
77 After you've used a particular formatter object to format a particular
78 HTML tree object, you probably should not use either again.
79
81 The three specific formatters:-
82
83 HTML::FormatText
84 Format HTML into plain text
85
86 HTML::FormatPS
87 Format HTML into postscript
88
89 HTML::FormatRTF
90 Format HTML into Rich Text Format
91
92 Also the HTML manipulation libraries used - HTML::TreeBuilder,
93 HTML::Element and HTML::Tree
94
96 See perlmodinstall for information and options on installing Perl
97 modules.
98
100 No bugs have been reported.
101
102 Please report any bugs or feature requests through the web interface at
103 <http://rt.cpan.org/Public/Dist/Display.html?Name=HTML-Format>.
104
106 The project homepage is <http://search.cpan.org/dist/HTML-Format>.
107
108 The latest version of this module is available from the Comprehensive
109 Perl Archive Network (CPAN). Visit <http://www.perl.com/CPAN/> to find
110 a CPAN site near you, or see
111 <http://search.cpan.org/dist/HTML-Format/>.
112
113 The development version lives at <http://github.com/nigelm/html-format>
114 and may be cloned from <git://github.com/nigelm/html-format.git>.
115 Instead of sending patches, please fork this project using the standard
116 git and github infrastructure.
117
119 · Nigel Metheringham <nigelm@cpan.org>
120
121 · Sean M Burke <sburke@cpan.org>
122
123 · Gisle Aas <gisle@ActiveState.com>
124
126 This software is copyright (c) 2011 by Nigel Metheringham, 2002-2005
127 Sean M Burke, 1999-2002 Gisle Aas.
128
129 This is free software; you can redistribute it and/or modify it under
130 the same terms as the Perl 5 programming language system itself.
131
132
133
134perl v5.16.3 2014-06-10 HTML::Formatter(3)