266 lines
6.6 KiB
HTML
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"> </A>
|
|
<H2>NAME</H2>
|
|
|
|
HTML::Formatter - Base class for HTML formatters
|
|
<A NAME="lbAC"> </A>
|
|
<H2>VERSION</H2>
|
|
|
|
|
|
|
|
version 2.12
|
|
<A NAME="lbAD"> </A>
|
|
<H2>SYNOPSIS</H2>
|
|
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
use HTML::FormatSomething;
|
|
my $infile = "whatever.html";
|
|
my $outfile = "whatever.file";
|
|
open OUT, ">$outfile"
|
|
or die "Can't write-open $outfile: $!\n";
|
|
|
|
print OUT HTML::FormatSomething->format_file(
|
|
$infile,
|
|
'option1' => 'value1',
|
|
'option2' => 'value2',
|
|
...
|
|
);
|
|
close(OUT);
|
|
|
|
</PRE>
|
|
|
|
|
|
<A NAME="lbAE"> </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>"$formatter-"</TT>format( <TT>$tree</TT> )> 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"> </A>
|
|
<H2>METHODS</H2>
|
|
|
|
|
|
|
|
<A NAME="lbAG"> </A>
|
|
<H3>new</H3>
|
|
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $formatter = FormatterClass->new(
|
|
option1 => value1, option2 => value2, ...
|
|
);
|
|
|
|
</PRE>
|
|
|
|
|
|
<P>
|
|
|
|
This creates a new formatter object with the given options.
|
|
<A NAME="lbAH"> </A>
|
|
<H3>format_file</H3>
|
|
|
|
|
|
|
|
<A NAME="lbAI"> </A>
|
|
<H3>format_from_file</H3>
|
|
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
$string = FormatterClass->format_file(
|
|
$html_source,
|
|
option1 => value1, option2 => 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>"SomeClass->new( ... )->format( ... )"</TT> on a new HTML::TreeBuilder object
|
|
based on the given <FONT SIZE="-1">HTML</FONT> file.
|
|
<A NAME="lbAJ"> </A>
|
|
<H3>format_string</H3>
|
|
|
|
|
|
|
|
<A NAME="lbAK"> </A>
|
|
<H3>format_from_string</H3>
|
|
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
$string = FormatterClass->format_string(
|
|
$html_source,
|
|
option1 => value1, option2 => 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>"SomeClass->new( ... )->format( ... )"</TT> on a new HTML::TreeBuilder
|
|
object based on the given source.
|
|
<A NAME="lbAL"> </A>
|
|
<H3>format</H3>
|
|
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $render_string = $formatter->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"> </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"> </A>
|
|
<H2>INSTALLATION</H2>
|
|
|
|
|
|
|
|
See perlmodinstall for information and options on installing Perl modules.
|
|
<A NAME="lbAO"> </A>
|
|
<H2>BUGS AND LIMITATIONS</H2>
|
|
|
|
|
|
|
|
You can make new bug reports, and view existing ones, through the
|
|
web interface at <<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>>.
|
|
<A NAME="lbAP"> </A>
|
|
<H2>AVAILABILITY</H2>
|
|
|
|
|
|
|
|
The project homepage is <<A HREF="https://metacpan.org/release/HTML-Format">https://metacpan.org/release/HTML-Format</A>>.
|
|
<P>
|
|
|
|
The latest version of this module is available from the Comprehensive Perl
|
|
Archive Network (<FONT SIZE="-1">CPAN</FONT>). Visit <<A HREF="http://www.perl.com/CPAN/">http://www.perl.com/CPAN/</A>> to find a <FONT SIZE="-1">CPAN</FONT>
|
|
site near you, or see <<A HREF="https://metacpan.org/module/HTML::Format/">https://metacpan.org/module/HTML::Format/</A>>.
|
|
<A NAME="lbAQ"> </A>
|
|
<H2>AUTHORS</H2>
|
|
|
|
|
|
|
|
<DL COMPACT>
|
|
<DT id="4">•<DD>
|
|
Nigel Metheringham <<A HREF="mailto:nigelm@cpan.org">nigelm@cpan.org</A>>
|
|
<DT id="5">•<DD>
|
|
Sean M Burke <<A HREF="mailto:sburke@cpan.org">sburke@cpan.org</A>>
|
|
<DT id="6">•<DD>
|
|
Gisle Aas <<A HREF="mailto:gisle@ActiveState.com">gisle@ActiveState.com</A>>
|
|
</DL>
|
|
<A NAME="lbAR"> </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"> </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>
|