Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit cb19976

Browse files
committed
fix_font(): Instead of using a long if/elsif cluster, use a bloody
dictionary. Added some entries to the dictionary to fix part of SF bug #451556.
1 parent 457c419 commit cb19976

1 file changed

Lines changed: 16 additions & 23 deletions

File tree

Doc/perl/python.perl

Lines changed: 16 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1182,33 +1182,26 @@ sub do_cmd_memberlineni{
11821182

11831183
@col_aligns = ('<td>', '<td>', '<td>', '<td>', '<td>');
11841184

1185+
%FontConversions = ('cdata' => 'tt class="cdata"',
1186+
'character' => 'tt class="character"',
1187+
'class' => 'tt class="class"',
1188+
'command' => 'code',
1189+
'constant' => 'tt class="constant"',
1190+
'exception' => 'tt class="exception"',
1191+
'file' => 'tt class="file"',
1192+
'filenq' => 'tt class="file"',
1193+
'kbd' => 'kbd',
1194+
'member' => 'tt class="member"',
1195+
'programopt' => 'b',
1196+
'textrm' => '',
1197+
);
1198+
11851199
sub fix_font{
11861200
# do a little magic on a font name to get the right behavior in the first
11871201
# column of the output table
11881202
my $font = @_[0];
1189-
if ($font eq 'textrm') {
1190-
$font = '';
1191-
}
1192-
elsif ($font eq 'file' || $font eq 'filenq') {
1193-
$font = 'tt class="file"';
1194-
}
1195-
elsif ($font eq 'member') {
1196-
$font = 'tt class="member"';
1197-
}
1198-
elsif ($font eq 'class') {
1199-
$font = 'tt class="class"';
1200-
}
1201-
elsif ($font eq 'constant') {
1202-
$font = 'tt class="constant"';
1203-
}
1204-
elsif ($font eq 'kbd') {
1205-
$font = 'kbd';
1206-
}
1207-
elsif ($font eq 'programopt') {
1208-
$font = 'b';
1209-
}
1210-
elsif ($font eq 'exception') {
1211-
$font = 'tt class="exception"';
1203+
if (defined $FontConversions{$font}) {
1204+
$font = $FontConversions{$font};
12121205
}
12131206
return $font;
12141207
}

0 commit comments

Comments
 (0)