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

Skip to content

Commit 64bdc24

Browse files
committed
Code cleanup, some syntax modernization.
1 parent 6b303b4 commit 64bdc24

1 file changed

Lines changed: 115 additions & 46 deletions

File tree

Doc/perl/l2hinit.perl

Lines changed: 115 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -55,34 +55,104 @@ sub find_my_file{
5555

5656

5757
sub make_nav_panel{
58-
($NEXT_TITLE ? "$NEXT\n" : '')
59-
. ($UP_TITLE ? "$UP\n" : '')
60-
. ($PREVIOUS_TITLE ? "$PREVIOUS\n" : '')
61-
. "$CONTENTS\n$INDEX"
58+
($NEXT_TITLE ? $NEXT : '')
59+
. ($UP_TITLE ? $UP : '')
60+
. ($PREVIOUS_TITLE ? $PREVIOUS : '')
61+
. $CONTENTS
62+
. $INDEX
6263
# . " $CUSTOM_BUTTONS"
63-
. "<br>\n"
64-
. ($NEXT_TITLE ? "<b> Next:</b> $NEXT_TITLE\n" : '')
64+
. "\n<br>\n"
65+
. ($NEXT_TITLE ? "<b>Next:</b> $NEXT_TITLE\n" : '')
6566
. ($UP_TITLE ? "<b>Up:</b> $UP_TITLE\n" : '')
6667
. ($PREVIOUS_TITLE ? "<b>Previous:</b> $PREVIOUS_TITLE\n" : '');
6768
}
6869

6970
sub top_navigation_panel {
7071
"<div class=navigation>\n"
71-
. &make_nav_panel
72-
. "<br><hr><p></div>"
72+
. make_nav_panel()
73+
. '<br><hr><p></div>';
7374
}
7475

7576
sub bot_navigation_panel {
7677
"<p>\n<div class=navigation><hr>"
77-
. &make_nav_panel
78-
. "</div>"
78+
. make_nav_panel()
79+
. '</div>';
80+
}
81+
82+
sub add_link {
83+
# Returns a pair (iconic link, textual link)
84+
my($icon, $current_file, @link) = @_;
85+
my($dummy, $file, $title) = split($delim,
86+
$toc_section_info{join(' ',@link)});
87+
if ($title && ($file ne $current_file)) {
88+
$title = purify($title);
89+
$title = get_first_words($title, $WORDS_IN_NAVIGATION_PANEL_TITLES);
90+
return (make_href($file, $icon), make_href($file, "$title"))
91+
}
92+
elsif ($icon eq $up_visible_mark && $EXTERNAL_UP_LINK) {
93+
return (make_href($EXTERNAL_UP_LINK, $icon),
94+
make_href($EXTERNAL_UP_LINK, "$EXTERNAL_UP_TITLE"))
95+
}
96+
elsif (($icon eq $previous_visible_mark
97+
|| $icon eq $previous_page_visible_mark)
98+
&& $EXTERNAL_PREV_LINK && $EXTERNAL_PREV_TITLE) {
99+
return (make_href($EXTERNAL_PREV_LINK, $icon),
100+
make_href($EXTERNAL_PREV_LINK, "$EXTERNAL_PREV_TITLE"))
101+
}
102+
elsif (($icon eq $next_visible_mark
103+
|| $icon eq $next_page_visible_mark)
104+
&& $EXTERNAL_DOWN_LINK && $EXTERNAL_DOWN_TITLE) {
105+
return (make_href($EXTERNAL_DOWN_LINK, $icon),
106+
make_href($EXTERNAL_DOWN_LINK, "$EXTERNAL_DOWN_TITLE"))
107+
}
108+
(&inactive_img($icon), "");
109+
}
110+
111+
sub add_special_link {
112+
my($icon, $file, $current_file) = @_;
113+
(($file && ($file ne $current_file)) ? make_href($file, $icon) : undef)
114+
}
115+
116+
sub img_tag {
117+
local($icon) = @_;
118+
my $alt;
119+
my $align = " align=bottom ";
120+
121+
$alt = join('|', 'up', 'next_group', 'previous_group'
122+
, 'next', 'previous', 'change_begin_right', 'change_begin'
123+
, 'change_end_right', 'change_end', 'change_delete_right'
124+
, 'change_delete', 'contents', 'index');
125+
126+
if ($icon =~ /(gif|png)$/) {
127+
$used_icons{$icon} = 1;
128+
if ($icon =~ /change_(begin|end|delete)_right/) { $align = ' ' };
129+
my $nav_border = "$NAV_BORDER";
130+
if ($icon =~ /($alt)/) {
131+
$alt = $1;
132+
}
133+
else {
134+
$nav_border = '1';
135+
$alt = '[*]';
136+
};
137+
if ($LOCAL_ICONS) {
138+
return join('', '<img ', $iconsizes{$1}, $align
139+
,'border=', $nav_border, ' alt="', $alt
140+
,'" src="', $icon, '">' );
141+
}
142+
return join('', '<img ', $iconsizes{$1}, $align
143+
,'border=', $nav_border, ' alt="', $alt, '"\n'
144+
,' src="', $ICONSERVER, "/$icon", '">' );
145+
}
146+
else {
147+
return $icon;
148+
}
79149
}
80150

81151

82152
sub gen_index_id {
83153
# this is used to ensure common index key generation and a stable sort
84154
my($str,$extra) = @_;
85-
sprintf("%s###%s%010d", $str, $extra, ++$global{'max_id'});
155+
sprintf('%s###%s%010d', $str, $extra, ++$global{'max_id'});
86156
}
87157

88158
sub make_index_entry {
@@ -92,16 +162,21 @@ sub make_index_entry {
92162
$TITLE = $ref_before unless $TITLE;
93163
# Save the reference
94164
$str = gen_index_id($str, '');
95-
$index{$str} .= &make_half_href("$CURRENT_FILE#$br_id");
165+
$index{$str} .= make_half_href("$CURRENT_FILE#$br_id");
96166
"<a name=\"$br_id\">$anchor_invisible_mark<\/a>";
97167
}
98168

99-
# use this instead with the buildindex.py tool
169+
170+
sub insert_index{
171+
my($mark,$datafile) = @_;
172+
my $index = `$myrootdir/tools/buildindex.py $datafile`;
173+
s/$mark/$index/;
174+
}
175+
100176
sub add_idx{
101177
print "\nDoing the index ...";
102178
close(IDXFILE);
103-
my $index = `$myrootdir/tools/buildindex.py index.dat`;
104-
s/$idx_mark/$index/;
179+
insert_index($idx_mark, 'index.dat');
105180
}
106181

107182

@@ -111,15 +186,13 @@ sub add_idx{
111186
sub add_module_idx{
112187
print "\nDoing the module index ...";
113188
my $key;
114-
my $index = "<p>";
115-
open(MODIDXFILE, ">modindex.dat") || die "\n$!\n";
189+
open(MODIDXFILE, '>modindex.dat') || die "\n$!\n";
116190
foreach $key (keys %Modules) {
117191
# dump the line in the data file; just use a dummy seqno field
118192
print MODIDXFILE "$Modules{$key}" . $IDXFILE_FIELD_SEP . "$key###\n";
119193
}
120194
close(MODIDXFILE);
121-
$index = `$myrootdir/tools/buildindex.py modindex.dat`;
122-
s/$idx_module_mark/$index<p>/;
195+
insert_index($idx_module_mark, 'modindex.dat');
123196
}
124197

125198
# replace both indexes as needed:
@@ -134,39 +207,39 @@ sub do_cmd_tableofcontents {
134207
local($_) = @_;
135208
$TITLE = $toc_title;
136209
$tocfile = $CURRENT_FILE;
137-
my($closures,$reopens) = &preserve_open_tags();
138-
&anchor_label("contents",$CURRENT_FILE,$_); # this is added
210+
my($closures,$reopens) = preserve_open_tags();
211+
anchor_label('contents', $CURRENT_FILE, $_); # this is added
139212
join('', "<BR>\n", $closures
140-
, &make_section_heading($toc_title, "H2"), $toc_mark
213+
, make_section_heading($toc_title, 'H2'), $toc_mark
141214
, $reopens, $_);
142215
}
143216
# In addition to the standard stuff, add label to allow named node files.
144217
sub do_cmd_listoffigures {
145218
local($_) = @_;
146219
$TITLE = $lof_title;
147220
$loffile = $CURRENT_FILE;
148-
my($closures,$reopens) = &preserve_open_tags();
149-
&anchor_label("lof",$CURRENT_FILE,$_); # this is added
221+
my($closures,$reopens) = preserve_open_tags();
222+
anchor_label('lof', $CURRENT_FILE, $_); # this is added
150223
join('', "<BR>\n", $closures
151-
, &make_section_heading($lof_title, "H2"), $lof_mark
224+
, make_section_heading($lof_title, 'H2'), $lof_mark
152225
, $reopens, $_);
153226
}
154227
# In addition to the standard stuff, add label to allow named node files.
155228
sub do_cmd_listoftables {
156229
local($_) = @_;
157230
$TITLE = $lot_title;
158231
$lotfile = $CURRENT_FILE;
159-
my($closures,$reopens) = &preserve_open_tags();
160-
&anchor_label("lot",$CURRENT_FILE,$_); # this is added
232+
my($closures,$reopens) = preserve_open_tags();
233+
anchor_label('lot', $CURRENT_FILE, $_); # this is added
161234
join('', "<BR>\n", $closures
162-
, &make_section_heading($lot_title, "H2"), $lot_mark
235+
, make_section_heading($lot_title, 'H2'), $lot_mark
163236
, $reopens, $_);
164237
}
165238
# In addition to the standard stuff, add label to allow named node files.
166239
sub do_cmd_textohtmlinfopage {
167240
local($_) = @_;
168241
if ($INFO) { #
169-
&anchor_label("about",$CURRENT_FILE,$_); # this is added
242+
anchor_label("about",$CURRENT_FILE,$_); # this is added
170243
} #
171244
( ($INFO == 1)
172245
? join('', $close_all
@@ -201,7 +274,7 @@ sub do_cmd_textohtmlindex {
201274
sub do_cmd_textohtmlmoduleindex {
202275
local($_) = @_;
203276
$TITLE = $idx_module_title;
204-
&anchor_label("modindex",$CURRENT_FILE,$_);
277+
anchor_label("modindex",$CURRENT_FILE,$_);
205278
'<p>' . make_section_heading($idx_module_title, "h2")
206279
. $idx_module_mark . $_;
207280
}
@@ -245,7 +318,7 @@ sub add_bbl_and_idx_dummy_commands {
245318
s/[\\]printindex/\\textohtmlindex /o;
246319
}
247320
#----------------------------------------------------------------------
248-
&lib_add_bbl_and_idx_dummy_commands()
321+
lib_add_bbl_and_idx_dummy_commands()
249322
if defined(&lib_add_bbl_and_idx_dummy_commands);
250323
}
251324

@@ -270,20 +343,16 @@ sub set_depth_levels {
270343
$MAX_SPLIT_DEPTH = $level + $MAX_SPLIT_DEPTH;
271344
} elsif (!($MAX_SPLIT_DEPTH)) { $MAX_SPLIT_DEPTH = 1 };
272345

273-
%unnumbered_section_commands = (
274-
'tableofcontents', $level
275-
, 'listoffigures', $level
276-
, 'listoftables', $level
277-
, 'bibliography', $level
278-
, 'textohtmlindex', $level
279-
, 'textohtmlmoduleindex', $level
280-
);
281-
$section_headings{'textohtmlmoduleindex'} = "h1";
282-
283-
%section_commands = (
284-
%unnumbered_section_commands
285-
, %section_commands
286-
);
346+
%unnumbered_section_commands = ('tableofcontents' => $level,
347+
'listoffigures' => $level,
348+
'listoftables' => $level,
349+
'bibliography' => $level,
350+
'textohtmlindex' => $level,
351+
'textohtmlmoduleindex' => $level);
352+
$section_headings{'textohtmlmoduleindex'} = 'h1';
353+
354+
%section_commands = (%unnumbered_section_commands,
355+
%section_commands);
287356

288357
make_sections_rx();
289358
}
@@ -315,7 +384,7 @@ sub protect_useritems {
315384
# style support file. The %declarations must be set before initialize()
316385
# is called in the main script.
317386
#
318-
%declarations = ('preform', '<dl><dd><pre></pre></dl>',
387+
%declarations = ('preform' => '<dl><dd><pre></pre></dl>',
319388
%declarations);
320389

321390
1; # This must be the last line

0 commit comments

Comments
 (0)