B - Provides quotification functionality for Usenet articles and mail.


NAME

Mail::QuoteWrap - Provides quotification functionality for Usenet articles and mail.


SYNOPSIS

    use Mail::QuoteWrap;
    ...
    my $columns = 72;                     # maximum column width of the post
    my $output_quotechar = ">";           # character to prepend to
                                          # quoted lines -- see quotify()
    my $input_quotechars = "<>:";         # characters to be recognized as
                                          # quotifiers when judging the
                                          # generation of a quote
    my $text = $news_article->body();     # get some body text somehow
    my $body = create Mail::QuoteWrap ($text, $columns, $output_quotechar,
                                     $input_quotechars, {});
    $body->quotify();
    $body->append("Me too!");
    my $newtext = $body->format();


DESCRIPTION

A Mail::QuoteWrap object expects its text member to contain a reference to a list of lines of text, such as the output of methods like body News::Article(). It can then produce quotified output, optionally prepended with the quote mark designated by output_quotechar, within the width specified by columns.

Mail::QuoteWrap specificially does not solve the following problems:

It does not handle munged quote characters, such as those produced by the AOHell newsreader or similar gunge:
 >> This >is a second-generation quote, but it
 > looks >>like a nasty mix of first- and second->
 > generation >>material.

It does not automatically detect and bypass news or mail headers. That is not the role of this object.

It assumes a paragraph structure to the quoted text and doesn't try to enforce any other. If you want a module that detects document structure and deals well with it, look at Text::Autoformat.


REQUIRES

This module uses Text::Format.


BUGS

If input_quotechars or output_quotechar contain suckful characters that regexp thinks it understands, all hell can break loose.

Mail::QuoteWrap may not deal well with Supercite-style quotification:
 Chuck> I believe everything I see written on toilet paper

is thought to be zeroth-generation (unquoted) material.


AUTHOR

Chuck Hardin <chardin@savageoasis.fc.net>


COPYRIGHT

This module is copyright 2000, Chuck Hardin.


LICENSE

This module is distributed under version 2 of the GNU Public License.


Public class method

create

 public class
 (Mail::QuoteWrap) create(string[] text [,integer columns]
                          [,string output_quotechar] [,string input_quotechars]
                          [,hashref format_params])

This method creates a Mail::QuoteWrap object populated with the parameters passed in. It returns a NULL object if any of the provided parameters are invalid.

The meanings of the members are as follows:

text
The body text of the message.

columns
The width to which the message should be justified. NOTE: If any line consisting of the quotification string and the first word is wider than this, then the line will be generated with that quotification string and that word, and it will overflow. Life is hard.

output_quotechar
The quotification character to prepend to the text when quoting. See quotify().

input_quotechars
The set of characters to be recognized as quotification marks when determining how to group quoted material.

format_params
Miscellaneous parameters to pass for formatting. See the documentation for the Text::Format module.


Private class method

new

 private class
 (Mail::QuoteWrap) new(hashref params)

Creates a Mail::QuoteWrap object populated by the data in params.


Public instance methods

text

 public instance
 (string []) text()

Returns the text member of the current Mail::QuoteWrap object.

set_text

 public instance
 (string) set_text(string[] text)

Sets the text member of the current Mail::QuoteWrap object. Returns a NULL string if it succeeds, or a descriptive error message otherwise.

columns

 public instance
 (integer) columns()

Returns the columns member of the current Mail::QuoteWrap object.

set_columns

 public instance
 (string) set_columns(integer columns)

Sets the columns member of the current Mail::QuoteWrap object. Returns a NULL string if it succeeds, or a descriptive error message otherwise.

input_quotechars

 public instance
 (string) input_quotechars()

Returns the input_quotechars member of the current Mail::QuoteWrap object.

set_input_quotechars

 public instance
 (string) set_input_quotechars(string input_quotechars)

Sets the input_quotechars member of the current Mail::QuoteWrap object. Returns a NULL string if it succeeds, or a descriptive error message otherwise.

output_quotechar

 public instance
 (string) output_quotechar()

Returns the output_quotechar member of the current Mail::QuoteWrap object.

set_output_quotechar

 public instance
 (string) set_output_quotechar(string output_quotechar)

Sets the output_quotechar member of the current Mail::QuoteWrap object. Returns a NULL string if it succeeds, or a descriptive error message otherwise.

format_params

 public instance
 (hashref) format_params()

Returns the format_params member of the current Mail::QuoteWrap object.

set_format_params

 public instance
 (string) set_format_params(hashref format_params)

Sets the format_params member of the current Mail::QuoteWrap object. Returns a NULL string if it succeeds, or a descriptive error message otherwise.

quotify

 public instance
 (string) quotify()

Quotifies all current text with the string in output_quotechar(). Modifies the input_quotechars member to reflect that the text is now quotified. Returns a NULL string if it succeeds, or a descriptive error message otherwise.

format

 public instance
 (string) format()

This method alters the text member of the current Mail::QuoteWrap object to conform to the constraints implied in the columns and format_params members. It recognizes the quotification characters in input_quotechars and uses them to lump related quoted material together. format() will use the same quotification character at the beginning of each line within a block of quoted material which it believes to be related. Returns a NULL string if it succeeds, or a descriptive error message otherwise.


Private utility methods

parse_quotification

 private
 (string, string) parse_quotification (string text, string quotechars)

Returns two strings: the quotification part of the line of text (consisting of all characters at the beginning of the line which are tabs, spaces, or characters in quotechars), and the remainder of the line. Returns two NULL strings if this matching does not work out.

break_text_into_blocks

 private
 (hashref []) break_text_into_blocks (string[] text, string quotechars)

Breaks text into a list of elements, each of which is a hash with the following elements:

quotification
Quotification string to use for this block.

message
Array ref containing the message text; undef if the message portion is blank.

Each message element is guaranteed to consist of lines of same-generation quotage -- i.e., a block will contain only first-generation quotes, second-generation, zeroth-generation, or what have you. Each line with blank message text gets its own block, to preserve vertical whitespace.

copy_and_push

 private
 (string) copy_and_push(hashref current_block, arrayref outlist)

Pushes a copy of the contents of current_block onto outlist. current_block is assumed to have two members as described in the documentation for break_text_into_blocks() above. Returns a NULL string if it succeeds, or a descriptive error message otherwise.

break_block_into_paragraphs

 private
 (string[]) break_block_into_paragraphs(string[] block)

Breaks the block into paragraphs according to the following rule:

If the previous line ended with a period and the current line begins with a tab or at least three spaces, the current line begins a new paragraph.

 B - Provides quotification functionality for Usenet articles and mail.