Update of /cvsroot/mhonarc/mhonarc/MHonArc/lib
In directory subversions:/tmp/cvs-serv6343/lib
Modified Files:
mhtxtplain.pl
Log Message:
* Incorporated format=flowed support into mhtxtplain.pl contributed
by Ken Hirsch, with some minor improvements.
Index: mhtxtplain.pl
===================================================================
RCS file: /cvsroot/mhonarc/mhonarc/MHonArc/lib/mhtxtplain.pl,v
retrieving revision 2.16
retrieving revision 2.17
diff -C2 -r2.16 -r2.17
*** mhtxtplain.pl 4 Apr 2002 03:38:39 -0000 2.16
--- mhtxtplain.pl 9 May 2002 03:25:17 -0000 2.17
***************
*** 43,46 ****
--- 43,51 ----
$HQuoteChars = '>|[\|\]+:]';
+ $StartFlowedQuote =
+ '<blockquote style="border-left: #0000FF solid 0.2em; '.
+ 'margin-left: 0.2em; padding-left: 0.2em">';
+ $EndFlowedQuote = "</blockquote>";
+
##---------------------------------------------------------------------------##
## Text/plain filter for mhonarc. The following filter arguments
***************
*** 210,214 ****
}
! my($charset, $nourl, $doquote, $igncharset, $nonfixed,
$keepspace, $maxwidth, $target, $defset, $xhtml);
my(%asis) = (
--- 215,219 ----
}
! my($charset, $nourl, $doquote, $igncharset, $nonfixed, $textformat,
$keepspace, $maxwidth, $target, $defset, $xhtml);
my(%asis) = (
***************
*** 242,245 ****
--- 247,258 ----
$charset = $defset;
}
+ ## Grab format parameter (if defined)
+ if ( defined($fields->{'content-type'}[0]) and
+ $fields->{'content-type'}[0] =~ /\bformat\s*=\s*([^\s;]+)/i ) {
+ $textformat = lc $1;
+ $textformat =~ s/['";\s]//g;
+ } else {
+ $textformat = "fixed";
+ }
## Check if certain charsets should be left alone
***************
*** 257,261 ****
## Check if max-width set
! if ($maxwidth) {
$$data =~ s/^(.*)$/&break_line($1, $maxwidth)/gem;
}
--- 270,274 ----
## Check if max-width set
! if ($maxwidth && $textformat eq 'fixed') {
$$data =~ s/^(.*)$/&break_line($1, $maxwidth)/gem;
}
***************
*** 280,284 ****
# Other
} else {
! warn qq/Warning: Unrecognized character set: $charset\n/;
esc_chars_inplace($data);
}
--- 293,300 ----
# Other
} else {
! warn qq/\n/,
! qq/Warning: Unrecognized character set: $charset\n/,
! qq/ Message-Id: <$MHAmsgid>\n/,
! qq/ Message Number: $MHAmsgnum\n/;
esc_chars_inplace($data);
}
***************
*** 288,304 ****
}
! ## Check for quoting
! if ($doquote) {
! $$data =~ s(_at_)^( ?${HQuoteChars})(.*)$(_at_)$1<I>$2</I>@gom;
! }
! ## Check if using nonfixed font
! if ($nonfixed) {
! $$data =~ s/(\r?\n)/<br>$1/g;
! if ($keepspace) {
! $$data =~ s/^(.*)$/&preserve_space($1)/gem;
}
} else {
! $$data = "<pre>\n" . $$data . "</pre>\n";
}
--- 304,392 ----
}
! if ($textformat eq 'flowed') {
! # Initial code for format=flowed by Ken Hirsch (May 2002).
! # text/plain; format=flowed defined in RFC2646
!
! my $currdepth = 0;
! my $ret='';
! s!^</?x-flowed>\r?\n>!!mg; # we don't know why Eudora puts these in
! while (length($$data)) {
! $$data =~ /^((?:>)*)/;
! my $qd = $1;
! if ($$data =~ s/^(.*(?:(?:\n|\r\n?)$qd(?!>).*)*\n?)//) {
! # divide message into chunks by "quote-depth",
! # which is the number of leading > signs
! my $chunk = $1;
! $chunk =~ s/^$qd ?//mg; # N.B. also takes care of
! # space-stuffing
! $chunk =~ s/^-- $/--/mg; # special case for '-- '
!
! if ($chunk =~ / \r?\n/) {
! # Treat this chunk as format=flowed
! # Lines that end with spaces are
! # considered to have soft line breaks.
! # Lines that end with no spaces are
! # considered to have hard line breaks.
! $chunk =~ s/(?<! )(\r?\n|\Z)/<br>$1/g;
!
! } else {
! # Treat this chunk as format=fixed
! if ($nonfixed) {
! $chunk =~ s/(\r?\n)/<br>$1/g;
! if ($keepspace) {
! $chunk =~ s/^(.*)$/&preserve_space($1)/gem;
! }
! } else {
! $chunk = "<pre>" . $chunk . "</pre>\n";
! }
! }
! my $newdepth = length($qd)/length('>');
! if ($currdepth < $newdepth) {
! $chunk = $StartFlowedQuote x
! ($newdepth - $currdepth) . $chunk;
! } elsif ($currdepth > $newdepth) {
! $chunk = $EndFlowedQuote x
! ($currdepth - $newdepth) . $chunk;
! }
! $currdepth = $newdepth;
! $ret .= $chunk;
! } else {
! # I think the above regex will always match, but
! # I put this in here to catch any weird cases
! # so there's no infinite loop
! warn qq/\n/,
! qq/Warning: Dequoting problem with format=flowed data\n/,
! qq/ Message-Id: <$MHAmsgid>\n/,
! qq/ Message Number: $MHAmsgnum\n/;
! $ret .= $$data;
! last;
! }
! }
! if ($currdepth > 0) {
! $ret .= $EndFlowedQuote x $currdepth;
}
+
+ ## Post-processing cleanup: makes things look nicer
+ $ret =~ s/<br><\/blockquote>/<\/blockquote>/g;
+ $ret =~ s/<\/blockquote><br>/<\/blockquote>/g;
+
+ $$data = $ret;
+
} else {
! ## Check for quoting
! if ($doquote) {
! $$data =~ s(_at_)^( ?${HQuoteChars})(.*)$(_at_)$1<I>$2</I>@gom;
! }
!
! ## Check if using nonfixed font
! if ($nonfixed) {
! $$data =~ s/(\r?\n)/<br>$1/g;
! if ($keepspace) {
! $$data =~ s/^(.*)$/&preserve_space($1)/gem;
! }
! } else {
! $$data = "<pre>" . $$data . "</pre>\n";
! }
}
---------------------------------------------------------------------
To sign-off this list, send email to majordomo(_at_)mhonarc(_dot_)org with the
message text UNSUBSCRIBE MHONARC-DEV