From 4dcd50cd53223f7c8a40aa231af23995abe1c3a1 Mon Sep 17 00:00:00 2001 From: Aaron Taylor Date: Thu, 17 Jun 2021 16:09:54 -0700 Subject: [PATCH] Line numbers are no longer selectable by default, easing copy+paste of code snippets. --- gitweb.cgi | 8 ++++---- static/gitweb.css | 6 ++++++ 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/gitweb.cgi b/gitweb.cgi index 56881e1..c24d40b 100755 --- a/gitweb.cgi +++ b/gitweb.cgi @@ -6411,9 +6411,9 @@ sub git_search_files { $ltext = esc_html($ltext, -nbsp=>1); } print "
" . - $cgi->a({-href => $file_href.'#l'.$lno, - -class => "linenr"}, sprintf('%4i', $lno)) . - ' ' . $ltext . "
\n"; + "" . + "" . $ltext . "\n"; } } if ($lastfile) { @@ -7208,7 +7208,7 @@ sub git_blob { chomp $line; $nr++; $line = untabify($line); - printf qq!
%4i %s
\n!, + printf qq!
%s
\n!, $nr, esc_attr(href(-replay => 1)), $nr, $nr, $highlight ? sanitize($line) : esc_html($line, -nbsp=>1); } diff --git a/static/gitweb.css b/static/gitweb.css index 44ce42b..8e93114 100644 --- a/static/gitweb.css +++ b/static/gitweb.css @@ -782,3 +782,9 @@ td.pre, div.pre, div.diff { .kwb { color:#6b3099; } .kwc { color:#d4663d; } .kwd { color:#2928ff; } + +/* Unselectable line numbers for easier copy+paste. */ + +[unselectable-linenr]::before { + content: attr(unselectable-linenr); +} -- 2.20.1