|
B |
Mail::QuoteWrap - Provides quotification functionality for Usenet articles and mail.
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();
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:
>> This >is a second-generation quote, but it > looks >>like a nasty mix of first- and second-> > generation >>material.
This module uses Text::Format.
Chuck> I believe everything I see written on toilet paper
is thought to be zeroth-generation (unquoted) material.
Chuck Hardin <chardin@savageoasis.fc.net>
This module is copyright 2000, Chuck Hardin.
This module is distributed under version 2 of the GNU Public License.
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:
quotify().
private class (Mail::QuoteWrap) new(hashref params)
Creates a Mail::QuoteWrap object populated by the data in params.
public instance (string []) text()
Returns the text member of the current Mail::QuoteWrap object.
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.
public instance (integer) columns()
Returns the columns member of the current Mail::QuoteWrap object.
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.
public instance (string) input_quotechars()
Returns the input_quotechars member of the current Mail::QuoteWrap object.
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.
public instance (string) output_quotechar()
Returns the output_quotechar member of the current Mail::QuoteWrap object.
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.
public instance (hashref) format_params()
Returns the format_params member of the current Mail::QuoteWrap object.
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.
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.
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 (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.
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:
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.
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.
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 |