Skip to content

Commit 61bf126

Browse files
asedenogitster
authored andcommitted
gitweb: move highlight config out of guess_file_syntax()
Move highlight config out of guess_file_syntax() so that it can be extended/overridden by system/user configuration. Signed-off-by: Alejandro R. Sedeño <asedeno@mit.edu> Acked-by: Jakub Narebski <jnareb@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 43e331e commit 61bf126

1 file changed

Lines changed: 23 additions & 24 deletions

File tree

gitweb/gitweb.perl

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,29 @@ sub evaluate_uri {
232232
# Leave it undefined (or set to 'undef') to turn off load checking.
233233
our $maxload = 300;
234234

235+
# configuration for 'highlight' (http://www.andre-simon.de/)
236+
# match by basename
237+
our %highlight_basename = (
238+
#'Program' => 'py',
239+
#'Library' => 'py',
240+
'SConstruct' => 'py', # SCons equivalent of Makefile
241+
'Makefile' => 'make',
242+
);
243+
# match by extension
244+
our %highlight_ext = (
245+
# main extensions, defining name of syntax;
246+
# see files in /usr/share/highlight/langDefs/ directory
247+
map { $_ => $_ }
248+
qw(py c cpp rb java css php sh pl js tex bib xml awk bat ini spec tcl),
249+
# alternate extensions, see /etc/highlight/filetypes.conf
250+
'h' => 'c',
251+
map { $_ => 'cpp' } qw(cxx c++ cc),
252+
map { $_ => 'php' } qw(php3 php4),
253+
map { $_ => 'pl' } qw(perl pm), # perhaps also 'cgi'
254+
'mak' => 'make',
255+
map { $_ => 'xml' } qw(xhtml html htm),
256+
);
257+
235258
# You define site-wide feature defaults here; override them with
236259
# $GITWEB_CONFIG as necessary.
237260
our %feature = (
@@ -3316,30 +3339,6 @@ sub blob_contenttype {
33163339
sub guess_file_syntax {
33173340
my ($highlight, $mimetype, $file_name) = @_;
33183341
return undef unless ($highlight && defined $file_name);
3319-
3320-
# configuration for 'highlight' (http://www.andre-simon.de/)
3321-
# match by basename
3322-
my %highlight_basename = (
3323-
#'Program' => 'py',
3324-
#'Library' => 'py',
3325-
'SConstruct' => 'py', # SCons equivalent of Makefile
3326-
'Makefile' => 'make',
3327-
);
3328-
# match by extension
3329-
my %highlight_ext = (
3330-
# main extensions, defining name of syntax;
3331-
# see files in /usr/share/highlight/langDefs/ directory
3332-
map { $_ => $_ }
3333-
qw(py c cpp rb java css php sh pl js tex bib xml awk bat ini spec tcl),
3334-
# alternate extensions, see /etc/highlight/filetypes.conf
3335-
'h' => 'c',
3336-
map { $_ => 'cpp' } qw(cxx c++ cc),
3337-
map { $_ => 'php' } qw(php3 php4),
3338-
map { $_ => 'pl' } qw(perl pm), # perhaps also 'cgi'
3339-
'mak' => 'make',
3340-
map { $_ => 'xml' } qw(xhtml html htm),
3341-
);
3342-
33433342
my $basename = basename($file_name, '.in');
33443343
return $highlight_basename{$basename}
33453344
if exists $highlight_basename{$basename};

0 commit comments

Comments
 (0)