Re: Format=Flowed

2002-10-26 10:09:23
Ken Hirsch:
Perhaps any paragraph (of more than one line) should be treated as fixed if all its lines end without blanks.

Earl Hood:
The filter code needs to be modified so that within each chunk, the
chunk is split into separate paragraph units before determining if the
data is flowed or not.

It seems as we are agreed on this, and I wrote some code accordingly. A modified file and the CVS diff are attached to this message.

Hope you agree it's an improvement.

/ Gunnar
CVS diff Format=Flowed modifications (compared to v2.24)
<                   $chunk =~ s/(^|[^ ])(\r?\n|\Z)/$1<br>$2/mg;
                  #chunk =~ s/(^|[^ ])(\r?\n|\Z)/$1<br>$2/mg;
                  $chunk = &flowed($chunk);


sub flowed {
    my $chunk = shift;
    $chunk =~ s/\r?\n/\n/g;
    $chunk =~ s/\s+$//;

    # Special treatment of two or three blank lines (more
    # than three blank lines are reduced to three)
    $chunk =~ s/\n{4,}/\n\n<br>\n<br>\n\n/g;
    $chunk =~ s/\n{3}/\n\n<br>\n\n/g;

    # Split into paragraphs
    my @paras = split (/\n\n/, $chunk);
    for my $para (@paras) {

      # Decide if the paragraph is fixed or flowed
      my $fixed = 1;
      my @lines = split (/\n/, $para);
      for (@lines) {
          if (/ $/) {
              $fixed = 0;

      unless ($para =~ /<br>/) {
          if ($fixed) {
              $para = "\n<pre>$para\n</pre>";
          } else {
              for (@lines) {
                  s/([^ ])$/$1<br>/;
              $para = join ("\n", @lines);
    $chunk = join ("\n", @paras) . "\n<br>";

Description: Zip compressed data

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