man-pages/man3/HTML::Formatter.3pm.html
2021-03-31 01:06:50 +01:00

266 lines
6.6 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML><HEAD><TITLE>Man page of HTML::Formatter</TITLE>
</HEAD><BODY>
<H1>HTML::Formatter</H1>
Section: User Contributed Perl Documentation (3pm)<BR>Updated: 2016-12-15<BR><A HREF="#index">Index</A>
<A HREF="/cgi-bin/man/man2html">Return to Main Contents</A><HR>
<A NAME="lbAB">&nbsp;</A>
<H2>NAME</H2>
HTML::Formatter - Base class for HTML formatters
<A NAME="lbAC">&nbsp;</A>
<H2>VERSION</H2>
version 2.12
<A NAME="lbAD">&nbsp;</A>
<H2>SYNOPSIS</H2>
<PRE>
use HTML::FormatSomething;
my $infile = &quot;whatever.html&quot;;
my $outfile = &quot;whatever.file&quot;;
open OUT, &quot;&gt;$outfile&quot;
or die &quot;Can't write-open $outfile: $!\n&quot;;
print OUT HTML::FormatSomething-&gt;format_file(
$infile,
'option1' =&gt; 'value1',
'option2' =&gt; 'value2',
...
);
close(OUT);
</PRE>
<A NAME="lbAE">&nbsp;</A>
<H2>DESCRIPTION</H2>
HTML::Formatter is a base class for classes that take <FONT SIZE="-1">HTML</FONT> and format it to
some output format. When you take an object of such a base class and call
<TT>&quot;$formatter-&quot;</TT>format( <TT>$tree</TT> )&gt; with an HTML::TreeBuilder (or
HTML::Element) object, they return the appropriately formatted string for
the input <FONT SIZE="-1">HTML.</FONT>
<P>
<FONT SIZE="-1">HTML</FONT> formatters are able to format a <FONT SIZE="-1">HTML</FONT> syntax tree into various printable
formats. Different formatters produce output for different output media.
Common for all formatters are that they will return the formatted output when
the <I>format()</I> method is called. The <I>format()</I> method takes a HTML::Element
object (usually the HTML::TreeBuilder root object) as parameter.
<A NAME="lbAF">&nbsp;</A>
<H2>METHODS</H2>
<A NAME="lbAG">&nbsp;</A>
<H3>new</H3>
<PRE>
my $formatter = FormatterClass-&gt;new(
option1 =&gt; value1, option2 =&gt; value2, ...
);
</PRE>
<P>
This creates a new formatter object with the given options.
<A NAME="lbAH">&nbsp;</A>
<H3>format_file</H3>
<A NAME="lbAI">&nbsp;</A>
<H3>format_from_file</H3>
<PRE>
$string = FormatterClass-&gt;format_file(
$html_source,
option1 =&gt; value1, option2 =&gt; value2, ...
);
</PRE>
<P>
Return a string consisting of the result of using the given class to format the
given <FONT SIZE="-1">HTML</FONT> file according to the given (optional) options. Internally it calls
<TT>&quot;SomeClass-&gt;new( ... )-&gt;format( ... )&quot;</TT> on a new HTML::TreeBuilder object
based on the given <FONT SIZE="-1">HTML</FONT> file.
<A NAME="lbAJ">&nbsp;</A>
<H3>format_string</H3>
<A NAME="lbAK">&nbsp;</A>
<H3>format_from_string</H3>
<PRE>
$string = FormatterClass-&gt;format_string(
$html_source,
option1 =&gt; value1, option2 =&gt; value2, ...
);
</PRE>
<P>
Return a string consisting of the result of using the given class to format the
given <FONT SIZE="-1">HTML</FONT> source according to the given (optional) options. Internally it
calls <TT>&quot;SomeClass-&gt;new( ... )-&gt;format( ... )&quot;</TT> on a new HTML::TreeBuilder
object based on the given source.
<A NAME="lbAL">&nbsp;</A>
<H3>format</H3>
<PRE>
my $render_string = $formatter-&gt;format( $html_tree_object );
</PRE>
<P>
This renders the given <FONT SIZE="-1">HTML</FONT> object according to the options set for <TT>$formatter</TT>.
<P>
After you've used a particular formatter object to format a particular <FONT SIZE="-1">HTML</FONT>
tree object, you probably should not use either again.
<A NAME="lbAM">&nbsp;</A>
<H2>SEE ALSO</H2>
The three specific formatters:-
<DL COMPACT>
<DT id="1">HTML::FormatText<DD>
Format <FONT SIZE="-1">HTML</FONT> into plain text
<DT id="2">HTML::FormatPS<DD>
Format <FONT SIZE="-1">HTML</FONT> into postscript
<DT id="3">HTML::FormatRTF<DD>
Format <FONT SIZE="-1">HTML</FONT> into Rich Text Format
</DL>
<P>
Also the <FONT SIZE="-1">HTML</FONT> manipulation libraries used - HTML::TreeBuilder,
HTML::Element and HTML::Tree
<A NAME="lbAN">&nbsp;</A>
<H2>INSTALLATION</H2>
See perlmodinstall for information and options on installing Perl modules.
<A NAME="lbAO">&nbsp;</A>
<H2>BUGS AND LIMITATIONS</H2>
You can make new bug reports, and view existing ones, through the
web interface at &lt;<A HREF="http://rt.cpan.org/Public/Dist/Display.html?Name=HTML-Format">http://rt.cpan.org/Public/Dist/Display.html?Name=HTML-Format</A>&gt;.
<A NAME="lbAP">&nbsp;</A>
<H2>AVAILABILITY</H2>
The project homepage is &lt;<A HREF="https://metacpan.org/release/HTML-Format">https://metacpan.org/release/HTML-Format</A>&gt;.
<P>
The latest version of this module is available from the Comprehensive Perl
Archive Network (<FONT SIZE="-1">CPAN</FONT>). Visit &lt;<A HREF="http://www.perl.com/CPAN/">http://www.perl.com/CPAN/</A>&gt; to find a <FONT SIZE="-1">CPAN</FONT>
site near you, or see &lt;<A HREF="https://metacpan.org/module/HTML::Format/">https://metacpan.org/module/HTML::Format/</A>&gt;.
<A NAME="lbAQ">&nbsp;</A>
<H2>AUTHORS</H2>
<DL COMPACT>
<DT id="4">&bull;<DD>
Nigel Metheringham &lt;<A HREF="mailto:nigelm@cpan.org">nigelm@cpan.org</A>&gt;
<DT id="5">&bull;<DD>
Sean M Burke &lt;<A HREF="mailto:sburke@cpan.org">sburke@cpan.org</A>&gt;
<DT id="6">&bull;<DD>
Gisle Aas &lt;<A HREF="mailto:gisle@ActiveState.com">gisle@ActiveState.com</A>&gt;
</DL>
<A NAME="lbAR">&nbsp;</A>
<H2>COPYRIGHT AND LICENSE</H2>
This software is copyright (c) 2015 by Nigel Metheringham, 2002-2005 Sean M Burke, 1999-2002 Gisle Aas.
<P>
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
<P>
<HR>
<A NAME="index">&nbsp;</A><H2>Index</H2>
<DL>
<DT id="7"><A HREF="#lbAB">NAME</A><DD>
<DT id="8"><A HREF="#lbAC">VERSION</A><DD>
<DT id="9"><A HREF="#lbAD">SYNOPSIS</A><DD>
<DT id="10"><A HREF="#lbAE">DESCRIPTION</A><DD>
<DT id="11"><A HREF="#lbAF">METHODS</A><DD>
<DL>
<DT id="12"><A HREF="#lbAG">new</A><DD>
<DT id="13"><A HREF="#lbAH">format_file</A><DD>
<DT id="14"><A HREF="#lbAI">format_from_file</A><DD>
<DT id="15"><A HREF="#lbAJ">format_string</A><DD>
<DT id="16"><A HREF="#lbAK">format_from_string</A><DD>
<DT id="17"><A HREF="#lbAL">format</A><DD>
</DL>
<DT id="18"><A HREF="#lbAM">SEE ALSO</A><DD>
<DT id="19"><A HREF="#lbAN">INSTALLATION</A><DD>
<DT id="20"><A HREF="#lbAO">BUGS AND LIMITATIONS</A><DD>
<DT id="21"><A HREF="#lbAP">AVAILABILITY</A><DD>
<DT id="22"><A HREF="#lbAQ">AUTHORS</A><DD>
<DT id="23"><A HREF="#lbAR">COPYRIGHT AND LICENSE</A><DD>
</DL>
<HR>
This document was created by
<A HREF="/cgi-bin/man/man2html">man2html</A>,
using the manual pages.<BR>
Time: 00:05:45 GMT, March 31, 2021
</BODY>
</HTML>