1HTML::Formatter(3) User Contributed Perl Documentation HTML::Formatter(3)
2
3
4
6 HTML::Formatter - Base class for HTML formatters
7
9 use HTML::FormatSomething;
10 my $infile = "whatever.html";
11 my $outfile = "whatever.file";
12 open OUT, ">$outfile"
13 or die "Can't write-open $outfile: $!\nAborting";
14 binmode(OUT);
15 print OUT HTML::FormatSomething->format_file(
16 $infile,
17 'option1' => 'value1',
18 'option2' => 'value2',
19 ...
20 );
21 close(OUT);
22
24 HTML::Formatter is a base class for classes that take HTML and format
25 it to some output format. When you take an object of such a base class
26 and call "$formatter->format( $tree )" with an HTML::TreeBuilder (or
27 HTML::Element) object, they return the
28
29 HTML formatters are able to format a HTML syntax tree into various
30 printable formats. Different formatters produce output for different
31 output media. Common for all formatters are that they will return the
32 formatted output when the format() method is called. The format()
33 method takes a HTML::Element object (usually the HTML::TreeBuilder root
34 object) as parameter.
35
36 Here are the four main methods that this class provides:
37
38 SomeClass->format_file( $filename, option1 => value1, option2 =>
39 value2, ... )
40 This returns a string consisting of the result of using the given
41 class to format the given HTML file according to the given
42 (optional) options. Internally it calls "SomeClass->new( ...
43 )->format( ... )" on a new HTML::TreeBuilder object based on the
44 given HTML file.
45
46 SomeClass->format_string( $html_source, option1 => value1, option2 =>
47 value2, ... )
48 This returns a string consisting of the result of using the given
49 class to format the given HTML source according to the given
50 (optional) options. Internally it calls "SomeClass->new( ...
51 )->format( ... )" on a new HTML::TreeBuilder object based on the
52 given source.
53
54 $formatter = SomeClass->new( option1 => value1, option2 => value2, ...
55 )
56 This creates a new formatter object with the given options.
57
58 $render_string = $formatter->format( $html_tree_object )
59 This renders the given HTML object accerting to the options set for
60 $formatter.
61
62 After you've used a particular formatter object to format a particular
63 HTML tree object, you probably should not use either again.
64
66 HTML::FormatText, HTML::FormatPS, HTML::FormatRTF
67
68 HTML::TreeBuilder, HTML::Element, HTML::Tree
69
71 Copyright (c) 1995-2002 Gisle Aas, and 2002- Sean M. Burke. All rights
72 reserved.
73
74 This library is free software; you can redistribute it and/or modify it
75 under the same terms as Perl itself.
76
77 This program is distributed in the hope that it will be useful, but
78 without any warranty; without even the implied warranty of mer‐
79 chantability or fitness for a particular purpose.
80
82 Current maintainer: Sean M. Burke <sburke@cpan.org>
83
84 Original author: Gisle Aas <gisle@aas.no>
85
86
87
88perl v5.8.8 2004-06-02 HTML::Formatter(3)