+ $$dst .= qq(<span\nclass="$class">);
+}
+
+sub anchor0 ($$$$$) {
+ my ($dst, $ctx, $linkify, $fn, $rest) = @_;
+
+ my $orig = $fn;
+
+ # normal git diffstat output is impossible to parse reliably
+ # without --numstat, and that isn't the default for format-patch.
+ # So only do best-effort handling of renames for common cases;
+ # which works well in practice. If projects put "=>", or trailing
+ # spaces in filenames, oh well :P
+ $fn =~ s/(?: *$DIFFSTAT_COMMENT)? *\z//so;
+ $fn =~ s/{(?:.+) => (.+)}/$1/ or $fn =~ s/.* => (.+)/$1/;
+ $fn = git_unquote($fn);
+
+ # long filenames will require us to walk backwards in anchor1
+ if ($fn =~ s!\A\.\.\./?!!) {
+ my $lp = $ctx->{-long_path} ||= {};
+ $lp->{$fn} = qr/\Q$fn\E\z/s;
+ }
+
+ if (my $attr = to_attr($ctx->{-apfx}.$fn)) {
+ $ctx->{-anchors}->{$attr} = 1;
+ my $spaces = ($orig =~ s/( +)\z//) ? $1 : '';
+ $$dst .= " <a\nid=i$attr\nhref=#$attr>" .
+ ascii_html($orig) . '</a>' . $spaces .
+ to_html($linkify, $rest);
+ return 1;
+ }
+ undef;