+ ("<html><head><title>". join(' - ', @title) .
+ '</title></head><body><pre style="white-space:pre-wrap">' . $rv);
+}
+
+sub html_footer {
+ my ($mime) = @_;
+ my %cc; # everyone else
+ my $to; # this is the From address
+
+ foreach my $h (qw(From To Cc)) {
+ my $v = $mime->header($h);
+ defined($v) && length($v) or next;
+ my @addrs = Email::Address->parse($v);
+ foreach my $recip (@addrs) {
+ my $address = $recip->address;
+ my $dst = lc($address);
+ $cc{$dst} ||= $address;
+ $to ||= $dst;
+ }
+ }
+ Email::Address->purge_cache;
+
+ my $subj = $mime->header('Subject') || '';
+ $subj = "Re: $subj" unless $subj =~ /\bRe:/;
+ my $irp = uri_escape_utf8(
+ $mime->header_obj->header_raw('Message-ID') || '');
+ delete $cc{$to};
+ $to = uri_escape_utf8($to);
+ $subj = uri_escape_utf8($subj);
+
+ my $cc = uri_escape_utf8(join(',', values %cc));
+ my $href = "mailto:$to?In-Reply-To=$irp&Cc=${cc}&Subject=$subj";
+
+ '<a href="' . ascii_html($href) . '">reply</a>';
+}
+
+sub linkify_refs {
+ join(' ', map {
+ my $v = PublicInbox::Hval->new_msgid($_);
+ my $html = $v->as_html;
+ my $href = $v->as_href;
+ "<<a href=\"$href.html\">$html</a>>";
+ } @_);