ietf-822
[Top] [All Lists]

MHonArc support for format=flowed

2002-05-01 20:17:47

I've created an experimental version of MHonArc with support for format=flowed.
I've submitted it for comment on the MHonArc mailing list, and thought I should 
get
some feedback here.  For anybody that doesn't know, MHonArc is the program that
creates web archives of mailing lists, including
http://www.imc.org/ietf-822/mail-archive/maillist.html

(As an aside, does anybody else see Chinese characters on that page?  When I 
use IE6
on Windows XP, the characters +ietf- display as the Unicode character U+89EB, 
which
means "to tremble with fear."  If anybody at Microsoft can explain this, I'd 
really
be interested.)

I have a demonstration of the output at:
http://personal.rdu.bellsouth.net/~kahirsch/maillist.html, using just the
format=flowed messages from the ietf-822 mailing list.

You can download the Perl source for the revised module at
http://personal.rdu.bellsouth.net/~kahirsch/mhtxtplain.pl

Here are the highlights, for those who know Perl:
Here are the highlights:
(1) define the HTML formatting for flowed quotes
(line 45 in revised mhtxtplain.pl)
$StartFlowedQuote = '<blockquote style=' .
 '"border-left: #0000ff solid 2px; margin-left: 5px; padding-left: 5px">' .
  "\n";
$EndFlowedQuote   = "</blockquote>\n";

(2) process the body
(line 303)
  if ($textformat eq 'flowed') {
    # experimental support for format=flowed 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 =~ /^((?:&gt;)*)/;
      my $qd = $1;
      if ($$data =~ s/^(.*(?:\n$qd(?!&gt;).*)*\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>\n" . $chunk . "</pre>\n";
            }
          }
          my $newdepth = length($qd)/length('&gt;');
          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
        print STDERR "DEQUOTINGERROR($$data)\n";
        $ret .= $$data;
        last;
      }
    }
    if ($currdepth > 0) {
      $ret .= $EndFlowedQuote x $currdepth;
    }
    $$data = $ret;
  } else {






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