mhonarc-dev

Re: Format=flowed

2002-10-28 19:47:23
Earl:
I've just checked-in the newer version into CVS.  Feel free to
to try it out to see if it works with your data.

Ken:
Single line paragraphs are ambiguous as to whether they are fixed or flowed. I 
think that it is a little startling to have a fixed-width font line in between 
two variable-width paragraphs. Granted, it's not a capital crime, but it is 
less than ideal.

It also seems that your latest code has a bug. It does not show a blank line 
between two flowed paragraphs.

I agree on both those comments, and have attached some modifications that resolve the issues. To see the difference, please compare http://www.gunnar.cc/misc/archive/msg00005.html, converted with revision 2.25 of mhtxtplain.pl, with http://arc.ringlink.org/ringlink-open/msg02452.html, converted with my (latest) modified version.

Also, I noticed that v2.25 never converts to more than one blank line. I think that 2 or 3 blank lines between paragraphs should be recognized, since the use of additional blank lines may be part of a message's disposition. The attached code takes care of that as well.

I've also played with a new CPAN module, Text::Flowed, and I attach a variant which makes use of that module. I'm not sure that it is an appropriate way to handle messages when converting to HTML, but you guys may want to check it out.

/ Gunnar


mhtxtplain.pl
CVS diff Format=Flowed modifications (compared to v2.25)
===================================================================
53c53
< $EndFlowedQuote   = "</blockquote>";
---
$EndFlowedQuote   = "</blockquote>\n";
350a351,356
              $chunk =~ s/\r?\n/\n/g;

              # recognize up to 3 blank lines between (flowed) paragraphs
              $chunk =~ s/\s+$//;
              $chunk =~ s/\n([\t ]*\n){3,}/\n\n<br>\n<br>\n\n/g;
              $chunk =~ s/\n([\t ]*\n){2}/\n\n<br>\n\n/g;
359c365
< 
---
                      $para = "$para\n<br>";
367,368c373,380
<                       } else {
<                           $para = '<pre>' . $para . '</pre>';
---
                      } elsif ($para !~ /<br>/) {
                          $para =~ s/^\n//;
                          my @lines = split (/\n/, $para);
                          if (scalar @lines > 1) {
                              $para = '<pre>' . $para . '</pre>';
                          } else {
                              $para .= "<br>\n<br>";
                          }
371c383
<                   $chunk .= $para;
---
                  $chunk .= "$para\n";
398,399c410,412
<       $ret =~ s/<br><\/blockquote>/<\/blockquote>/g;
<       $ret =~ s/<\/blockquote><br>/<\/blockquote>/g;
---
      $ret =~ s/<br>\n?(<\/?blockquote)/$1/g;
      $ret =~ s/(<\/blockquote>)\n?<br>/$1/g;
      $ret =~ s/<br>\n?(<pre>)/$1/g;

Attachment: mhtxtplain.zip
Description: Zip compressed data

Attachment: Text_Flowed_experiment.zip
Description: Zip compressed data

<Prev in Thread] Current Thread [Next in Thread>