about summary refs log tree commit homepage
path: root/lib/PublicInbox/ViewVCS.pm
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2019-01-27 11:38:42 +0000
committerEric Wong <e@80x24.org>2019-01-27 11:43:34 +0000
commit603d9ebc517fcf89ab6d2e7845b118aa6b8e9069 (patch)
treedd5b7906bd1cc02992a058aa350f8686f0f87d99 /lib/PublicInbox/ViewVCS.pm
parentfd8e62c1ed9b9f7eb851a263a9ada2cb8c182193 (diff)
downloadpublic-inbox-603d9ebc517fcf89ab6d2e7845b118aa6b8e9069.tar.gz
And update 216dark.css to match a color scheme I'm used to;
which is fairly minimal and doesn't use all the classes
"highlight" provides.
Diffstat (limited to 'lib/PublicInbox/ViewVCS.pm')
-rw-r--r--lib/PublicInbox/ViewVCS.pm15
1 files changed, 14 insertions, 1 deletions
diff --git a/lib/PublicInbox/ViewVCS.pm b/lib/PublicInbox/ViewVCS.pm
index 5de37ee6..a8aa0b61 100644
--- a/lib/PublicInbox/ViewVCS.pm
+++ b/lib/PublicInbox/ViewVCS.pm
@@ -21,6 +21,11 @@ use PublicInbox::SolverGit;
 use PublicInbox::WwwStream;
 use PublicInbox::Linkify;
 use PublicInbox::Hval qw(ascii_html to_filename);
+my $hl = eval {
+        require PublicInbox::HlMod;
+        PublicInbox::HlMod->new;
+};
+
 my %QP_MAP = ( A => 'oid_a', B => 'oid_b', a => 'path_a', b => 'path_b' );
 my $max_size = 1024 * 1024; # TODO: configurable
 my $enc_utf8 = find_encoding('UTF-8');
@@ -88,6 +93,14 @@ sub solve_result {
         my $nl = ($$blob =~ tr/\n/\n/);
         my $pad = length($nl);
 
+        $l->linkify_1($$blob);
+        my $ok = $hl->do_hl($blob, $path) if $hl;
+        if ($ok) {
+                $blob = $ok;
+        } else {
+                $$blob = ascii_html($$blob);
+        }
+
         # using some of the same CSS class names and ids as cgit
         $log = "<pre>$oid $type $size bytes $raw_link</pre>" .
                 "<hr /><table\nclass=blob>".
@@ -96,7 +109,7 @@ sub solve_result {
                 } (1..$nl)) . '</pre></td>' .
                 '<td><pre> </pre></td>'. # pad for non-CSS users
                 "<td\nclass=lines><pre\nstyle='white-space:pre'><code>" .
-                ascii_html($$blob) .
+                $l->linkify_2($$blob) .
                 '</code></pre></td></tr></table>' . $log;
 
         html_page($ctx, 200, \$log);