diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl index 5d556d9469..c7862097ca 100755 --- a/gitweb/gitweb.perl +++ b/gitweb/gitweb.perl @@ -7075,7 +7075,19 @@ sub git_blob { # we can have blame only for text/* mimetype $have_blame &&= ($mimetype =~ m!^text/!); + my $highlight_js = gitweb_check_feature('syntaxhighlighter_js'); + if ($highlight_js) { + push @stylesheets, $highlight_js->{url} . '/styles/shCore' + . $highlight_js->{style} . '.css'; + push @stylesheets, $highlight_js->{url} . '/styles/shTheme' + . $highlight_js->{theme} . '.css'; + } + my $highlight = gitweb_check_feature('highlight'); + if ($highlight_js && $highlight) { + die_error(500, 'The highlight and syntaxhighlighter_js are' + . 'mutually exclusive'); + } my $syntax = guess_file_syntax($highlight, $mimetype, $file_name); $fd = run_highlighter($fd, $highlight, $syntax) if $syntax; @@ -7123,6 +7135,58 @@ sub git_blob { href(action=>"blob_plain", hash=>$hash, hash_base=>$hash_base, file_name=>$file_name) . qq!" />\n!; + } elsif ($highlight_js) { + my $ext = $file_name; + $ext =~ s/.*\.//; + print qq!
!;
+		while (my $line = <$fd>) {
+			$line =~ s!&!\&!g;
+			$line =~ s!!;
+		foreach my $name ('Core', 'Autoloader') {
+			print qq!!;
+		}
+		print qq!!;
 	} else {
 		my $nr;
 		while (my $line = <$fd>) {