blob: 8d737c0ee44d19da80d1030a1db49d4996738f71 [file] [log] [blame]
Fred Drakebc7101d1998-03-06 21:18:55 +00001#LaTeX2HTML Version 96.1 : dot.latex2html-init -*- perl -*-
2#
Fred Drake13210ed1998-03-17 06:28:05 +00003# Significantly revised by Fred L. Drake, Jr. <fdrake@acm.org> for use
4# with the Python documentation.
5#
6# New name to avoid distributing "dot" files with the Python documentation.
7#
Fred Drakebc7101d1998-03-06 21:18:55 +00008
Fred Drake41814bc1998-05-11 18:23:35 +00009package Override;
10
11use Cwd qw(getcwd);
12
13
14package main;
15
Fred Drake28e7b4c1998-10-20 18:14:20 +000016$HTML_VERSION = 4.0;
17
Fred Drake6aa5d481998-08-11 03:14:50 +000018$MAX_LINK_DEPTH = 2;
Fred Draked7571651998-04-23 20:06:24 +000019$ADDRESS = '';
Fred Drakebc7101d1998-03-06 21:18:55 +000020
Fred Drakee194beb1998-05-19 19:38:49 +000021$NO_FOOTNODE = 1;
Fred Drakebc7101d1998-03-06 21:18:55 +000022$NUMBERED_FOOTNOTES = 1;
23
24# Python documentation uses section numbers to support references to match
25# in the printed and online versions.
26#
27$SHOW_SECTION_NUMBERS = 1;
28
29$ICONSERVER = '../icons';
30
Fred Drake6aa5d481998-08-11 03:14:50 +000031# Control where the navigation bars should show up:
32$TOP_NAVIGATION = 1;
33$BOTTOM_NAVIGATION = 1;
34$AUTO_NAVIGATION = 0;
35
Fred Drake0cb76201998-08-07 16:43:29 +000036$BODYTEXT = 'bgcolor="#ffffff"';
Fred Drakebc7101d1998-03-06 21:18:55 +000037$CHILDLINE = "\n<p><hr>\n";
38$VERBOSITY = 0;
Fred Drakebc7101d1998-03-06 21:18:55 +000039
Fred Drake4d10b431998-08-07 20:51:58 +000040# default # of columns for the indexes
Fred Drakeaa3f9fb1998-08-07 19:52:37 +000041$INDEX_COLUMNS = 2;
Fred Drake2383f6d1999-03-02 16:00:37 +000042$MODULE_INDEX_COLUMNS = 4;
Fred Drakeaa3f9fb1998-08-07 19:52:37 +000043
Fred Drakec9f2c141998-03-11 12:08:21 +000044
Fred Drakedb34a1e1998-03-10 23:02:57 +000045# A little painful, but lets us clean up the top level directory a little,
46# and not be tied to the current directory (as far as I can tell).
47#
Fred Drakec9f2c141998-03-11 12:08:21 +000048use Cwd;
49use File::Basename;
50($myname, $mydir, $myext) = fileparse(__FILE__, '\..*');
51chop $mydir; # remove trailing '/'
52$mydir = getcwd() . "$dd$mydir"
53 unless $mydir =~ s|^/|/|;
Fred Drakedb34a1e1998-03-10 23:02:57 +000054$LATEX2HTMLSTYLES = "$mydir$envkey$LATEX2HTMLSTYLES";
Fred Drakeb3a3ed81998-07-24 22:17:34 +000055push (@INC, $mydir);
Fred Drakebc7101d1998-03-06 21:18:55 +000056
Fred Drake235e6b11998-03-27 05:19:43 +000057($myrootname, $myrootdir, $myext) = fileparse($mydir, '\..*');
58chop $myrootdir;
59
Fred Drakebc7101d1998-03-06 21:18:55 +000060
Fred Drakea4565b01998-05-15 17:14:17 +000061# Hackish way to get the appropriate paper-*/ directory into $TEXINPUTS;
62# pass in the paper size (a4 or letter) as the environment variable PAPER
63# to add the right directory. If not given, the current directory is
64# added instead for use with HOWTO processing.
65#
66if (defined $ENV{'PAPER'}) {
67 $mytexinputs = "$myrootdir${dd}paper-$ENV{'PAPER'}$envkey";
68}
69else {
70 $mytexinputs = getcwd() . $envkey;
71}
72$mytexinputs .= "$myrootdir${dd}texinputs";
73
74
75sub custom_driver_hook{
76 #
77 # This adds the directory of the main input file to $TEXINPUTS; it
78 # seems to be sufficiently general that it should be fine for HOWTO
79 # processing.
80 #
81 my $file = @_[0];
82 my($jobname,$dir,$ext) = fileparse($file, '\..*');
83 $dir = make_directory_absolute($dir);
84 $dir =~ s/$dd$//;
85 $TEXINPUTS = "$dir$envkey$mytexinputs";
86 print "\nadding $dir to \$TEXINPUTS\n";
87}
88
89
Fred Drake062bc6e1998-08-13 22:03:46 +000090sub set_icon_size{
91 my($name, $w, $h) = @_;
92 $iconsizes{$name} = "width=$w height=$h";
93}
94
Fred Drake95474f91999-02-09 18:45:50 +000095foreach $name (split(/ /, 'up next previous contents index modules blank')) {
Fred Drake062bc6e1998-08-13 22:03:46 +000096 set_icon_size($name, 32, 32);
97}
98# The '_motif' is really annoying, and makes the HTML larger with no value
99# added, so strip it off:
100foreach $name (keys %icons) {
101 my $icon = $icons{$name};
Fred Drake95474f91999-02-09 18:45:50 +0000102 # Strip off the wasteful '_motif':
Fred Drake062bc6e1998-08-13 22:03:46 +0000103 $icon =~ s/_motif//;
Fred Drake95474f91999-02-09 18:45:50 +0000104 # Change the greyed-out icons to be blank:
105 $icon =~ s/[a-z]*_gr/blank/;
Fred Drake062bc6e1998-08-13 22:03:46 +0000106 $icons{$name} = $icon;
107}
Fred Drake95474f91999-02-09 18:45:50 +0000108$icons{'blank'} = 'blank.' . $IMAGE_TYPE;
Fred Drake9f7adc41998-08-11 19:33:38 +0000109
Fred Drake6aa5d481998-08-11 03:14:50 +0000110$CUSTOM_BUTTONS = '';
Fred Drake95474f91999-02-09 18:45:50 +0000111$BLANK_ICON = "\n<td>" . img_tag('blank.' . $IMAGE_TYPE) . "</td>";
Fred Drakeaa99a501999-03-03 16:21:34 +0000112$BLANK_ICON =~ s/alt="blank"/alt=""/;
Fred Drake7a9ed711999-02-12 19:00:38 +0000113$NAV_BGCOLOR = " bgcolor=\"#99CCFF\"";
Fred Drake6aa5d481998-08-11 03:14:50 +0000114
Fred Drakebeb27bf1999-02-16 17:22:32 +0000115sub make_nav_sectref{
116 my($label,$title) = @_;
117 if ($title) {
118 return ("<b class=navlabel>$label:</b> "
119 . "<span class=sectref>$title</span>\n");
120 }
121 return '';
122}
123
Fred Drake13210ed1998-03-17 06:28:05 +0000124sub make_nav_panel{
Fred Drakeaa99a501999-03-03 16:21:34 +0000125 return ("<table align=center width=\"100%\" cellpadding=0 cellspacing=2>"
126 . "\n<tr>"
Fred Drakebeb27bf1999-02-16 17:22:32 +0000127 . "\n<td>$NEXT</td>"
128 . "\n<td>$UP</td>"
129 . "\n<td>$PREVIOUS</td>"
130 . "\n<td align=center$NAV_BGCOLOR width=\"100%\">"
131 . "\n <b class=title>$t_title</b></td>"
132 . ($CONTENTS ? "\n<td>$CONTENTS</td>" : $BLANK_ICON)
133 . "\n<td>$CUSTOM_BUTTONS</td>" # module index
134 . ($INDEX ? "\n<td>$INDEX</td>" : $BLANK_ICON)
135 . "\n</tr></table>"
136 #. "<hr>"
137 . make_nav_sectref("Next", $NEXT_TITLE)
138 . make_nav_sectref("Up", $UP_TITLE)
139 . make_nav_sectref("Previous", $PREVIOUS_TITLE)
140 );
Fred Drake13210ed1998-03-17 06:28:05 +0000141}
142
Fred Drakebc7101d1998-03-06 21:18:55 +0000143sub top_navigation_panel {
Fred Drake13210ed1998-03-17 06:28:05 +0000144 "<div class=navigation>\n"
Fred Drake64bdc241998-04-17 02:14:12 +0000145 . make_nav_panel()
Fred Drake72e5a901999-02-10 17:35:41 +0000146 . '<br><hr></div>';
Fred Drakebc7101d1998-03-06 21:18:55 +0000147}
148
149sub bot_navigation_panel {
Fred Drake9d4b6c51998-04-11 05:21:14 +0000150 "<p>\n<div class=navigation><hr>"
Fred Drake64bdc241998-04-17 02:14:12 +0000151 . make_nav_panel()
152 . '</div>';
153}
154
155sub add_link {
156 # Returns a pair (iconic link, textual link)
157 my($icon, $current_file, @link) = @_;
158 my($dummy, $file, $title) = split($delim,
Fred Drake28e7b4c1998-10-20 18:14:20 +0000159 $section_info{join(' ',@link)});
Fred Drake64bdc241998-04-17 02:14:12 +0000160 if ($title && ($file ne $current_file)) {
161 $title = purify($title);
162 $title = get_first_words($title, $WORDS_IN_NAVIGATION_PANEL_TITLES);
163 return (make_href($file, $icon), make_href($file, "$title"))
164 }
165 elsif ($icon eq $up_visible_mark && $EXTERNAL_UP_LINK) {
166 return (make_href($EXTERNAL_UP_LINK, $icon),
167 make_href($EXTERNAL_UP_LINK, "$EXTERNAL_UP_TITLE"))
168 }
169 elsif (($icon eq $previous_visible_mark
170 || $icon eq $previous_page_visible_mark)
171 && $EXTERNAL_PREV_LINK && $EXTERNAL_PREV_TITLE) {
172 return (make_href($EXTERNAL_PREV_LINK, $icon),
173 make_href($EXTERNAL_PREV_LINK, "$EXTERNAL_PREV_TITLE"))
174 }
175 elsif (($icon eq $next_visible_mark
176 || $icon eq $next_page_visible_mark)
177 && $EXTERNAL_DOWN_LINK && $EXTERNAL_DOWN_TITLE) {
178 return (make_href($EXTERNAL_DOWN_LINK, $icon),
179 make_href($EXTERNAL_DOWN_LINK, "$EXTERNAL_DOWN_TITLE"))
180 }
181 (&inactive_img($icon), "");
182}
183
184sub add_special_link {
185 my($icon, $file, $current_file) = @_;
186 (($file && ($file ne $current_file)) ? make_href($file, $icon) : undef)
187}
188
189sub img_tag {
190 local($icon) = @_;
191 my $alt;
192 my $align = " align=bottom ";
193
Fred Drake062bc6e1998-08-13 22:03:46 +0000194 # having this list hardcoded here is really bogus....
Fred Drake64bdc241998-04-17 02:14:12 +0000195 $alt = join('|', 'up', 'next_group', 'previous_group'
196 , 'next', 'previous', 'change_begin_right', 'change_begin'
197 , 'change_end_right', 'change_end', 'change_delete_right'
Fred Drake95474f91999-02-09 18:45:50 +0000198 , 'change_delete', 'contents', 'index', 'modules', 'blank');
Fred Drake64bdc241998-04-17 02:14:12 +0000199
200 if ($icon =~ /(gif|png)$/) {
201 $used_icons{$icon} = 1;
202 if ($icon =~ /change_(begin|end|delete)_right/) { $align = ' ' };
203 my $nav_border = "$NAV_BORDER";
204 if ($icon =~ /($alt)/) {
205 $alt = $1;
Fred Drakeaa99a501999-03-03 16:21:34 +0000206 $alt = ""
207 if ($alt eq "blank");
Fred Drake64bdc241998-04-17 02:14:12 +0000208 }
209 else {
210 $nav_border = '1';
211 $alt = '[*]';
212 };
213 if ($LOCAL_ICONS) {
214 return join('', '<img ', $iconsizes{$1}, $align
215 ,'border=', $nav_border, ' alt="', $alt
216 ,'" src="', $icon, '">' );
217 }
218 return join('', '<img ', $iconsizes{$1}, $align
Fred Drakea0e4b781998-08-14 15:03:48 +0000219 ,'border=', $nav_border, ' alt="', $alt, "\"\n"
Fred Drake64bdc241998-04-17 02:14:12 +0000220 ,' src="', $ICONSERVER, "/$icon", '">' );
221 }
222 else {
223 return $icon;
224 }
Fred Drakebc7101d1998-03-06 21:18:55 +0000225}
226
227
Fred Drake50cdd971999-02-19 23:04:59 +0000228sub do_cmd_arabic {
229 # get rid of that nasty <SPAN CLASS="arabic">...</SPAN>
230 local($ctr, $val, $id, $_) = &read_counter_value(@_[0]);
231 return ($val ? &farabic($val) : "0") . $_;
232}
233
234
Fred Drakebc7101d1998-03-06 21:18:55 +0000235sub gen_index_id {
236 # this is used to ensure common index key generation and a stable sort
Fred Drake235e6b11998-03-27 05:19:43 +0000237 my($str,$extra) = @_;
Fred Drake64bdc241998-04-17 02:14:12 +0000238 sprintf('%s###%s%010d', $str, $extra, ++$global{'max_id'});
Fred Drakebc7101d1998-03-06 21:18:55 +0000239}
240
Fred Drake13210ed1998-03-17 06:28:05 +0000241sub make_index_entry {
Fred Drake11916921998-04-02 22:30:57 +0000242 my($br_id,$str) = @_;
Fred Drake13210ed1998-03-17 06:28:05 +0000243 # If TITLE is not yet available (i.e the \index command is in the title of the
244 # current section), use $ref_before.
245 $TITLE = $ref_before unless $TITLE;
246 # Save the reference
247 $str = gen_index_id($str, '');
Fred Drake64bdc241998-04-17 02:14:12 +0000248 $index{$str} .= make_half_href("$CURRENT_FILE#$br_id");
Fred Drake13210ed1998-03-17 06:28:05 +0000249 "<a name=\"$br_id\">$anchor_invisible_mark<\/a>";
250}
Fred Drakebc7101d1998-03-06 21:18:55 +0000251
Fred Drake64bdc241998-04-17 02:14:12 +0000252
253sub insert_index{
Fred Drake2383f6d1999-03-02 16:00:37 +0000254 my($mark,$datafile,$columns,$letters,$prefix) = @_;
Fred Drake4d10b431998-08-07 20:51:58 +0000255 my $prog = "$myrootdir/tools/buildindex.py";
256 my $index;
257 if ($letters) {
258 $index = `$prog --columns $columns --letters $datafile`;
259 }
260 else {
261 $index = `$prog --columns $columns $datafile`;
262 }
Fred Drake2383f6d1999-03-02 16:00:37 +0000263 s/$mark/$prefix$index/;
Fred Drake64bdc241998-04-17 02:14:12 +0000264}
265
Fred Drake235e6b11998-03-27 05:19:43 +0000266sub add_idx{
Fred Drake9bbdce51999-01-19 16:30:10 +0000267 print "\nBuilding HTML for the index ...";
Fred Drake235e6b11998-03-27 05:19:43 +0000268 close(IDXFILE);
Fred Drake2383f6d1999-03-02 16:00:37 +0000269 insert_index($idx_mark, 'index.dat', $INDEX_COLUMNS, 1, '');
Fred Drake13210ed1998-03-17 06:28:05 +0000270}
Fred Drakebc7101d1998-03-06 21:18:55 +0000271
272
273$idx_module_mark = '<tex2html_idx_module_mark>';
274$idx_module_title = 'Module Index';
275
Fred Drake13210ed1998-03-17 06:28:05 +0000276sub add_module_idx{
Fred Drake9bbdce51999-01-19 16:30:10 +0000277 print "\nBuilding HTML for the module index ...";
Fred Drake235e6b11998-03-27 05:19:43 +0000278 my $key;
Fred Drake2383f6d1999-03-02 16:00:37 +0000279 my $first = 1;
280 my $prevplat = '';
281 my $allthesame = 1;
282 my $prefix = '';
283 foreach $key (keys %Modules) {
284 $key =~ s/<tt>([a-zA-Z0-9._]*)<\/tt>/\1/;
285 my $plat = "$ModulePlatforms{$key}";
286 $plat = ''
Fred Drake62cc3601999-03-04 18:41:17 +0000287 if ($plat eq $IGNORE_PLATFORM_ANNOTATION);
Fred Drake2383f6d1999-03-02 16:00:37 +0000288 if (!$first) {
289 $allthesame = 0
290 if ($prevplat ne $plat);
291 }
292 else { $first = 0; }
293 $prevplat = $plat;
294 }
Fred Drake64bdc241998-04-17 02:14:12 +0000295 open(MODIDXFILE, '>modindex.dat') || die "\n$!\n";
Fred Drake235e6b11998-03-27 05:19:43 +0000296 foreach $key (keys %Modules) {
297 # dump the line in the data file; just use a dummy seqno field
Fred Drake2383f6d1999-03-02 16:00:37 +0000298 my $nkey = $1;
299 my $moditem = "$Modules{$key}";
300 my $plat = '';
301 $key =~ s/<tt>([a-zA-Z0-9._]*)<\/tt>/\1/;
302 if ($ModulePlatforms{$key} && !$allthesame) {
Fred Drakebb584d31999-03-25 22:18:30 +0000303 $plat = (" <em>(<span class=platform>$ModulePlatforms{$key}"
304 . '</span>)</em>');
Fred Drake2383f6d1999-03-02 16:00:37 +0000305 }
306 print MODIDXFILE
307 $moditem
308 . $IDXFILE_FIELD_SEP
309 . "<tt class=module>$key</tt>$plat###\n";
Fred Drakebc7101d1998-03-06 21:18:55 +0000310 }
Fred Drake235e6b11998-03-27 05:19:43 +0000311 close(MODIDXFILE);
Fred Drake2383f6d1999-03-02 16:00:37 +0000312 if (!$allthesame) {
313 $prefix = <<PLAT_DISCUSS;
314
315
316<p> Some module names are followed by an annotation indicating what
317platform they are available on.</p>
318
319PLAT_DISCUSS
320 }
321 insert_index($idx_module_mark, 'modindex.dat', $MODULE_INDEX_COLUMNS, 0,
322 $prefix);
Fred Drakebc7101d1998-03-06 21:18:55 +0000323}
324
Fred Drake235e6b11998-03-27 05:19:43 +0000325# replace both indexes as needed:
326sub add_idx_hook{
Fred Drakeb3a3ed81998-07-24 22:17:34 +0000327 add_idx() if (/$idx_mark/);
328 add_module_idx() if (/$idx_module_mark/);
Fred Drake2383f6d1999-03-02 16:00:37 +0000329 process_python_state();
Fred Drake235e6b11998-03-27 05:19:43 +0000330}
Fred Drakebc7101d1998-03-06 21:18:55 +0000331
Fred Drakebc7101d1998-03-06 21:18:55 +0000332
333# In addition to the standard stuff, add label to allow named node files.
334sub do_cmd_tableofcontents {
335 local($_) = @_;
336 $TITLE = $toc_title;
337 $tocfile = $CURRENT_FILE;
Fred Drake64bdc241998-04-17 02:14:12 +0000338 my($closures,$reopens) = preserve_open_tags();
339 anchor_label('contents', $CURRENT_FILE, $_); # this is added
Fred Drakebeb27bf1999-02-16 17:22:32 +0000340 join('', "<BR>\n\\tableofchildlinks[off]", $closures
Fred Drake64bdc241998-04-17 02:14:12 +0000341 , make_section_heading($toc_title, 'H2'), $toc_mark
Fred Drakebc7101d1998-03-06 21:18:55 +0000342 , $reopens, $_);
343}
344# In addition to the standard stuff, add label to allow named node files.
345sub do_cmd_listoffigures {
346 local($_) = @_;
347 $TITLE = $lof_title;
348 $loffile = $CURRENT_FILE;
Fred Drake64bdc241998-04-17 02:14:12 +0000349 my($closures,$reopens) = preserve_open_tags();
350 anchor_label('lof', $CURRENT_FILE, $_); # this is added
Fred Drakebc7101d1998-03-06 21:18:55 +0000351 join('', "<BR>\n", $closures
Fred Drake64bdc241998-04-17 02:14:12 +0000352 , make_section_heading($lof_title, 'H2'), $lof_mark
Fred Drakebc7101d1998-03-06 21:18:55 +0000353 , $reopens, $_);
354}
355# In addition to the standard stuff, add label to allow named node files.
356sub do_cmd_listoftables {
357 local($_) = @_;
358 $TITLE = $lot_title;
359 $lotfile = $CURRENT_FILE;
Fred Drake64bdc241998-04-17 02:14:12 +0000360 my($closures,$reopens) = preserve_open_tags();
361 anchor_label('lot', $CURRENT_FILE, $_); # this is added
Fred Drakebc7101d1998-03-06 21:18:55 +0000362 join('', "<BR>\n", $closures
Fred Drake64bdc241998-04-17 02:14:12 +0000363 , make_section_heading($lot_title, 'H2'), $lot_mark
Fred Drakebc7101d1998-03-06 21:18:55 +0000364 , $reopens, $_);
365}
366# In addition to the standard stuff, add label to allow named node files.
367sub do_cmd_textohtmlinfopage {
368 local($_) = @_;
369 if ($INFO) { #
Fred Drake64bdc241998-04-17 02:14:12 +0000370 anchor_label("about",$CURRENT_FILE,$_); # this is added
Fred Drakebc7101d1998-03-06 21:18:55 +0000371 } #
Fred Drake15796f71998-11-30 19:25:47 +0000372 my $the_version = ''; # and the rest is
373 if ($t_date) { # mostly ours
374 $the_version = ",\n$t_date";
375 if ($PYTHON_VERSION) {
376 $the_version .= ", Release $PYTHON_VERSION";
377 }
378 }
379 $_ = (($INFO == 1)
380 ? join('', $close_all
381 , "<strong>$t_title</strong>$the_version\n"
382 , `cat $myrootdir${dd}html${dd}about.dat`
Fred Drakebc7101d1998-03-06 21:18:55 +0000383 , $open_all, $_)
Fred Drake15796f71998-11-30 19:25:47 +0000384 : join('', $close_all, $INFO,"\n", $open_all, $_));
385 $_;
Fred Drakebc7101d1998-03-06 21:18:55 +0000386}
387
388# $idx_mark will be replaced with the real index at the end
389sub do_cmd_textohtmlindex {
390 local($_) = @_;
391 $TITLE = $idx_title;
392 $idxfile = $CURRENT_FILE;
Fred Drake235e6b11998-03-27 05:19:43 +0000393 if (%index_labels) { make_index_labels(); }
394 if (($SHORT_INDEX) && (%index_segment)) { make_preindex(); }
Fred Drakebc7101d1998-03-06 21:18:55 +0000395 else { $preindex = ''; }
Fred Drake235e6b11998-03-27 05:19:43 +0000396 my $heading = make_section_heading($idx_title, 'h2') . $idx_mark;
Fred Drake11916921998-04-02 22:30:57 +0000397 my($pre,$post) = minimize_open_tags($heading);
Fred Drake235e6b11998-03-27 05:19:43 +0000398 anchor_label('genindex',$CURRENT_FILE,$_); # this is added
399 '<br>\n' . $pre . $_;
Fred Drakebc7101d1998-03-06 21:18:55 +0000400}
401
402# $idx_module_mark will be replaced with the real index at the end
403sub do_cmd_textohtmlmoduleindex {
404 local($_) = @_;
Fred Drakebc7101d1998-03-06 21:18:55 +0000405 $TITLE = $idx_module_title;
Fred Drake64bdc241998-04-17 02:14:12 +0000406 anchor_label("modindex",$CURRENT_FILE,$_);
Fred Drake235e6b11998-03-27 05:19:43 +0000407 '<p>' . make_section_heading($idx_module_title, "h2")
408 . $idx_module_mark . $_;
Fred Drakebc7101d1998-03-06 21:18:55 +0000409}
410
411# The bibliography and the index should be treated as separate sections
412# in their own HTML files. The \bibliography{} command acts as a sectioning command
413# that has the desired effect. But when the bibliography is constructed
414# manually using the thebibliography environment, or when using the
415# theindex environment it is not possible to use the normal sectioning
416# mechanism. This subroutine inserts a \bibliography{} or a dummy
417# \textohtmlindex command just before the appropriate environments
418# to force sectioning.
419
420# XXX This *assumes* that if there are two {theindex} environments, the
421# first is the module index and the second is the standard index. This
422# is sufficient for the current Python documentation, but that's about
423# it.
424
425sub add_bbl_and_idx_dummy_commands {
Fred Drake11916921998-04-02 22:30:57 +0000426 my $id = $global{'max_id'};
Fred Drakebc7101d1998-03-06 21:18:55 +0000427
428 s/([\\]begin\s*$O\d+$C\s*thebibliography)/$bbl_cnt++; $1/eg;
429 s/([\\]begin\s*$O\d+$C\s*thebibliography)/$id++; "\\bibliography$O$id$C$O$id$C $1"/geo
430 #if ($bbl_cnt == 1)
431 ;
432 #}
Fred Drake11916921998-04-02 22:30:57 +0000433 #----------------------------------------------------------------------
434 # (FLD) This was added
435 my(@parts) = split(/\\begin\s*$O\d+$C\s*theindex/);
436 if (scalar(@parts) == 3) {
437 # Be careful to re-write the string in place, since $_ is *not*
438 # returned explicity; *** nasty side-effect dependency! ***
439 print "\nadd_bbl_and_idx_dummy_commands ==> adding module index";
440 my $rx = "([\\\\]begin\\s*$O\\d+$C\\s*theindex[\\s\\S]*)"
441 . "([\\\\]begin\\s*$O\\d+$C\\s*theindex)";
442 s/$rx/\\textohtmlmoduleindex \1 \\textohtmlindex \2/o;
Fred Drake6aa5d481998-08-11 03:14:50 +0000443 # Add a button to the navigation areas:
Fred Drake062bc6e1998-08-13 22:03:46 +0000444 $CUSTOM_BUTTONS .= ("<a\n href=\"modindex.html\">"
445 . img_tag('modules.'.$IMAGE_TYPE) . "</a>");
Fred Drake11916921998-04-02 22:30:57 +0000446 }
447 else {
Fred Drake95474f91999-02-09 18:45:50 +0000448 $CUSTOM_BUTTONS .= img_tag('blank.' . $IMAGE_TYPE);
Fred Drake11916921998-04-02 22:30:57 +0000449 $global{'max_id'} = $id; # not sure why....
450 s/([\\]begin\s*$O\d+$C\s*theindex)/\\textohtmlindex $1/o;
451 s/[\\]printindex/\\textohtmlindex /o;
452 }
453 #----------------------------------------------------------------------
Fred Drake64bdc241998-04-17 02:14:12 +0000454 lib_add_bbl_and_idx_dummy_commands()
Fred Drake11916921998-04-02 22:30:57 +0000455 if defined(&lib_add_bbl_and_idx_dummy_commands);
Fred Drakebc7101d1998-03-06 21:18:55 +0000456}
457
458# The bibliographic references, the appendices, the lists of figures and tables
459# etc. must appear in the contents table at the same level as the outermost
460# sectioning command. This subroutine finds what is the outermost level and
461# sets the above to the same level;
462
Fred Drake13210ed1998-03-17 06:28:05 +0000463sub set_depth_levels {
464 # Sets $outermost_level
Fred Drake11916921998-04-02 22:30:57 +0000465 my $level;
Fred Drake13210ed1998-03-17 06:28:05 +0000466 #RRM: do not alter user-set value for $MAX_SPLIT_DEPTH
467 foreach $level ("part", "chapter", "section", "subsection",
468 "subsubsection", "paragraph") {
469 last if (($outermost_level) = /\\($level)$delimiter_rx/);
470 }
471 $level = ($outermost_level ? $section_commands{$outermost_level} :
472 do {$outermost_level = 'section'; 3;});
Fred Drakebc7101d1998-03-06 21:18:55 +0000473
Fred Drake13210ed1998-03-17 06:28:05 +0000474 #RRM: but calculate value for $MAX_SPLIT_DEPTH when a $REL_DEPTH was given
475 if ($REL_DEPTH && $MAX_SPLIT_DEPTH) {
476 $MAX_SPLIT_DEPTH = $level + $MAX_SPLIT_DEPTH;
477 } elsif (!($MAX_SPLIT_DEPTH)) { $MAX_SPLIT_DEPTH = 1 };
Fred Drakebc7101d1998-03-06 21:18:55 +0000478
Fred Drake64bdc241998-04-17 02:14:12 +0000479 %unnumbered_section_commands = ('tableofcontents' => $level,
480 'listoffigures' => $level,
481 'listoftables' => $level,
482 'bibliography' => $level,
483 'textohtmlindex' => $level,
484 'textohtmlmoduleindex' => $level);
485 $section_headings{'textohtmlmoduleindex'} = 'h1';
Fred Drakebc7101d1998-03-06 21:18:55 +0000486
Fred Drake64bdc241998-04-17 02:14:12 +0000487 %section_commands = (%unnumbered_section_commands,
488 %section_commands);
Fred Drake11916921998-04-02 22:30:57 +0000489
490 make_sections_rx();
Fred Drake13210ed1998-03-17 06:28:05 +0000491}
Fred Drakebc7101d1998-03-06 21:18:55 +0000492
493
494# Fix from Ross Moore for ']' in \item[...]; this can be removed once the next
Fred Drake235e6b11998-03-27 05:19:43 +0000495# patch to LaTeX2HTML is released and tested ... if the patch gets included.
496# Be very careful to keep this around, just in case things break again!
Fred Drakebc7101d1998-03-06 21:18:55 +0000497#
498sub protect_useritems {
499 local(*_) = @_;
Fred Drake11916921998-04-02 22:30:57 +0000500 local($preitems,$thisitem);
Fred Drakebc7101d1998-03-06 21:18:55 +0000501 while (/\\item\s*\[/) {
Fred Drake11916921998-04-02 22:30:57 +0000502 $preitems .= $`;
503 $_ = $';
Fred Drakebc7101d1998-03-06 21:18:55 +0000504 $thisitem = $&.'<<'.++$global{'max_id'}.'>>';
505 s/^(((($O|$OP)\d+($C|$CP)).*\3|<[^<>]*>|[^\]<]+)*)\]/$thisitem.=$1;''/e;
Fred Drake11916921998-04-02 22:30:57 +0000506 $preitems .= $thisitem . '<<' . $global{'max_id'} . '>>]';
507 s/^]//;
Fred Drakebc7101d1998-03-06 21:18:55 +0000508 }
509 $_ = $preitems . $_;
510}
511
Fred Drake1072e461998-04-12 02:16:34 +0000512# This changes the markup used for {verbatim} environments, and is the
Fred Drake95474f91999-02-09 18:45:50 +0000513# best way I've found that ensures the <dl> goes on the outside of the
Fred Drake1072e461998-04-12 02:16:34 +0000514# <pre>...</pre>.
515#
516# Note that this *must* be done in the init file, not the python.perl
517# style support file. The %declarations must be set before initialize()
518# is called in the main script.
519#
Fred Drakebeb27bf1999-02-16 17:22:32 +0000520%declarations = ('preform' => '<dl><dd><pre class=verbatim></pre></dl>',
Fred Drake1072e461998-04-12 02:16:34 +0000521 %declarations);
522
Fred Drakebc7101d1998-03-06 21:18:55 +00005231; # This must be the last line