]> Sergey Matveev's repositories - public-inbox.git/commitdiff
viewdiff: do not anchor spaces after filenames in diffstat
authorEric Wong <e@80x24.org>
Sat, 4 Jan 2020 09:16:21 +0000 (09:16 +0000)
committerEric Wong <e@80x24.org>
Sat, 4 Jan 2020 09:35:28 +0000 (09:35 +0000)
Viewing a CSS-less page in a browser which underlines links
can show a long line of underscores after diffstats.  Not all
browsers underline links by default, though.

lib/PublicInbox/ViewDiff.pm

index 4669e8746f043ac7ca840f5e699cbb478a85a4ac..4d72eb4807199c272c32f133fbcbfb38e982648a 100644 (file)
@@ -104,8 +104,9 @@ sub anchor0 ($$$$$) {
 
        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>'.
+                       ascii_html($orig) . '</a>' . $spaces .
                        to_html($linkify, $rest);
                return 1;
        }