blob: 407f396ff1e5a9c087f32fa855e176a14674e5ce [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 Drakee15956b2000-04-03 04:51:13 +000019$MAX_SPLIT_DEPTH = 5; # split at subsections but not sub-subsections
Fred Draked7571651998-04-23 20:06:24 +000020$ADDRESS = '';
Fred Drakebc7101d1998-03-06 21:18:55 +000021
Fred Drakee194beb1998-05-19 19:38:49 +000022$NO_FOOTNODE = 1;
Fred Drakebc7101d1998-03-06 21:18:55 +000023$NUMBERED_FOOTNOTES = 1;
24
25# Python documentation uses section numbers to support references to match
26# in the printed and online versions.
27#
28$SHOW_SECTION_NUMBERS = 1;
29
30$ICONSERVER = '../icons';
31
Fred Drake6aa5d481998-08-11 03:14:50 +000032# Control where the navigation bars should show up:
33$TOP_NAVIGATION = 1;
34$BOTTOM_NAVIGATION = 1;
35$AUTO_NAVIGATION = 0;
36
Fred Drake191439a1999-09-22 19:50:51 +000037$SUPPRESS_CONTENTS = 0;
38$SUPPRESS_INDEXES = 0;
39
40# these exactly match the python.org colors
41$BODYTEXT = ('bgcolor="#ffffff" text="#000000"'
42 . ' link="#0000bb" vlink="#551a8b" alink="#ff0000"');
Fred Drakebc7101d1998-03-06 21:18:55 +000043$CHILDLINE = "\n<p><hr>\n";
44$VERBOSITY = 0;
Fred Drakebc7101d1998-03-06 21:18:55 +000045
Fred Drake4d10b431998-08-07 20:51:58 +000046# default # of columns for the indexes
Fred Drakeaa3f9fb1998-08-07 19:52:37 +000047$INDEX_COLUMNS = 2;
Fred Drake2383f6d1999-03-02 16:00:37 +000048$MODULE_INDEX_COLUMNS = 4;
Fred Drakeaa3f9fb1998-08-07 19:52:37 +000049
Fred Drakec9f2c141998-03-11 12:08:21 +000050
Fred Drakedb34a1e1998-03-10 23:02:57 +000051# A little painful, but lets us clean up the top level directory a little,
52# and not be tied to the current directory (as far as I can tell).
53#
Fred Drakec9f2c141998-03-11 12:08:21 +000054use Cwd;
55use File::Basename;
56($myname, $mydir, $myext) = fileparse(__FILE__, '\..*');
57chop $mydir; # remove trailing '/'
58$mydir = getcwd() . "$dd$mydir"
59 unless $mydir =~ s|^/|/|;
Fred Drakedb34a1e1998-03-10 23:02:57 +000060$LATEX2HTMLSTYLES = "$mydir$envkey$LATEX2HTMLSTYLES";
Fred Drakeb3a3ed81998-07-24 22:17:34 +000061push (@INC, $mydir);
Fred Drakebc7101d1998-03-06 21:18:55 +000062
Fred Drake235e6b11998-03-27 05:19:43 +000063($myrootname, $myrootdir, $myext) = fileparse($mydir, '\..*');
64chop $myrootdir;
65
Fred Drakebc7101d1998-03-06 21:18:55 +000066
Fred Drakea4565b01998-05-15 17:14:17 +000067# Hackish way to get the appropriate paper-*/ directory into $TEXINPUTS;
68# pass in the paper size (a4 or letter) as the environment variable PAPER
69# to add the right directory. If not given, the current directory is
70# added instead for use with HOWTO processing.
71#
72if (defined $ENV{'PAPER'}) {
73 $mytexinputs = "$myrootdir${dd}paper-$ENV{'PAPER'}$envkey";
74}
75else {
76 $mytexinputs = getcwd() . $envkey;
77}
78$mytexinputs .= "$myrootdir${dd}texinputs";
79
80
Fred Drakeb35f2b71999-09-23 16:53:09 +000081# Change this variable to change the text added in "About this document...";
82# this should be an absolute pathname to get it right.
83#
84$ABOUT_FILE = "$myrootdir${dd}html${dd}stdabout.dat";
85
86
Fred Drakea4565b01998-05-15 17:14:17 +000087sub custom_driver_hook{
88 #
89 # This adds the directory of the main input file to $TEXINPUTS; it
90 # seems to be sufficiently general that it should be fine for HOWTO
91 # processing.
92 #
93 my $file = @_[0];
94 my($jobname,$dir,$ext) = fileparse($file, '\..*');
95 $dir = make_directory_absolute($dir);
96 $dir =~ s/$dd$//;
97 $TEXINPUTS = "$dir$envkey$mytexinputs";
98 print "\nadding $dir to \$TEXINPUTS\n";
99}
100
Fred Drake191439a1999-09-22 19:50:51 +0000101# Defining this allows us to remove all table of contents and index
102# processing using an init file; this is required to get rid of the
103# Table of Contents or we'd get a blank page. Based on a suggestion
104# from Ross Moore <ross@ics.mq.edu.au>.
105#
106# Seems to require a more recent version of LaTeX2HTML than I've
107# been using, though.
108#
109sub preprocess{
110 if ($SUPPRESS_CONTENTS) {
111 s/\\(tableofcontents|listof(figures|tables))/\2/g;
112 }
113 if ($SUPPRESS_INDEXES) {
114 s/\\(print|make)index//g;
115 }
116}
117
Fred Drakea4565b01998-05-15 17:14:17 +0000118
Fred Drake062bc6e1998-08-13 22:03:46 +0000119sub set_icon_size{
120 my($name, $w, $h) = @_;
121 $iconsizes{$name} = "width=$w height=$h";
122}
123
Fred Drake95474f91999-02-09 18:45:50 +0000124foreach $name (split(/ /, 'up next previous contents index modules blank')) {
Fred Drake062bc6e1998-08-13 22:03:46 +0000125 set_icon_size($name, 32, 32);
126}
Fred Drake191439a1999-09-22 19:50:51 +0000127sub adjust_icon_information{
128 # The '_motif' is really annoying, and makes the HTML larger with no value
129 # added, so strip it off:
130 foreach $name (keys %icons) {
131 my $icon = $icons{$name};
132 # Strip off the wasteful '_motif':
133 $icon =~ s/_motif//;
134 # Change the greyed-out icons to be blank:
135 $icon =~ s/[a-z]*_gr[.]/blank./;
136 # make sure we're using the latest $IMAGE_TYPE
137 $icon =~ s/[.](gif|png)$/.$IMAGE_TYPE/;
138 $icons{$name} = $icon;
139 }
140 $icons{'blank'} = 'blank.' . $IMAGE_TYPE;
141
142 $CUSTOM_BUTTONS = '';
143 $BLANK_ICON = "\n<td>" . img_tag('blank.' . $IMAGE_TYPE) . "</td>";
144 $BLANK_ICON =~ s/alt="blank"/alt=""/;
145 $NAV_BGCOLOR = " bgcolor=\"#99CCFF\"";
Fred Drake062bc6e1998-08-13 22:03:46 +0000146}
Fred Drakee15956b2000-04-03 04:51:13 +0000147
Fred Drake191439a1999-09-22 19:50:51 +0000148adjust_icon_information();
Fred Drake9f7adc41998-08-11 19:33:38 +0000149
Fred Drake6aa5d481998-08-11 03:14:50 +0000150
Fred Drakebeb27bf1999-02-16 17:22:32 +0000151sub make_nav_sectref{
152 my($label,$title) = @_;
153 if ($title) {
Fred Drakee15956b2000-04-03 04:51:13 +0000154 return ("<b class='navlabel'>$label:</b> "
155 . "<span class='sectref'>$title</span>\n");
Fred Drakebeb27bf1999-02-16 17:22:32 +0000156 }
157 return '';
158}
159
Fred Drake13210ed1998-03-17 06:28:05 +0000160sub make_nav_panel{
Fred Drakea0075441999-04-29 19:06:56 +0000161 my $s;
Fred Drakee15956b2000-04-03 04:51:13 +0000162 $s = "<table align='center' width='100%' cellpadding='0' cellspacing='2'>"
Fred Drakea0075441999-04-29 19:06:56 +0000163 . "\n<tr>"
164 . "\n<td>$NEXT</td>"
165 . "\n<td>$UP</td>"
Fred Drake191439a1999-09-22 19:50:51 +0000166 . "\n<td>$PREVIOUS</td>";
167 if ($SUPPRESS_CONTENTS && $SUPPRESS_INDEXES) {
168 $s .= ("\n<td align=right$NAV_BGCOLOR width=\"100%\">"
169 . "\n <b class=title>$t_title\&nbsp;\&nbsp;\&nbsp;</b></td>");
170 }
171 else {
172 $s .= ("\n<td align=center$NAV_BGCOLOR width=\"100%\">"
173 . "\n <b class=title>$t_title</b></td>"
174 . ($CONTENTS ? "\n<td>$CONTENTS</td>" : $BLANK_ICON)
175 . "\n<td>$CUSTOM_BUTTONS</td>" # module index
176 . ($INDEX ? "\n<td>$INDEX</td>" : $BLANK_ICON));
177 }
178 $s .= ("\n</tr></table>"
179 . make_nav_sectref("Next", $NEXT_TITLE)
180 . make_nav_sectref("Up", $UP_TITLE)
181 . make_nav_sectref("Previous", $PREVIOUS_TITLE));
182 # remove these; they are unnecessary and cause error from validation
Fred Drakea0075441999-04-29 19:06:56 +0000183 $s =~ s/ NAME="tex2html\d+"\n//g;
184 return $s;
Fred Drake13210ed1998-03-17 06:28:05 +0000185}
186
Fred Drakebc7101d1998-03-06 21:18:55 +0000187sub top_navigation_panel {
Fred Drakee15956b2000-04-03 04:51:13 +0000188 "<div class='navigation'>\n"
Fred Drake64bdc241998-04-17 02:14:12 +0000189 . make_nav_panel()
Fred Drake72e5a901999-02-10 17:35:41 +0000190 . '<br><hr></div>';
Fred Drakebc7101d1998-03-06 21:18:55 +0000191}
192
193sub bot_navigation_panel {
Fred Drakee15956b2000-04-03 04:51:13 +0000194 "<p>\n<div class='navigation'><hr>"
Fred Drake64bdc241998-04-17 02:14:12 +0000195 . make_nav_panel()
196 . '</div>';
197}
198
199sub add_link {
200 # Returns a pair (iconic link, textual link)
201 my($icon, $current_file, @link) = @_;
202 my($dummy, $file, $title) = split($delim,
Fred Drake28e7b4c1998-10-20 18:14:20 +0000203 $section_info{join(' ',@link)});
Fred Drake64bdc241998-04-17 02:14:12 +0000204 if ($title && ($file ne $current_file)) {
205 $title = purify($title);
206 $title = get_first_words($title, $WORDS_IN_NAVIGATION_PANEL_TITLES);
207 return (make_href($file, $icon), make_href($file, "$title"))
208 }
209 elsif ($icon eq $up_visible_mark && $EXTERNAL_UP_LINK) {
210 return (make_href($EXTERNAL_UP_LINK, $icon),
211 make_href($EXTERNAL_UP_LINK, "$EXTERNAL_UP_TITLE"))
212 }
213 elsif (($icon eq $previous_visible_mark
214 || $icon eq $previous_page_visible_mark)
215 && $EXTERNAL_PREV_LINK && $EXTERNAL_PREV_TITLE) {
216 return (make_href($EXTERNAL_PREV_LINK, $icon),
217 make_href($EXTERNAL_PREV_LINK, "$EXTERNAL_PREV_TITLE"))
218 }
219 elsif (($icon eq $next_visible_mark
220 || $icon eq $next_page_visible_mark)
221 && $EXTERNAL_DOWN_LINK && $EXTERNAL_DOWN_TITLE) {
222 return (make_href($EXTERNAL_DOWN_LINK, $icon),
223 make_href($EXTERNAL_DOWN_LINK, "$EXTERNAL_DOWN_TITLE"))
224 }
225 (&inactive_img($icon), "");
226}
227
228sub add_special_link {
229 my($icon, $file, $current_file) = @_;
230 (($file && ($file ne $current_file)) ? make_href($file, $icon) : undef)
231}
232
233sub img_tag {
234 local($icon) = @_;
235 my $alt;
236 my $align = " align=bottom ";
237
Fred Drake062bc6e1998-08-13 22:03:46 +0000238 # having this list hardcoded here is really bogus....
Fred Drake64bdc241998-04-17 02:14:12 +0000239 $alt = join('|', 'up', 'next_group', 'previous_group'
240 , 'next', 'previous', 'change_begin_right', 'change_begin'
241 , 'change_end_right', 'change_end', 'change_delete_right'
Fred Drake95474f91999-02-09 18:45:50 +0000242 , 'change_delete', 'contents', 'index', 'modules', 'blank');
Fred Drake64bdc241998-04-17 02:14:12 +0000243
244 if ($icon =~ /(gif|png)$/) {
245 $used_icons{$icon} = 1;
246 if ($icon =~ /change_(begin|end|delete)_right/) { $align = ' ' };
247 my $nav_border = "$NAV_BORDER";
248 if ($icon =~ /($alt)/) {
249 $alt = $1;
Fred Drakeaa99a501999-03-03 16:21:34 +0000250 $alt = ""
251 if ($alt eq "blank");
Fred Drake64bdc241998-04-17 02:14:12 +0000252 }
253 else {
254 $nav_border = '1';
255 $alt = '[*]';
256 };
257 if ($LOCAL_ICONS) {
258 return join('', '<img ', $iconsizes{$1}, $align
259 ,'border=', $nav_border, ' alt="', $alt
260 ,'" src="', $icon, '">' );
261 }
Fred Draked3d28d31999-09-23 15:29:45 +0000262 my $s = join('', '<img ', $iconsizes{$1}, $align,
263 'border=', $nav_border, ' alt="', $alt, "\"\n",
264 ' src="', $ICONSERVER, "/$icon", '">' );
265 # if $ICONSERVER starts with "./", remove "./":
266 $s =~ s|src="(.\/)+|src="|;
267 return $s;
Fred Drake64bdc241998-04-17 02:14:12 +0000268 }
269 else {
270 return $icon;
271 }
Fred Drakebc7101d1998-03-06 21:18:55 +0000272}
273
274
Fred Drake50cdd971999-02-19 23:04:59 +0000275sub do_cmd_arabic {
276 # get rid of that nasty <SPAN CLASS="arabic">...</SPAN>
277 local($ctr, $val, $id, $_) = &read_counter_value(@_[0]);
278 return ($val ? &farabic($val) : "0") . $_;
279}
280
281
Fred Drakebc7101d1998-03-06 21:18:55 +0000282sub gen_index_id {
283 # this is used to ensure common index key generation and a stable sort
Fred Drake235e6b11998-03-27 05:19:43 +0000284 my($str,$extra) = @_;
Fred Drake64bdc241998-04-17 02:14:12 +0000285 sprintf('%s###%s%010d', $str, $extra, ++$global{'max_id'});
Fred Drakebc7101d1998-03-06 21:18:55 +0000286}
287
Fred Drake64bdc241998-04-17 02:14:12 +0000288sub insert_index{
Fred Drake2383f6d1999-03-02 16:00:37 +0000289 my($mark,$datafile,$columns,$letters,$prefix) = @_;
Fred Drake4d10b431998-08-07 20:51:58 +0000290 my $prog = "$myrootdir/tools/buildindex.py";
291 my $index;
292 if ($letters) {
293 $index = `$prog --columns $columns --letters $datafile`;
294 }
295 else {
296 $index = `$prog --columns $columns $datafile`;
297 }
Fred Drake2383f6d1999-03-02 16:00:37 +0000298 s/$mark/$prefix$index/;
Fred Drake64bdc241998-04-17 02:14:12 +0000299}
300
Fred Drake235e6b11998-03-27 05:19:43 +0000301sub add_idx{
Fred Drake9bbdce51999-01-19 16:30:10 +0000302 print "\nBuilding HTML for the index ...";
Fred Drake235e6b11998-03-27 05:19:43 +0000303 close(IDXFILE);
Fred Drake2383f6d1999-03-02 16:00:37 +0000304 insert_index($idx_mark, 'index.dat', $INDEX_COLUMNS, 1, '');
Fred Drake13210ed1998-03-17 06:28:05 +0000305}
Fred Drakebc7101d1998-03-06 21:18:55 +0000306
307
308$idx_module_mark = '<tex2html_idx_module_mark>';
309$idx_module_title = 'Module Index';
310
Fred Drake13210ed1998-03-17 06:28:05 +0000311sub add_module_idx{
Fred Drake9bbdce51999-01-19 16:30:10 +0000312 print "\nBuilding HTML for the module index ...";
Fred Drake235e6b11998-03-27 05:19:43 +0000313 my $key;
Fred Drake2383f6d1999-03-02 16:00:37 +0000314 my $first = 1;
315 my $prevplat = '';
316 my $allthesame = 1;
317 my $prefix = '';
318 foreach $key (keys %Modules) {
319 $key =~ s/<tt>([a-zA-Z0-9._]*)<\/tt>/\1/;
320 my $plat = "$ModulePlatforms{$key}";
321 $plat = ''
Fred Drake62cc3601999-03-04 18:41:17 +0000322 if ($plat eq $IGNORE_PLATFORM_ANNOTATION);
Fred Drake2383f6d1999-03-02 16:00:37 +0000323 if (!$first) {
324 $allthesame = 0
325 if ($prevplat ne $plat);
326 }
327 else { $first = 0; }
328 $prevplat = $plat;
329 }
Fred Drake64bdc241998-04-17 02:14:12 +0000330 open(MODIDXFILE, '>modindex.dat') || die "\n$!\n";
Fred Drake235e6b11998-03-27 05:19:43 +0000331 foreach $key (keys %Modules) {
332 # dump the line in the data file; just use a dummy seqno field
Fred Drake2383f6d1999-03-02 16:00:37 +0000333 my $nkey = $1;
334 my $moditem = "$Modules{$key}";
335 my $plat = '';
336 $key =~ s/<tt>([a-zA-Z0-9._]*)<\/tt>/\1/;
337 if ($ModulePlatforms{$key} && !$allthesame) {
Fred Drakee15956b2000-04-03 04:51:13 +0000338 $plat = (" <em>(<span class='platform'>$ModulePlatforms{$key}"
Fred Drakebb584d31999-03-25 22:18:30 +0000339 . '</span>)</em>');
Fred Drake2383f6d1999-03-02 16:00:37 +0000340 }
Fred Drakee15956b2000-04-03 04:51:13 +0000341 print MODIDXFILE $moditem . $IDXFILE_FIELD_SEP
342 . "<tt class='module'>$key</tt>$plat###\n";
Fred Drakebc7101d1998-03-06 21:18:55 +0000343 }
Fred Drake235e6b11998-03-27 05:19:43 +0000344 close(MODIDXFILE);
Fred Drake2383f6d1999-03-02 16:00:37 +0000345 if (!$allthesame) {
346 $prefix = <<PLAT_DISCUSS;
347
348
349<p> Some module names are followed by an annotation indicating what
350platform they are available on.</p>
351
352PLAT_DISCUSS
353 }
354 insert_index($idx_module_mark, 'modindex.dat', $MODULE_INDEX_COLUMNS, 0,
355 $prefix);
Fred Drakebc7101d1998-03-06 21:18:55 +0000356}
357
Fred Drake235e6b11998-03-27 05:19:43 +0000358# replace both indexes as needed:
359sub add_idx_hook{
Fred Drakeb3a3ed81998-07-24 22:17:34 +0000360 add_idx() if (/$idx_mark/);
361 add_module_idx() if (/$idx_module_mark/);
Fred Drake2383f6d1999-03-02 16:00:37 +0000362 process_python_state();
Fred Drake235e6b11998-03-27 05:19:43 +0000363}
Fred Drakebc7101d1998-03-06 21:18:55 +0000364
Fred Drakebc7101d1998-03-06 21:18:55 +0000365
Fred Drake191439a1999-09-22 19:50:51 +0000366# In addition to the standard stuff, add label to allow named node files and
367# support suppression of the page complete (for HTML Help use).
Fred Drakebc7101d1998-03-06 21:18:55 +0000368sub do_cmd_tableofcontents {
369 local($_) = @_;
Fred Drake191439a1999-09-22 19:50:51 +0000370# if ($SUPPRESS_CONTENTS) {
371# return $_;
372# }
Fred Drakebc7101d1998-03-06 21:18:55 +0000373 $TITLE = $toc_title;
374 $tocfile = $CURRENT_FILE;
Fred Drake64bdc241998-04-17 02:14:12 +0000375 my($closures,$reopens) = preserve_open_tags();
376 anchor_label('contents', $CURRENT_FILE, $_); # this is added
Fred Drakebeb27bf1999-02-16 17:22:32 +0000377 join('', "<BR>\n\\tableofchildlinks[off]", $closures
Fred Drake64bdc241998-04-17 02:14:12 +0000378 , make_section_heading($toc_title, 'H2'), $toc_mark
Fred Drakebc7101d1998-03-06 21:18:55 +0000379 , $reopens, $_);
380}
381# In addition to the standard stuff, add label to allow named node files.
382sub do_cmd_listoffigures {
383 local($_) = @_;
384 $TITLE = $lof_title;
385 $loffile = $CURRENT_FILE;
Fred Drake64bdc241998-04-17 02:14:12 +0000386 my($closures,$reopens) = preserve_open_tags();
387 anchor_label('lof', $CURRENT_FILE, $_); # this is added
Fred Drakebc7101d1998-03-06 21:18:55 +0000388 join('', "<BR>\n", $closures
Fred Drake64bdc241998-04-17 02:14:12 +0000389 , make_section_heading($lof_title, 'H2'), $lof_mark
Fred Drakebc7101d1998-03-06 21:18:55 +0000390 , $reopens, $_);
391}
392# In addition to the standard stuff, add label to allow named node files.
393sub do_cmd_listoftables {
394 local($_) = @_;
395 $TITLE = $lot_title;
396 $lotfile = $CURRENT_FILE;
Fred Drake64bdc241998-04-17 02:14:12 +0000397 my($closures,$reopens) = preserve_open_tags();
398 anchor_label('lot', $CURRENT_FILE, $_); # this is added
Fred Drakebc7101d1998-03-06 21:18:55 +0000399 join('', "<BR>\n", $closures
Fred Drake64bdc241998-04-17 02:14:12 +0000400 , make_section_heading($lot_title, 'H2'), $lot_mark
Fred Drakebc7101d1998-03-06 21:18:55 +0000401 , $reopens, $_);
402}
403# In addition to the standard stuff, add label to allow named node files.
404sub do_cmd_textohtmlinfopage {
405 local($_) = @_;
406 if ($INFO) { #
Fred Drake64bdc241998-04-17 02:14:12 +0000407 anchor_label("about",$CURRENT_FILE,$_); # this is added
Fred Drakebc7101d1998-03-06 21:18:55 +0000408 } #
Fred Drake15796f71998-11-30 19:25:47 +0000409 my $the_version = ''; # and the rest is
410 if ($t_date) { # mostly ours
411 $the_version = ",\n$t_date";
412 if ($PYTHON_VERSION) {
413 $the_version .= ", Release $PYTHON_VERSION";
414 }
415 }
416 $_ = (($INFO == 1)
Fred Drakeb35f2b71999-09-23 16:53:09 +0000417 ? join('',
418 $close_all,
419 "<strong>$t_title</strong>$the_version\n",
420 `cat $ABOUT_FILE`,
421 $open_all, $_)
422 : join('', $close_all, $INFO,"\n", $open_all, $_));
Fred Drake15796f71998-11-30 19:25:47 +0000423 $_;
Fred Drakebc7101d1998-03-06 21:18:55 +0000424}
425
426# $idx_mark will be replaced with the real index at the end
427sub do_cmd_textohtmlindex {
428 local($_) = @_;
429 $TITLE = $idx_title;
430 $idxfile = $CURRENT_FILE;
Fred Drake235e6b11998-03-27 05:19:43 +0000431 if (%index_labels) { make_index_labels(); }
432 if (($SHORT_INDEX) && (%index_segment)) { make_preindex(); }
Fred Drakebc7101d1998-03-06 21:18:55 +0000433 else { $preindex = ''; }
Fred Drake235e6b11998-03-27 05:19:43 +0000434 my $heading = make_section_heading($idx_title, 'h2') . $idx_mark;
Fred Drake11916921998-04-02 22:30:57 +0000435 my($pre,$post) = minimize_open_tags($heading);
Fred Drake235e6b11998-03-27 05:19:43 +0000436 anchor_label('genindex',$CURRENT_FILE,$_); # this is added
437 '<br>\n' . $pre . $_;
Fred Drakebc7101d1998-03-06 21:18:55 +0000438}
439
440# $idx_module_mark will be replaced with the real index at the end
441sub do_cmd_textohtmlmoduleindex {
442 local($_) = @_;
Fred Drakebc7101d1998-03-06 21:18:55 +0000443 $TITLE = $idx_module_title;
Fred Drake64bdc241998-04-17 02:14:12 +0000444 anchor_label("modindex",$CURRENT_FILE,$_);
Fred Drake235e6b11998-03-27 05:19:43 +0000445 '<p>' . make_section_heading($idx_module_title, "h2")
446 . $idx_module_mark . $_;
Fred Drakebc7101d1998-03-06 21:18:55 +0000447}
448
449# The bibliography and the index should be treated as separate sections
450# in their own HTML files. The \bibliography{} command acts as a sectioning command
451# that has the desired effect. But when the bibliography is constructed
452# manually using the thebibliography environment, or when using the
453# theindex environment it is not possible to use the normal sectioning
454# mechanism. This subroutine inserts a \bibliography{} or a dummy
455# \textohtmlindex command just before the appropriate environments
456# to force sectioning.
457
458# XXX This *assumes* that if there are two {theindex} environments, the
459# first is the module index and the second is the standard index. This
460# is sufficient for the current Python documentation, but that's about
461# it.
462
463sub add_bbl_and_idx_dummy_commands {
Fred Drake11916921998-04-02 22:30:57 +0000464 my $id = $global{'max_id'};
Fred Drakebc7101d1998-03-06 21:18:55 +0000465
466 s/([\\]begin\s*$O\d+$C\s*thebibliography)/$bbl_cnt++; $1/eg;
Fred Drake191439a1999-09-22 19:50:51 +0000467 s/([\\]begin\s*$O\d+$C\s*thebibliography)/$id++; "\\bibliography$O$id$C$O$id$C $1"/geo;
Fred Drake11916921998-04-02 22:30:57 +0000468 #----------------------------------------------------------------------
469 # (FLD) This was added
Fred Drake191439a1999-09-22 19:50:51 +0000470 if ($SUPPRESS_INDEXES) {
471 $CUSTOM_BUTTONS .= img_tag('blank.' . $IMAGE_TYPE);
Fred Drake11916921998-04-02 22:30:57 +0000472 }
473 else {
Fred Drake191439a1999-09-22 19:50:51 +0000474 my(@parts) = split(/\\begin\s*$O\d+$C\s*theindex/);
475 if (scalar(@parts) == 3) {
476 # Be careful to re-write the string in place, since $_ is *not*
477 # returned explicity; *** nasty side-effect dependency! ***
478 print "\nadd_bbl_and_idx_dummy_commands ==> adding module index";
479 my $rx = "([\\\\]begin\\s*$O\\d+$C\\s*theindex[\\s\\S]*)"
480 . "([\\\\]begin\\s*$O\\d+$C\\s*theindex)";
481 s/$rx/\\textohtmlmoduleindex \1 \\textohtmlindex \2/o;
482 # Add a button to the navigation areas:
483 $CUSTOM_BUTTONS .= ("<a\n href=\"modindex.html\">"
484 . img_tag('modules.'.$IMAGE_TYPE) . "</a>");
485 }
486 else {
487 $CUSTOM_BUTTONS .= img_tag('blank.' . $IMAGE_TYPE);
488 $global{'max_id'} = $id; # not sure why....
489 s/([\\]begin\s*$O\d+$C\s*theindex)/\\textohtmlindex $1/o;
490 s/[\\]printindex/\\textohtmlindex /o;
491 }
Fred Drake11916921998-04-02 22:30:57 +0000492 }
493 #----------------------------------------------------------------------
Fred Drake64bdc241998-04-17 02:14:12 +0000494 lib_add_bbl_and_idx_dummy_commands()
Fred Drake11916921998-04-02 22:30:57 +0000495 if defined(&lib_add_bbl_and_idx_dummy_commands);
Fred Drakebc7101d1998-03-06 21:18:55 +0000496}
497
498# The bibliographic references, the appendices, the lists of figures and tables
499# etc. must appear in the contents table at the same level as the outermost
500# sectioning command. This subroutine finds what is the outermost level and
501# sets the above to the same level;
502
Fred Drake13210ed1998-03-17 06:28:05 +0000503sub set_depth_levels {
504 # Sets $outermost_level
Fred Drake11916921998-04-02 22:30:57 +0000505 my $level;
Fred Drake13210ed1998-03-17 06:28:05 +0000506 #RRM: do not alter user-set value for $MAX_SPLIT_DEPTH
507 foreach $level ("part", "chapter", "section", "subsection",
508 "subsubsection", "paragraph") {
509 last if (($outermost_level) = /\\($level)$delimiter_rx/);
510 }
511 $level = ($outermost_level ? $section_commands{$outermost_level} :
512 do {$outermost_level = 'section'; 3;});
Fred Drakebc7101d1998-03-06 21:18:55 +0000513
Fred Drake13210ed1998-03-17 06:28:05 +0000514 #RRM: but calculate value for $MAX_SPLIT_DEPTH when a $REL_DEPTH was given
515 if ($REL_DEPTH && $MAX_SPLIT_DEPTH) {
516 $MAX_SPLIT_DEPTH = $level + $MAX_SPLIT_DEPTH;
517 } elsif (!($MAX_SPLIT_DEPTH)) { $MAX_SPLIT_DEPTH = 1 };
Fred Drakebc7101d1998-03-06 21:18:55 +0000518
Fred Drake64bdc241998-04-17 02:14:12 +0000519 %unnumbered_section_commands = ('tableofcontents' => $level,
520 'listoffigures' => $level,
521 'listoftables' => $level,
522 'bibliography' => $level,
523 'textohtmlindex' => $level,
524 'textohtmlmoduleindex' => $level);
525 $section_headings{'textohtmlmoduleindex'} = 'h1';
Fred Drakebc7101d1998-03-06 21:18:55 +0000526
Fred Drake64bdc241998-04-17 02:14:12 +0000527 %section_commands = (%unnumbered_section_commands,
528 %section_commands);
Fred Drake11916921998-04-02 22:30:57 +0000529
530 make_sections_rx();
Fred Drake13210ed1998-03-17 06:28:05 +0000531}
Fred Drakebc7101d1998-03-06 21:18:55 +0000532
533
534# Fix from Ross Moore for ']' in \item[...]; this can be removed once the next
Fred Drake235e6b11998-03-27 05:19:43 +0000535# patch to LaTeX2HTML is released and tested ... if the patch gets included.
536# Be very careful to keep this around, just in case things break again!
Fred Drakebc7101d1998-03-06 21:18:55 +0000537#
538sub protect_useritems {
539 local(*_) = @_;
Fred Drake11916921998-04-02 22:30:57 +0000540 local($preitems,$thisitem);
Fred Drakebc7101d1998-03-06 21:18:55 +0000541 while (/\\item\s*\[/) {
Fred Drake11916921998-04-02 22:30:57 +0000542 $preitems .= $`;
543 $_ = $';
Fred Drakebc7101d1998-03-06 21:18:55 +0000544 $thisitem = $&.'<<'.++$global{'max_id'}.'>>';
545 s/^(((($O|$OP)\d+($C|$CP)).*\3|<[^<>]*>|[^\]<]+)*)\]/$thisitem.=$1;''/e;
Fred Drake11916921998-04-02 22:30:57 +0000546 $preitems .= $thisitem . '<<' . $global{'max_id'} . '>>]';
547 s/^]//;
Fred Drakebc7101d1998-03-06 21:18:55 +0000548 }
549 $_ = $preitems . $_;
550}
551
Fred Drake1072e461998-04-12 02:16:34 +0000552# This changes the markup used for {verbatim} environments, and is the
Fred Drake95474f91999-02-09 18:45:50 +0000553# best way I've found that ensures the <dl> goes on the outside of the
Fred Drake1072e461998-04-12 02:16:34 +0000554# <pre>...</pre>.
555#
556# Note that this *must* be done in the init file, not the python.perl
557# style support file. The %declarations must be set before initialize()
Fred Drakee15956b2000-04-03 04:51:13 +0000558# is called in the main LaTeX2HTML script (which happens before style files
559# are loaded).
Fred Drake1072e461998-04-12 02:16:34 +0000560#
Fred Drakee15956b2000-04-03 04:51:13 +0000561%declarations = ('preform' => '<dl><dd><pre class="verbatim"></pre></dl>',
Fred Drake1072e461998-04-12 02:16:34 +0000562 %declarations);
563
Fred Drakee15956b2000-04-03 04:51:13 +0000564
565# This is added to get rid of the long comment that follows the doctype
566# declaration; MSIE5 on NT4 SP4 barfs on it and drops the content of the
567# page.
568sub make_head_and_body {
569 local($title,$body) = @_;
570 local($DTDcomment) = '';
571 local($version,$isolanguage) = ($HTML_VERSION, 'EN');
572 local(%isolanguages) = ( 'english', 'EN' , 'USenglish', 'EN.US'
573 , 'original', 'EN' , 'german' , 'DE'
574 , 'austrian', 'DE.AT', 'french' , 'FR'
575 , 'spanish', 'ES'
576 , %isolanguages );
577 $isolanguage = $isolanguages{$default_language};
578 $isolanguage = 'EN' unless $isolanguage;
579 $title = &purify($title,1);
580 eval("\$title = ". $default_title ) unless ($title);
581
582 # allow user-modification of the <TITLE> tag; thanks Dan Young
583 if (defined &custom_TITLE_hook) {
584 $title = &custom_TITLE_hook($title, $toc_sec_title);
585 }
586
587 if ($DOCTYPE =~ /\/\/[\w\.]+\s*$/) { # language spec included
588 $DTDcomment = "<!DOCTYPE html PUBLIC \"$DOCTYPE\">\n";
589 } else {
590 $DTDcomment = "<!DOCTYPE html PUBLIC \"$DOCTYPE//"
591 . ($ISO_LANGUAGE ? $ISO_LANGUAGE : $isolanguage) . "\">\n";
592 }
593
594 $STYLESHEET = $FILE.".css" unless $STYLESHEET;
595 if (!$charset && $CHARSET) { $charset = $CHARSET; $charset =~ s/_/\-/go; }
596
597 join('', ($DOCTYPE ? $DTDcomment : '' )
598 ,"<html>\n<head>\n<title>", $title, "</title>\n"
599 , &meta_information($title)
600 , ($CHARSET && $HTML_VERSION ge "2.1" ?
601 "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=$charset\">\n"
602 : "" )
603 , ($BASE ? "<base href=\"$BASE\">\n" : "" )
604 , "<link rel=\"STYLESHEET\" href=\"$STYLESHEET\">"
605 , $more_links_mark
606 , "\n</head>\n<body $body>\n");
607}
608
Fred Drakebc7101d1998-03-06 21:18:55 +00006091; # This must be the last line