]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/View.pm
viewdiff: rewrite and simplify
[public-inbox.git] / lib / PublicInbox / View.pm
index fd1bd7e2add29f423398dc6b32b6093a820537ea..ff36777c60f482286fc92921a4591ba52c184634 100644 (file)
@@ -496,13 +496,10 @@ sub multipart_text_as_html {
 sub flush_quote {
        my ($s, $l, $quot) = @_;
 
-       # show everything in the full version with anchor from
-       # short version (see above)
-       my $rv = $l->linkify_1($$quot);
+       my $rv = $l->to_html($$quot);
 
        # we use a <span> here to allow users to specify their own
        # color for quoted text
-       $rv = $l->linkify_2(ascii_html($rv));
        $$quot = undef;
        $$s .= qq(<span\nclass="q">) . $rv . '</span>'
 }
@@ -565,7 +562,7 @@ sub add_text_body { # callback for msg_iter
                $idx[0] = $upfx . $idx[0] if $upfx ne '';
                $ctx->{-apfx} = join('/', @idx);
                $ctx->{-anchors} = {}; # attr => filename
-               $ctx->{-diff} = $diff = [];
+               $diff = 1;
                delete $ctx->{-long_path};
                my $spfx;
                if ($ibx->{-repo_objs}) {
@@ -598,18 +595,15 @@ sub add_text_body { # callback for msg_iter
                attach_link($ctx, $ct, $p, $fn, $err);
                $$rv .= "\n";
        }
-       my $l = PublicInbox::Linkify->new;
+       my $l = $ctx->{-linkify} //= PublicInbox::Linkify->new;
        foreach my $cur (@sections) {
                if ($cur =~ /\A>/) {
                        flush_quote($rv, $l, \$cur);
                } elsif ($diff) {
-                       @$diff = split(/^/m, $cur);
-                       $cur = undef;
-                       flush_diff($rv, $ctx, $l);
+                       flush_diff($rv, $ctx, \$cur);
                } else {
                        # regular lines, OK
-                       $l->linkify_1($cur);
-                       $$rv .= $l->linkify_2(ascii_html($cur));
+                       $$rv .= $l->to_html($cur);
                        $cur = undef;
                }
        }