- my ($quot, $n, $part_nr, $full_pfx, $final, $do_anchor) = @_;
-
- # n.b.: do not use <blockquote> since it screws up alignment
- # w.r.t. unquoted text. Repliers may rely on pre-formatted
- # alignment to point out a certain word in quoted text.
- if ($full_pfx) {
- if (!$final && scalar(@$quot) <= MAX_INLINE_QUOTED) {
- # show quote inline
- my %l;
- my $rv = join('', map { linkify_1(\%l, $_) } @$quot);
- @$quot = ();
- $rv = ascii_html($rv);
- return linkify_2(\%l, $rv);
- }
-
- # show a short snippet of quoted text and link to full version:
- @$quot = map { s/^(?:>\s*)+//gm; $_ } @$quot;
- my $cur = join(' ', @$quot);
- @$quot = split(/\s+/, $cur);
- $cur = '';
- do {
- my $tmp = shift(@$quot);
- my $len = length($tmp) + length($cur);
- if ($len > MAX_TRUNC_LEN) {
- @$quot = ();
- } else {
- $cur .= $tmp . ' ';
- }
- } while (@$quot && length($cur) < MAX_TRUNC_LEN);
- @$quot = ();
- $cur =~ s/ \z/ .../s;
- $cur = ascii_html($cur);
- my $nr = ++$$n;
- "> [<a\nhref=\"$full_pfx#q${part_nr}_$nr\">$cur</a>]\n";
+ my ($s, $l, $quot) = @_;
+
+ # show everything in the full version with anchor from
+ # short version (see above)
+ my $rv = $l->linkify_1(join('', @$quot));
+ @$quot = ();
+
+ # we use a <div> here to allow users to specify their own
+ # color for quoted text
+ $rv = $l->linkify_2(ascii_html($rv));
+ $$s .= qq(<span\nclass="q">) . $rv . '</span>'
+}
+
+sub attach_link ($$$$) {
+ my ($upfx, $ct, $p, $fn) = @_;
+ my ($part, $depth, @idx) = @$p;
+ my $nl = $idx[-1] > 1 ? "\n" : '';
+ my $idx = join('.', @idx);
+ my $size = bytes::length($part->body);
+ $ct ||= 'text/plain';
+ $ct =~ s/;.*//; # no attributes
+ $ct = ascii_html($ct);
+ my $desc = $part->header('Content-Description');
+ $desc = $fn unless defined $desc;
+ $desc = '' unless defined $desc;
+ my $sfn;
+ if (defined $fn && $fn =~ /\A[[:alnum:]][\w\.-]+[[:alnum:]]\z/) {
+ $sfn = $fn;
+ } elsif ($ct eq 'text/plain') {
+ $sfn = 'a.txt';