
=head1 NAME

Mail::Message::Convert::Html - Format messages from or to HTML

=head1 CLASS INHERITANCE

 Mail::Message::Convert::Html
   is a Mail::Message::Convert
   is a Mail::Reporter

=head1 SYNOPSIS

 use Mail::Message::Convert::Html;
 my $Html = Mail::Message::Convert::Html->new;

 print $html->fieldToHtml($head);
 print $html->headToHtmlHead($head);
 print $html->headToHtmlTable($head);
 print $html->textToHtml($text);

=head1 DESCRIPTION

The package contains various translators which handle HTML or XHTML
without the help of external modules.  There are more HTML related modules,
which do require extra packages to be installed.

=head1 METHODS

=head2 Initiation

=over 4

=item B<new> OPTIONS

(Class method)

 OPTION               DEFAULT
 fields               <see description>
 head_mailto          <true>
 log                  'WARNINGS'
 produce              'HTML'
 trace                'WARNINGS'

=over 4

=item B<fields> =E<gt> NAMES|ARRAY-OF-NAMES|REGEXS

See Mail::Message::Convert::new(fields)

=item B<head_mailto> =E<gt> BOOLEAN

Whether to replace e-mail addresses in some header lines with links.

=item B<log> =E<gt> LEVEL

See Mail::Reporter::new(log)

=item B<produce> =E<gt> 'HTML'|'XHTML'

Produce HTML or XHTML output.  The output is slightly different, even
html browsers will usually accept the XHTML data.

=item B<trace> =E<gt> LEVEL

See Mail::Reporter::new(trace)

=back

=back

=head2 Converting

=over 4

=item B<fieldContentsToHtml> FIELD, [SUBJECT]

Format one field from the header to HTML.  When the header line usually
usually contains e-mail addresses, the line is scanned and valid addresses
are linked with an C<mailto:> anchor.  The SUBJECT can be specified to
be included in that link.

=item B<fieldToHtml> FIELD, [SUBJECT]

Reformat one header line field to HTML.  The FIELD's name
is printed in bold, followed by the formatted field content,
which is produced by the C<fieldContentsToHtml> method.

=item B<headToHtmlHead> HEAD, META

Translate the selected header lines (fields) to an html page header.  Each
selected field will get its own meta line with the same name as the line.
Furthermore:

=over 4

=item * the C<Subject> field will become the C<title>,

=item * C<From> is used for the C<Author>

=back

Besides, you can specify your own meta fields, which will overrule header
fields.  Empty fields will not be included.  When a C<title> is specified,
this will become the html title, otherwise the C<Subject> field is
taken.  In list context, the lines are separately, where in scalar context
the whole text is returned as one.

If you need to add lines to the head (for instance, http-equiv lines), then
splice them before the last element in the returned list.

Examples:

 my @head = $html->headToHtmlHead
     ( $head
     , description => 'This is a message'
     , generator   => 'Mail::Box'
     );
 splice @head, -1, 0, '<meta http-equiv=...>';
 print @head;

=item B<headToHtmlTable> HEAD, [TABLE-PARAMS]

Produce a display of the selected fields of the header (see
selectedFields()) in a table shape.  The optional
TABLE-PARAMS are added as parameters to the produced TABLE tag.
In list context, the separate lines are returned.  In scalar
context, everything is returned as one.

Examples:

 print $html->headToHtmlTable($head, 'width="50%"');

=item B<selectedFields> HEAD

See Mail::Message::Convert::selectedFields()

=item B<textToHtml> LINES

Translate one or more LINES from text into HTML.  Each line is taken one
after the other, and only simple things are translated.  The C<plainToHtml>
method is able to convert large plain texts in a descent fashion.  In scalar
context, the resulting lines are returned as one.

=back

=head2 Logging and Tracing

=over 4

=item B<defaultTrace> [LEVEL, [LEVEL]

See Mail::Reporter::defaultTrace()

=item B<errors> 

See Mail::Reporter::errors()

=item B<log> [LEVEL [,STRINGS]]

See Mail::Reporter::log()

=item B<report> [LEVEL]

See Mail::Reporter::report()

=item B<reportAll> [LEVEL]

See Mail::Reporter::reportAll()

=item B<trace> [LEVEL]

See Mail::Reporter::trace()

=item B<warnings> 

See Mail::Reporter::warnings()

=back

=head2 Other Methods

=over 4

=item B<AUTOLOAD> 

See Mail::Reporter::AUTOLOAD()

=item B<DESTROY> 

See Mail::Reporter::DESTROY()

=item B<inGlobalDestruction> 

See Mail::Reporter::inGlobalDestruction()

=item B<logPriority> LEVEL

See Mail::Reporter::logPriority()

=item B<logSettings> 

See Mail::Reporter::logSettings()

=item B<notImplemented> 

See Mail::Reporter::notImplemented()

=back

=head1 SEE ALSO

A good start to read is Mail::Box-Overview.
More documentation and a mailinglist are available from the project's
website at L<http://perl.overmeer.net/mailbox/>.

=head1 AUTHOR

Written by Mark Overmeer (L<mark@overmeer.net|mailto:mark@overmeer.net>)
with the help of many.  See the ChangeLog for details.

=head1 VERSION

This code is beta, version 2.037.

Copyright (c) 2001-2003 by the authors. All rights reserved.
This program is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.
