No point in wasting bytes even if gets compressed over
the wire, it'll use more memory when rendering on the
client.
        # Drop signatures
        $s =~ s/^-- \n.*\z//ms and $$more = 'more...';
 
-       # kill any leading or trailing whitespace
-       $s =~ s/\A\s+//s;
+       # kill any leading or trailing whitespace lines
+       $s =~ s/^[ \t]$//sgm;
        $s =~ s/\s+\z//s;
 
        if (length $s) {
                # add prefix:
                $s =~ s/^/$pfx/sgm;
 
+               # kill per-line trailing whitespace
+               $s =~ s/[ \t]+$//sgm;
+
                $rv .= $s . "\n";
        }
        $rv;